@applicaster/zapp-react-dom-app
Version:
Zapp App Component for Applicaster's Quick Brick React Native App
43 lines (37 loc) • 1.18 kB
JavaScript
/* global tizen */
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
import { QuickBrickCommunicationModule } from "../../Polyfills/QuickBrickCommunicationModule";
import { loadLocaleImpl, getLanguageCode } from "./utils";
async function getBrowserLocale() {
return navigator.language;
}
async function getSamsungLocale() {
return new Promise((resolve) => {
if (typeof tizen === "undefined") {
return getBrowserLocale().then(resolve);
}
try {
tizen.systeminfo.getPropertyValue("LOCALE", (locale) => {
resolve(locale.language);
});
} catch (e) {
console.warn(e); // eslint-disable-line no-console
getBrowserLocale().then(resolve);
}
});
}
const getLocale = platformSelect({
samsung_tv: getSamsungLocale,
default: getBrowserLocale,
});
/**
* Supported platforms: [Samsung] TODO: LG
* This function is adding languageLocale and countryLocale to the QuickBrickCommunicationModule
* @return Promise
* Warning! This function mutates QuickBrickCommunicationModule
*/
export const loadLocale = loadLocaleImpl(
getLocale,
getLanguageCode,
QuickBrickCommunicationModule
);