diff options
author | Sebastian <sebasjm@gmail.com> | 2022-03-14 15:20:32 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-03-14 15:21:24 -0300 |
commit | 08959f83bc9f6d5df93cb6c2d34b671bf419d05a (patch) | |
tree | 1a366b05453de18b598c9a587caea7ba6d1c93e7 /packages/taler-wallet-webextension/src/context/translation.ts | |
parent | 1d7c8f7083f2aa98295f1ad28399c8e19a9e7754 (diff) | |
download | wallet-core-08959f83bc9f6d5df93cb6c2d34b671bf419d05a.tar.xz |
take translator from transaltion context
Diffstat (limited to 'packages/taler-wallet-webextension/src/context/translation.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/context/translation.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/src/context/translation.ts b/packages/taler-wallet-webextension/src/context/translation.ts index 2ded07078..82ea41e32 100644 --- a/packages/taler-wallet-webextension/src/context/translation.ts +++ b/packages/taler-wallet-webextension/src/context/translation.ts @@ -31,7 +31,8 @@ interface Type { lang: string; supportedLang: { [id in keyof typeof supportedLang]: string } changeLanguage: (l: string) => void; - i18n: typeof i18n + i18n: typeof i18n; + isSaved: boolean; } const supportedLang = { @@ -44,7 +45,8 @@ const supportedLang = { it: "Italiano [it]", // ko: "한국어 [ko]", // ru: "Ру́сский язы́к [ru]", - tr: "Türk [tr]" + tr: "Türk [tr]", + navigator: "Defined by navigator", }; @@ -54,7 +56,8 @@ const initial = { changeLanguage: () => { // do not change anything }, - i18n + i18n, + isSaved: false, }; const Context = createContext<Type>(initial); @@ -69,7 +72,7 @@ export const TranslationProvider = ({ children, forceLang, }: Props): VNode => { - const [lang, changeLanguage] = useLang(initial); + const [lang, changeLanguage, isSaved] = useLang(initial); useEffect(() => { if (forceLang) { changeLanguage(forceLang); @@ -83,7 +86,7 @@ export const TranslationProvider = ({ } else { setupI18n(lang, strings); } - return h(Context.Provider, { value: { lang, changeLanguage, supportedLang, i18n }, children }); + return h(Context.Provider, { value: { lang, changeLanguage, supportedLang, i18n, isSaved }, children }); }; export const useTranslationContext = (): Type => useContext(Context); |