aboutsummaryrefslogtreecommitdiff
path: root/src/i18n.tsx
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-04-09 00:41:14 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-04-09 00:41:14 +0200
commita75ef403acf80685c560aed09c544f0a272c666f (patch)
treebcfae61fe2c03beac71dbc6fc8b10b2f4f2b7393 /src/i18n.tsx
parent6533716fac07e4988ef94231a0c0c8aba68e0d5e (diff)
make linter happy
Diffstat (limited to 'src/i18n.tsx')
-rw-r--r--src/i18n.tsx36
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]);
+}
/**