Tiqa / redux-polyglot

Polyglot.js bindings for Redux
MIT License
58 stars 13 forks source link

feature request - actions to add phrases #104

Open gotrecillo opened 6 years ago

gotrecillo commented 6 years ago

It can be nice to dynamically add phrases without removing the old ones, for example when using code splitting it can be nice to be able to do it.

Are you open to a pull request with this?

guillaumearm commented 6 years ago

Hi @gotrecillo

Sure, PRs are welcome 👍


How do you see the implementation ?

a @@polyglot/ADD_PHRASES action ?

const addPhrases = (locale, phrases) => ({
  type: '@@polyglot/ADD_PHRASES',
  payload: { locale, phrases },
});

Wrong locale edge case

In your case, if you want to add phrases, you have to be aware of your current locale in your own code (you can use getLocale selector).

dispatch a ADD_PHRASES with wrong locale won't do anything.


Cache phrases

Regarding #15, we would make a cache of phrases, ADD_PHRASES should be take in consideration too.

Actually, there is no way to make a cache of phrases, so it's not the scope of this issue.


Anyway, thank you for taking the time to make an issue :-)

gotrecillo commented 5 years ago

I will make it this weekend 👍