APSL/redux-i18n

Add new language translations on demand.

fabiulous opened this issue · 10 comments

Have you considered the possibility to add the languages into reducer?

It would help loading additional strings on demand, when changing a language, instead of including the whole language array in the first load.

Let me know what you think (even if it's a bad idea). I might be able to help

Hi!

Can you tell me in which cases would be necessary update translations object?

I can do it, but I'm not sure that save this big object in reducer be a right decisions.

In my case, I use often this package (https://github.com/elgerlambert/redux-localstorage) and maybe translations object could not be stored in localstorage because is very big.

But, I could add some parameter into component for decide if save translation to reducer, or not.

Thanks.

As the application grows, translations tend to grow quite a lot also, adding a lot to the overall size of the js bundle. There is no need for a user who speaks only english to download js with french text.

Having it in reducer, would allow to fetch a new language from the api and then add it to the existing translations list in the reducer.

Similar to angular-gettext lazy loading https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/

Hi,

Oh yes! Now I think that's a really good feature! I love load async translations.

I'll work about that at next days. I'll add an option for select how you want use translations object (bundle or reducer).

Thank you so much.

Awesome! Let me know if you want some help.

Hi,

I already have done but I don't want to create a tag, yet. I prefer test it a little bit more.

If you want to help me, please install package directly from git and test it, too.

    "redux-i18n": "git+ssh://git@github.com:APSL/redux-i18n.git#trans_to_reducer",

Documentation is here:

https://github.com/APSL/redux-i18n/tree/trans_to_reducer#async-translations

Thank you so much.

I will check it out better when I got some time this week.
It seems you added possibility to load all the languages. That's already a good improvement.

Would be great to do this.props.dispatch(setTranslation(r.translations, 'fr'))
And then extend the existing object with the new language.

So when I fetch for italian then we do this.props.dispatch(setTranslation(r.translations, 'it'))

Hi Fabio,
You're right. I going to do it later.
Thanks

Hi,
It's done. Now is possible to pass a second parameter to "setTranslations" action, for set language.
Best regards.

Hi!

I've created new version (1.2.0) because I was very excited. I couldn't wait more... :)

Unit test pass and I think that all is well.

Best regards.

Oh man, that was fast!
Awesome :D