1 |
|
2 | import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
3 | import * as R from "ramda";
|
4 | import { QuickBrickCommunicationModule } from "../../Polyfills/QuickBrickCommunicationModule";
|
5 |
|
6 | type Locale = {
|
7 | language: string,
|
8 | country: string,
|
9 | };
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export function loadLocale() {
|
18 | const getDefault = () => Promise.resolve();
|
19 | const getSamsungLocale = () =>
|
20 | new Promise((resolve, reject) => {
|
21 | if (typeof tizen === "undefined") resolve();
|
22 | try {
|
23 | tizen.systeminfo.getPropertyValue(
|
24 | "LOCALE",
|
25 | (locale: Locale) => {
|
26 | const { language } = locale;
|
27 | const [languageLocale, countryLocale] = R.compose(
|
28 | R.map(R.toLower),
|
29 | R.split("_")
|
30 | )(language);
|
31 |
|
32 | QuickBrickCommunicationModule.languageLocale = languageLocale;
|
33 | QuickBrickCommunicationModule.countryLocale = countryLocale;
|
34 | resolve();
|
35 | },
|
36 | err => {
|
37 | reject(new Error(err));
|
38 | }
|
39 | );
|
40 | } catch (err) {
|
41 | reject(new Error(err));
|
42 | }
|
43 | });
|
44 |
|
45 | return platformSelect({
|
46 | samsung_tv: getSamsungLocale,
|
47 | lg_tv: getDefault,
|
48 | default: getDefault,
|
49 | })();
|
50 | }
|