diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-04-09 00:41:14 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-04-09 00:41:14 +0200 |
commit | a75ef403acf80685c560aed09c544f0a272c666f (patch) | |
tree | bcfae61fe2c03beac71dbc6fc8b10b2f4f2b7393 /src/i18n.tsx | |
parent | 6533716fac07e4988ef94231a0c0c8aba68e0d5e (diff) |
make linter happy
Diffstat (limited to 'src/i18n.tsx')
-rw-r--r-- | src/i18n.tsx | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/i18n.tsx b/src/i18n.tsx index dfd1528e3..ddf4fb768 100644 --- a/src/i18n.tsx +++ b/src/i18n.tsx @@ -26,23 +26,31 @@ import {strings} from "./i18n/strings"; import * as jedLib from "jed"; import * as React from "react"; -let lang: string; -try { - lang = chrome.i18n.getUILanguage(); - // Chrome gives e.g. "en-US", but Firefox gives us "en_US" - lang = lang.replace("_", "-"); -} catch (e) { - lang = "en"; - console.warn("i18n default language not available"); -} -if (!strings[lang]) { - lang = "en-US"; - console.log(`language ${lang} not found, defaulting to english`); -} +const jed = setupJed(); -const jed = new jedLib.Jed(strings[lang]); +/** + * Set up jed library for internationalization, + * based on browser language settings. + */ +function setupJed(): any { + let lang: string; + try { + lang = chrome.i18n.getUILanguage(); + // Chrome gives e.g. "en-US", but Firefox gives us "en_US" + lang = lang.replace("_", "-"); + } catch (e) { + lang = "en"; + console.warn("i18n default language not available"); + } + + if (!strings[lang]) { + lang = "en-US"; + console.log(`language ${lang} not found, defaulting to english`); + } + return new jedLib.Jed(strings[lang]); +} /** |