Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const l10n = {
- "ru": {
- "Language": "Язык",
- "Contacts": "Контакты"
- },
- "de": {
- "Language": "Sprache",
- "Contacts": "Kontakte"
- }
- };
- // ...
- function useLocalize() {
- //ToDo: need cache?
- const language = useSelector(state => state.language);
- const l10nDict = useSelector(state => state.l10nDict[language]);
- return (!l10nDict)
- ? key => key
- : key => l10nDict[key] || key;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement