diff options
author | 2018-11-30 14:32:45 +0100 | |
---|---|---|
committer | 2018-11-30 14:32:45 +0100 | |
commit | 3d87c0e45cead95ddb6c11fc6540b82e375bdcf5 (patch) | |
tree | c91f425a39cb585242d6df5b4070de4a2141b3b4 /src/helpers | |
parent | Merge branch 'update/monetization' into develop (diff) | |
download | ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.tar.gz ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.tar.zst ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.zip |
feat(App): Improved spell checker & context menu
Diffstat (limited to 'src/helpers')
-rw-r--r-- | src/helpers/i18n-helpers.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/helpers/i18n-helpers.js b/src/helpers/i18n-helpers.js new file mode 100644 index 000000000..afd28cab4 --- /dev/null +++ b/src/helpers/i18n-helpers.js | |||
@@ -0,0 +1,27 @@ | |||
1 | export function getLocale({ locale, locales, defaultLocale, fallbackLocale }) { | ||
2 | let localeStr = locale; | ||
3 | if (locales[locale] === undefined) { | ||
4 | let localeFuzzy; | ||
5 | Object.keys(locales).forEach((localStr) => { | ||
6 | if (locales && Object.hasOwnProperty.call(locales, localStr)) { | ||
7 | if (locale.substring(0, 2) === localStr.substring(0, 2)) { | ||
8 | localeFuzzy = localStr; | ||
9 | } | ||
10 | } | ||
11 | }); | ||
12 | |||
13 | if (localeFuzzy !== undefined) { | ||
14 | localeStr = localeFuzzy; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | if (locales[localeStr] === undefined) { | ||
19 | localeStr = defaultLocale; | ||
20 | } | ||
21 | |||
22 | if (!localeStr) { | ||
23 | localeStr = fallbackLocale; | ||
24 | } | ||
25 | |||
26 | return localeStr; | ||
27 | } | ||