dkfbasel / vuex-i18n

Localization plugin for vue.js 2.0 using vuex as store
MIT License
665 stars 56 forks source link

What is the difference between this package and vuex + i18n installed individually? #80

Closed rlam3 closed 5 years ago

rlam3 commented 6 years ago

What is the difference between this package and vuex + i18n installed individually?

tikiatua commented 6 years ago

Hi @rlam3

Thank you for your question. The vuex-i18n package is using a vuex module to store all translation information. Translations are accessed via some helper functions provided by the plugin. It does NOT make use of the i18n-package.

The i18n plugin uses a different mechanism (without vuex) to store the translation information. It also provides additional methods and components for localization.

I would recommend to choose the library depending on your use case. vuex-i18n uses the built in functionality of vuex and is quite easy to use. vue-i18n provides a wide range of methods, but is also somewhat more complex.

rlam3 commented 6 years ago

@tikiatua Thanks for your reply. I'm interested into understanding more and would love your feedback on when to use vuex-i18n over the normal i18n package it still a bit confusing for me as it seems like both are just trying to achieve the same outcome. Some different use cases would probably be best to help others as well.

cuivip commented 6 years ago

you mean the difference about this(https://kazupon.github.io/vue-i18n/) project ?? I am confused with this question and reply. BUT I really want to know the difference bettween vuex-i18n and vue-i18n.

tikiatua commented 6 years ago

Hi @cuivip

Thank you for your comment. The reply was really somewhat confusing as my autocomplete mixed some things up. I edited the reply to make it somewhat more clear.

If you really want to understand the difference, I would recommend to quickly browse the source code of the two projects. Our idea was, that vuex provides a lot of functionality for reactive state management. Therefore we write a rather small plugin, that uses a vuex module to store the state and some more elaborate methods to fetch the respective locale, taking into account various specific localization use cases (i.e. pluralization, regional locales).

This keeps the code base rather small and easy to maintain. But it also means, that we do not handle loading of locale information or more complex use cases.

Vue-i18n employs a different approach and provides a fare more expansive toolset for localization. In my personal opinion, some of them encourage programming behavior that I would not necessarily recommend. But many things are really helpful.

In the end it is up for you to decide, which approach fits better with your project.

havelock commented 6 years ago

This project, unlike vue-i18n, does not seem to ignore that in a lot of languages pluralforms are more complex than "0 - 1 - many", rendering the former unusable for those. https://github.com/kazupon/vue-i18n/issues/78 (open since 2016!)

PS. Kudos for an example in Latvian language, I happen to be from Latvia and didn't expect this :)

lysz210 commented 5 years ago

The goal of the 2 plugins are the same but they differ in the way they achieve it. I tried vue-i18n and is very flexible in managing static translation, by static I mean that you must have in advance all the translations. I was looking for something more flaxible for real-time translations adding new translation dynamically using Yandex translate backed with Laravel api. At a first glance I think vuex-i18n get all the benefit of vuex dynamic state management making easier to control lazy loading. For example in the vue-i18n docs they explain the lazy-loading but it's mostly using webpack way to extract locales as modules and lazy-loading later. You can get the same result using ajax, but they don't accept (yet) async function for messages or locales. There is also i18next but it looks more complex than vue-i18n and vuex-i18n. I think the best way to choose between vue-i18n and vuex-i18n is your familiar with vuex and use it on your app vuex-i18n is probably your choice, use it also if your translations are very basic. Use vue-i18n if you need to customize pluralization ad custom interpolation.