gt-react-native 10.19.15 → 10.19.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/NativeGtReactNative.js +9 -7
- package/dist/commonjs/NativeGtReactNative.js.map +1 -1
- package/dist/commonjs/_virtual/_rolldown/runtime.js +23 -0
- package/dist/commonjs/errors-dir/constants.js +5 -6
- package/dist/commonjs/errors-dir/constants.js.map +1 -1
- package/dist/commonjs/errors-dir/errors.js +12 -7
- package/dist/commonjs/errors-dir/errors.js.map +1 -1
- package/dist/commonjs/errors-dir/warnings.js +34 -15
- package/dist/commonjs/errors-dir/warnings.js.map +1 -1
- package/dist/commonjs/index.js +35 -194
- package/dist/commonjs/internal.js +3 -13
- package/dist/commonjs/plugin-dir/index.js +35 -51
- package/dist/commonjs/plugin-dir/index.js.map +1 -1
- package/dist/commonjs/plugin-dir/types.js +24 -9
- package/dist/commonjs/plugin-dir/types.js.map +1 -1
- package/dist/commonjs/plugin-dir/utils/resolveLocales.js +52 -69
- package/dist/commonjs/plugin-dir/utils/resolveLocales.js.map +1 -1
- package/dist/commonjs/plugin.js +5 -13
- package/dist/commonjs/provider/GTProvider.js +22 -20
- package/dist/commonjs/provider/GTProvider.js.map +1 -1
- package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js +96 -160
- package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js.map +1 -1
- package/dist/commonjs/provider/hooks/useRegionState.js +32 -44
- package/dist/commonjs/provider/hooks/useRegionState.js.map +1 -1
- package/dist/commonjs/tools/testLocalePolyfill.js +125 -146
- package/dist/commonjs/tools/testLocalePolyfill.js.map +1 -1
- package/dist/commonjs/types/config.js +1 -6
- package/dist/commonjs/utils/getNativeLocales.js +36 -51
- package/dist/commonjs/utils/getNativeLocales.js.map +1 -1
- package/dist/commonjs/utils/nativeStore.js +37 -42
- package/dist/commonjs/utils/nativeStore.js.map +1 -1
- package/dist/commonjs/utils/utils.js +10 -14
- package/dist/commonjs/utils/utils.js.map +1 -1
- package/dist/module/NativeGtReactNative.d.ts.map +1 -0
- package/dist/module/NativeGtReactNative.js +5 -3
- package/dist/module/NativeGtReactNative.js.map +1 -1
- package/dist/module/errors-dir/constants.d.ts.map +1 -0
- package/dist/module/errors-dir/constants.js +4 -2
- package/dist/module/errors-dir/constants.js.map +1 -1
- package/dist/module/errors-dir/errors.d.ts.map +1 -0
- package/dist/module/errors-dir/errors.js +11 -3
- package/dist/module/errors-dir/errors.js.map +1 -1
- package/dist/{typescript/commonjs/src → module}/errors-dir/warnings.d.ts +1 -1
- package/dist/module/errors-dir/warnings.d.ts.map +1 -0
- package/dist/module/errors-dir/warnings.js +31 -11
- package/dist/module/errors-dir/warnings.js.map +1 -1
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +2 -5
- package/dist/module/internal.d.ts.map +1 -0
- package/dist/module/internal.js +2 -4
- package/dist/module/plugin-dir/index.d.ts.map +1 -0
- package/dist/module/plugin-dir/index.js +28 -45
- package/dist/module/plugin-dir/index.js.map +1 -1
- package/dist/{typescript/commonjs/src → module}/plugin-dir/types.d.ts +1 -1
- package/dist/module/plugin-dir/types.d.ts.map +1 -0
- package/dist/module/plugin-dir/types.js +22 -5
- package/dist/module/plugin-dir/types.js.map +1 -1
- package/dist/{typescript/commonjs/src → module}/plugin-dir/utils/resolveLocales.d.ts +1 -1
- package/dist/module/plugin-dir/utils/resolveLocales.d.ts.map +1 -0
- package/dist/module/plugin-dir/utils/resolveLocales.js +46 -62
- package/dist/module/plugin-dir/utils/resolveLocales.js.map +1 -1
- package/dist/module/plugin.d.ts.map +1 -0
- package/dist/module/plugin.js +2 -4
- package/dist/module/provider/GTProvider.d.ts.map +1 -0
- package/dist/module/provider/GTProvider.js +15 -14
- package/dist/module/provider/GTProvider.js.map +1 -1
- package/dist/module/provider/hooks/locale/useDetermineLocale.d.ts.map +1 -0
- package/dist/module/provider/hooks/locale/useDetermineLocale.js +91 -153
- package/dist/module/provider/hooks/locale/useDetermineLocale.js.map +1 -1
- package/dist/module/provider/hooks/useRegionState.d.ts.map +1 -0
- package/dist/module/provider/hooks/useRegionState.js +29 -39
- package/dist/module/provider/hooks/useRegionState.js.map +1 -1
- package/dist/module/tools/testLocalePolyfill.d.ts.map +1 -0
- package/dist/module/tools/testLocalePolyfill.js +124 -143
- package/dist/module/tools/testLocalePolyfill.js.map +1 -1
- package/dist/{typescript/commonjs/src → module}/types/config.d.ts +4 -4
- package/dist/module/types/config.d.ts.map +1 -0
- package/dist/module/types/config.js +0 -3
- package/dist/module/utils/getNativeLocales.d.ts.map +1 -0
- package/dist/module/utils/getNativeLocales.js +35 -48
- package/dist/module/utils/getNativeLocales.js.map +1 -1
- package/dist/module/utils/nativeStore.d.ts.map +1 -0
- package/dist/module/utils/nativeStore.js +35 -38
- package/dist/module/utils/nativeStore.js.map +1 -1
- package/dist/module/utils/utils.d.ts.map +1 -0
- package/dist/module/utils/utils.js +10 -11
- package/dist/module/utils/utils.js.map +1 -1
- package/package.json +15 -36
- package/src/errors-dir/errors.ts +8 -1
- package/src/errors-dir/warnings.ts +30 -9
- package/src/plugin-dir/types.ts +4 -1
- package/src/plugin-dir/utils/resolveLocales.ts +4 -1
- package/src/provider/hooks/locale/useDetermineLocale.ts +7 -3
- package/src/types/config.ts +4 -3
- package/src/utils/getNativeLocales.ts +7 -2
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/internal.js.map +0 -1
- package/dist/commonjs/package.json +0 -1
- package/dist/commonjs/plugin.js.map +0 -1
- package/dist/commonjs/types/config.js.map +0 -1
- package/dist/module/index.js.map +0 -1
- package/dist/module/internal.js.map +0 -1
- package/dist/module/package.json +0 -1
- package/dist/module/plugin.js.map +0 -1
- package/dist/module/types/config.js.map +0 -1
- package/dist/typescript/commonjs/package.json +0 -1
- package/dist/typescript/commonjs/src/NativeGtReactNative.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/errors-dir/constants.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/errors-dir/errors.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/errors-dir/warnings.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/index.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/internal.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/plugin-dir/index.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/plugin-dir/types.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/plugin.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/provider/GTProvider.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/provider/hooks/useRegionState.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/tools/testLocalePolyfill.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/types/config.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/utils/getNativeLocales.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/utils/nativeStore.d.ts.map +0 -1
- package/dist/typescript/commonjs/src/utils/utils.d.ts.map +0 -1
- package/dist/typescript/module/package.json +0 -1
- package/dist/typescript/module/src/NativeGtReactNative.d.ts +0 -10
- package/dist/typescript/module/src/NativeGtReactNative.d.ts.map +0 -1
- package/dist/typescript/module/src/errors-dir/constants.d.ts +0 -2
- package/dist/typescript/module/src/errors-dir/constants.d.ts.map +0 -1
- package/dist/typescript/module/src/errors-dir/errors.d.ts +0 -2
- package/dist/typescript/module/src/errors-dir/errors.d.ts.map +0 -1
- package/dist/typescript/module/src/errors-dir/warnings.d.ts +0 -5
- package/dist/typescript/module/src/errors-dir/warnings.d.ts.map +0 -1
- package/dist/typescript/module/src/index.d.ts +0 -5
- package/dist/typescript/module/src/index.d.ts.map +0 -1
- package/dist/typescript/module/src/internal.d.ts +0 -2
- package/dist/typescript/module/src/internal.d.ts.map +0 -1
- package/dist/typescript/module/src/plugin-dir/index.d.ts +0 -6
- package/dist/typescript/module/src/plugin-dir/index.d.ts.map +0 -1
- package/dist/typescript/module/src/plugin-dir/types.d.ts +0 -13
- package/dist/typescript/module/src/plugin-dir/types.d.ts.map +0 -1
- package/dist/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts +0 -13
- package/dist/typescript/module/src/plugin-dir/utils/resolveLocales.d.ts.map +0 -1
- package/dist/typescript/module/src/plugin.d.ts +0 -2
- package/dist/typescript/module/src/plugin.d.ts.map +0 -1
- package/dist/typescript/module/src/provider/GTProvider.d.ts +0 -4
- package/dist/typescript/module/src/provider/GTProvider.d.ts.map +0 -1
- package/dist/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts +0 -4
- package/dist/typescript/module/src/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
- package/dist/typescript/module/src/provider/hooks/useRegionState.d.ts +0 -3
- package/dist/typescript/module/src/provider/hooks/useRegionState.d.ts.map +0 -1
- package/dist/typescript/module/src/tools/testLocalePolyfill.d.ts +0 -8
- package/dist/typescript/module/src/tools/testLocalePolyfill.d.ts.map +0 -1
- package/dist/typescript/module/src/types/config.d.ts +0 -30
- package/dist/typescript/module/src/types/config.d.ts.map +0 -1
- package/dist/typescript/module/src/utils/getNativeLocales.d.ts +0 -10
- package/dist/typescript/module/src/utils/getNativeLocales.d.ts.map +0 -1
- package/dist/typescript/module/src/utils/nativeStore.d.ts +0 -16
- package/dist/typescript/module/src/utils/nativeStore.d.ts.map +0 -1
- package/dist/typescript/module/src/utils/utils.d.ts +0 -3
- package/dist/typescript/module/src/utils/utils.d.ts.map +0 -1
- /package/dist/{typescript/commonjs/src → module}/NativeGtReactNative.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/errors-dir/constants.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/errors-dir/errors.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/index.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/internal.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/plugin-dir/index.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/plugin.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/provider/GTProvider.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/provider/hooks/locale/useDetermineLocale.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/provider/hooks/useRegionState.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/tools/testLocalePolyfill.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/utils/getNativeLocales.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/utils/nativeStore.d.ts +0 -0
- /package/dist/{typescript/commonjs/src → module}/utils/utils.d.ts +0 -0
|
@@ -1,75 +1,58 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
const DEFAULT_CONFIG_FILE_PATHS = [_path.default.join(process.cwd(), 'gt.config.json'), _path.default.join(process.cwd(), '.locadex', 'gt.config.json')];
|
|
15
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
const require_errors_dir_warnings = require("../../errors-dir/warnings.js");
|
|
4
|
+
const require_errors_dir_errors = require("../../errors-dir/errors.js");
|
|
5
|
+
let generaltranslation_internal = require("generaltranslation/internal");
|
|
6
|
+
let path = require("path");
|
|
7
|
+
path = require_runtime.__toESM(path);
|
|
8
|
+
let fs = require("fs");
|
|
9
|
+
fs = require_runtime.__toESM(fs);
|
|
10
|
+
let _generaltranslation_supported_locales = require("@generaltranslation/supported-locales");
|
|
11
|
+
//#region src/plugin-dir/utils/resolveLocales.ts
|
|
12
|
+
const DEFAULT_CONFIG_FILE_PATHS = [path.default.join(process.cwd(), "gt.config.json"), path.default.join(process.cwd(), ".locadex", "gt.config.json")];
|
|
16
13
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function resolveLocales({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Validate the result
|
|
37
|
-
const invalidLocales = result.filter(locale => !(0, _supportedLocales.getSupportedLocale)(locale));
|
|
38
|
-
if (invalidLocales.length) {
|
|
39
|
-
console.warn((0, _warnings.invalidLocalesWarning)(invalidLocales));
|
|
40
|
-
result = result.filter(locale => !invalidLocales.includes(locale));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Fallback to default locale if no locales were found
|
|
44
|
-
if (result.length === 0) {
|
|
45
|
-
console.warn(_warnings.resolveLocalesFailedWarning);
|
|
46
|
-
result = [_internal.libraryDefaultLocale];
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
14
|
+
* Given a list of locales or a config object or a path to a config file, return a list of locales to polyfill.
|
|
15
|
+
* Preference order: locales > config > configFilePaths > library default locale
|
|
16
|
+
*/
|
|
17
|
+
function resolveLocales({ locales, config, configFilePath }) {
|
|
18
|
+
let result = [];
|
|
19
|
+
if (locales) result = Array.from(new Set(locales));
|
|
20
|
+
else if (config) result = Array.from(new Set([config.defaultLocale, ...config.locales]));
|
|
21
|
+
else result = resolveLocalesFromConfig(configFilePath);
|
|
22
|
+
const invalidLocales = result.filter((locale) => !(0, _generaltranslation_supported_locales.getSupportedLocale)(locale));
|
|
23
|
+
if (invalidLocales.length) {
|
|
24
|
+
console.warn(require_errors_dir_warnings.invalidLocalesWarning(invalidLocales));
|
|
25
|
+
result = result.filter((locale) => !invalidLocales.includes(locale));
|
|
26
|
+
}
|
|
27
|
+
if (result.length === 0) {
|
|
28
|
+
console.warn(require_errors_dir_warnings.resolveLocalesFailedWarning);
|
|
29
|
+
result = [generaltranslation_internal.libraryDefaultLocale];
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
49
32
|
}
|
|
50
|
-
|
|
51
33
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
* Resolve locales from a config file
|
|
35
|
+
* @param configFilePath - The path to the config file
|
|
36
|
+
* @returns A list of locales
|
|
37
|
+
*/
|
|
56
38
|
function resolveLocalesFromConfig(configFilePath) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
39
|
+
const configFilePaths = [...configFilePath ? [configFilePath] : [], ...DEFAULT_CONFIG_FILE_PATHS];
|
|
40
|
+
let result = [];
|
|
41
|
+
for (const filePath of configFilePaths) try {
|
|
42
|
+
if (!fs.default.existsSync(filePath)) {
|
|
43
|
+
console.warn(require_errors_dir_warnings.couldNotLocateConfigWarning(filePath));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const resolvedConfig = JSON.parse(fs.default.readFileSync(filePath, "utf8"));
|
|
47
|
+
result = Array.from(new Set([...resolvedConfig.defaultLocale ? [resolvedConfig.defaultLocale] : [], ...resolvedConfig.locales || []]));
|
|
48
|
+
break;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(require_errors_dir_errors.failedToReadConfigFileError(filePath), error);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
74
54
|
}
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.resolveLocales = resolveLocales;
|
|
57
|
+
|
|
75
58
|
//# sourceMappingURL=resolveLocales.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolveLocales.js","names":["invalidLocalesWarning","resolveLocalesFailedWarning","libraryDefaultLocale","couldNotLocateConfigWarning","failedToReadConfigFileError"],"sources":["../../../../src/plugin-dir/utils/resolveLocales.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n couldNotLocateConfigWarning,\n invalidLocalesWarning,\n resolveLocalesFailedWarning,\n} from '../../errors-dir/warnings';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport { failedToReadConfigFileError } from '../../errors-dir/errors';\nimport { getSupportedLocale } from '@generaltranslation/supported-locales';\nimport path from 'path';\n\nconst DEFAULT_CONFIG_FILE_PATHS = [\n path.join(process.cwd(), 'gt.config.json'),\n path.join(process.cwd(), '.locadex', 'gt.config.json'),\n];\n\n/**\n * Given a list of locales or a config object or a path to a config file, return a list of locales to polyfill.\n * Preference order: locales > config > configFilePaths > library default locale\n */\nexport function resolveLocales({\n locales,\n config,\n configFilePath,\n}: {\n locales?: string[];\n config?: { defaultLocale: string; locales: string[] } & Record<\n string,\n unknown\n >;\n configFilePath?: string;\n}): string[] {\n let result: string[] = [];\n\n // Resolve locales from the given options\n if (locales) {\n result = Array.from(new Set(locales));\n } else if (config) {\n result = Array.from(new Set([config.defaultLocale, ...config.locales]));\n } else {\n result = resolveLocalesFromConfig(configFilePath);\n }\n\n // Validate the result\n const invalidLocales = result.filter((locale) => !getSupportedLocale(locale));\n if (invalidLocales.length) {\n console.warn(invalidLocalesWarning(invalidLocales));\n result = result.filter((locale) => !invalidLocales.includes(locale));\n }\n\n // Fallback to default locale if no locales were found\n if (result.length === 0) {\n console.warn(resolveLocalesFailedWarning);\n result = [libraryDefaultLocale];\n }\n\n return result;\n}\n\n/**\n * Resolve locales from a config file\n * @param configFilePath - The path to the config file\n * @returns A list of locales\n */\nfunction resolveLocalesFromConfig(configFilePath: string | undefined) {\n const configFilePaths = [\n ...(configFilePath ? [configFilePath] : []),\n ...DEFAULT_CONFIG_FILE_PATHS,\n ];\n let result: string[] = [];\n\n for (const filePath of configFilePaths) {\n try {\n if (!fs.existsSync(filePath)) {\n console.warn(couldNotLocateConfigWarning(filePath));\n continue;\n }\n\n const resolvedConfig = JSON.parse(fs.readFileSync(filePath, 'utf8')) as {\n defaultLocale?: string;\n locales?: string[];\n };\n\n result = Array.from(\n new Set([\n ...(resolvedConfig.defaultLocale\n ? [resolvedConfig.defaultLocale]\n : []),\n ...(resolvedConfig.locales || []),\n ])\n );\n break;\n } catch (error) {\n console.error(failedToReadConfigFileError(filePath), error);\n break;\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,4BAA4B,CAChC,KAAA,QAAK,KAAK,QAAQ,KAAK,EAAE,iBAAiB,EAC1C,KAAA,QAAK,KAAK,QAAQ,KAAK,EAAE,YAAY,iBAAiB,CACvD;;;;;AAMD,SAAgB,eAAe,EAC7B,SACA,QACA,kBAQW;CACX,IAAI,SAAmB,EAAE;AAGzB,KAAI,QACF,UAAS,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC;UAC5B,OACT,UAAS,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,eAAe,GAAG,OAAO,QAAQ,CAAC,CAAC;KAEvE,UAAS,yBAAyB,eAAe;CAInD,MAAM,iBAAiB,OAAO,QAAQ,WAAW,EAAA,GAAA,sCAAA,oBAAoB,OAAO,CAAC;AAC7E,KAAI,eAAe,QAAQ;AACzB,UAAQ,KAAKA,4BAAAA,sBAAsB,eAAe,CAAC;AACnD,WAAS,OAAO,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC;;AAItE,KAAI,OAAO,WAAW,GAAG;AACvB,UAAQ,KAAKC,4BAAAA,4BAA4B;AACzC,WAAS,CAACC,4BAAAA,qBAAqB;;AAGjC,QAAO;;;;;;;AAQT,SAAS,yBAAyB,gBAAoC;CACpE,MAAM,kBAAkB,CACtB,GAAI,iBAAiB,CAAC,eAAe,GAAG,EAAE,EAC1C,GAAG,0BACJ;CACD,IAAI,SAAmB,EAAE;AAEzB,MAAK,MAAM,YAAY,gBACrB,KAAI;AACF,MAAI,CAAC,GAAA,QAAG,WAAW,SAAS,EAAE;AAC5B,WAAQ,KAAKC,4BAAAA,4BAA4B,SAAS,CAAC;AACnD;;EAGF,MAAM,iBAAiB,KAAK,MAAM,GAAA,QAAG,aAAa,UAAU,OAAO,CAAC;AAKpE,WAAS,MAAM,KACb,IAAI,IAAI,CACN,GAAI,eAAe,gBACf,CAAC,eAAe,cAAc,GAC9B,EAAE,EACN,GAAI,eAAe,WAAW,EAAE,CACjC,CAAC,CACH;AACD;UACO,OAAO;AACd,UAAQ,MAAMC,0BAAAA,4BAA4B,SAAS,EAAE,MAAM;AAC3D;;AAGJ,QAAO"}
|
package/dist/commonjs/plugin.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get: function () {
|
|
9
|
-
return _pluginDir.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _pluginDir = _interopRequireDefault(require("./plugin-dir"));
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
//# sourceMappingURL=plugin.js.map
|
|
5
|
+
const require_plugin_dir_index = require("./plugin-dir/index.js");
|
|
6
|
+
exports.default = require_plugin_dir_index.default;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
6
|
+
const require_provider_hooks_locale_useDetermineLocale = require("./hooks/locale/useDetermineLocale.js");
|
|
7
|
+
const require_utils_utils = require("../utils/utils.js");
|
|
8
|
+
const require_provider_hooks_useRegionState = require("./hooks/useRegionState.js");
|
|
9
|
+
let _generaltranslation_react_core = require("@generaltranslation/react-core");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
//#region src/provider/GTProvider.tsx
|
|
13
12
|
function GTProvider(props) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_generaltranslation_react_core.GTProvider, {
|
|
14
|
+
ssr: false,
|
|
15
|
+
environment: __DEV__ ? "development" : "production",
|
|
16
|
+
...props,
|
|
17
|
+
readAuthFromEnv: require_utils_utils.readAuthFromEnv,
|
|
18
|
+
useDetermineLocale: require_provider_hooks_locale_useDetermineLocale.useDetermineLocale,
|
|
19
|
+
useRegionState: require_provider_hooks_useRegionState.useRegionState
|
|
20
|
+
});
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.GTProvider = GTProvider;
|
|
24
|
+
exports.default = GTProvider;
|
|
25
|
+
|
|
24
26
|
//# sourceMappingURL=GTProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"GTProvider.js","names":["_GTProvider","readAuthFromEnv","useDetermineLocale","useRegionState"],"sources":["../../../src/provider/GTProvider.tsx"],"sourcesContent":["import { useDetermineLocale } from './hooks/locale/useDetermineLocale';\nimport type { GTProviderProps } from '../types/config';\nimport { GTProvider as _GTProvider } from '@generaltranslation/react-core';\nimport { readAuthFromEnv } from '../utils/utils';\nimport { useRegionState } from './hooks/useRegionState';\n\nexport function GTProvider(props: GTProviderProps): React.JSX.Element {\n return (\n <_GTProvider\n ssr={false}\n environment={__DEV__ ? 'development' : 'production'}\n {...props}\n readAuthFromEnv={readAuthFromEnv}\n useDetermineLocale={useDetermineLocale}\n useRegionState={useRegionState}\n />\n );\n}\n\nexport default GTProvider;\n"],"mappings":";;;;;;;;;;;AAMA,SAAgB,WAAW,OAA2C;AACpE,QACE,iBAAA,GAAA,kBAAA,KAACA,+BAAAA,YAAD;EACE,KAAK;EACL,aAAa,UAAU,gBAAgB;EACvC,GAAI;EACJ,iBAAiBC,oBAAAA;EACjB,oBAAoBC,iDAAAA;EACpB,gBAAgBC,sCAAAA;EAChB,CAAA"}
|
|
@@ -1,165 +1,101 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// check browser for locales
|
|
58
|
-
(0, _react.useEffect)(() => {
|
|
59
|
-
const newLocale = getNewLocale({
|
|
60
|
-
_locale,
|
|
61
|
-
locale,
|
|
62
|
-
locales,
|
|
63
|
-
defaultLocale,
|
|
64
|
-
localeCookieName,
|
|
65
|
-
customMapping,
|
|
66
|
-
enableI18n
|
|
67
|
-
});
|
|
68
|
-
setLocaleWithoutPersist(newLocale);
|
|
69
|
-
}, [_locale, locale, locales, defaultLocale, localeCookieName, customMapping, enableI18n]);
|
|
70
|
-
return [locale, setLocale];
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../../_virtual/_rolldown/runtime.js");
|
|
3
|
+
const require_errors_dir_constants = require("../../../errors-dir/constants.js");
|
|
4
|
+
const require_utils_getNativeLocales = require("../../../utils/getNativeLocales.js");
|
|
5
|
+
const require_utils_nativeStore = require("../../../utils/nativeStore.js");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let _generaltranslation_format = require("@generaltranslation/format");
|
|
8
|
+
let generaltranslation_internal = require("generaltranslation/internal");
|
|
9
|
+
let _generaltranslation_react_core_errors = require("@generaltranslation/react-core/errors");
|
|
10
|
+
//#region src/provider/hooks/locale/useDetermineLocale.ts
|
|
11
|
+
function useDetermineLocale({ locale: _locale = "", defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales = [], localeCookieName = "generaltranslation.locale", ssr = false, customMapping, enableI18n }) {
|
|
12
|
+
_locale = (0, _generaltranslation_format.resolveAliasLocale)(_locale, customMapping);
|
|
13
|
+
locales = locales.map((locale) => (0, _generaltranslation_format.resolveAliasLocale)(locale, customMapping));
|
|
14
|
+
const initializeLocale = () => {
|
|
15
|
+
if (!enableI18n) return defaultLocale;
|
|
16
|
+
return (0, _generaltranslation_format.resolveAliasLocale)(ssr ? _locale ? (0, _generaltranslation_format.determineLocale)(_locale, locales, customMapping) || "" : "" : getNewLocale({
|
|
17
|
+
_locale,
|
|
18
|
+
locale: _locale,
|
|
19
|
+
locales,
|
|
20
|
+
defaultLocale,
|
|
21
|
+
localeCookieName,
|
|
22
|
+
customMapping,
|
|
23
|
+
enableI18n
|
|
24
|
+
}), customMapping);
|
|
25
|
+
};
|
|
26
|
+
const [locale, _setLocale] = (0, react.useState)(initializeLocale());
|
|
27
|
+
const [setLocale, setLocaleWithoutPersist] = createSetLocale({
|
|
28
|
+
locale,
|
|
29
|
+
locales,
|
|
30
|
+
defaultLocale,
|
|
31
|
+
localeCookieName,
|
|
32
|
+
_setLocale,
|
|
33
|
+
customMapping,
|
|
34
|
+
enableI18n
|
|
35
|
+
});
|
|
36
|
+
(0, react.useEffect)(() => {
|
|
37
|
+
setLocaleWithoutPersist(getNewLocale({
|
|
38
|
+
_locale,
|
|
39
|
+
locale,
|
|
40
|
+
locales,
|
|
41
|
+
defaultLocale,
|
|
42
|
+
localeCookieName,
|
|
43
|
+
customMapping,
|
|
44
|
+
enableI18n
|
|
45
|
+
}));
|
|
46
|
+
}, [
|
|
47
|
+
_locale,
|
|
48
|
+
locale,
|
|
49
|
+
locales,
|
|
50
|
+
defaultLocale,
|
|
51
|
+
localeCookieName,
|
|
52
|
+
customMapping,
|
|
53
|
+
enableI18n
|
|
54
|
+
]);
|
|
55
|
+
return [locale, setLocale];
|
|
71
56
|
}
|
|
72
|
-
|
|
73
|
-
// ----- HELPER FUNCTIONS ---- //
|
|
74
|
-
|
|
75
57
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function getNewLocale({
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Check for locale in native store
|
|
101
|
-
let storedLocale = (0, _nativeStore.nativeStoreGet)(localeCookieName);
|
|
102
|
-
if (storedLocale) {
|
|
103
|
-
storedLocale = (0, _generaltranslation.resolveAliasLocale)(storedLocale, customMapping);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// check user's configured locales
|
|
107
|
-
let preferredLocales = (0, _getNativeLocales.getNativeLocales)();
|
|
108
|
-
if (preferredLocales.length === 0) preferredLocales = [defaultLocale];
|
|
109
|
-
preferredLocales = preferredLocales.map(l => (0, _generaltranslation.resolveAliasLocale)(l, customMapping));
|
|
110
|
-
|
|
111
|
-
// determine locale
|
|
112
|
-
let newLocale = (0, _generaltranslation.determineLocale)([...(_locale ? [_locale] : []),
|
|
113
|
-
// prefer user passed locale
|
|
114
|
-
...(storedLocale ? [storedLocale] : []),
|
|
115
|
-
// then prefer stored locale
|
|
116
|
-
...preferredLocales // then prefer browser locale
|
|
117
|
-
], locales, customMapping) || defaultLocale;
|
|
118
|
-
if (newLocale) {
|
|
119
|
-
newLocale = (0, _generaltranslation.resolveAliasLocale)(newLocale, customMapping);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// if stored locale not valid, change it back to whatever we use for fallback
|
|
123
|
-
if (storedLocale && storedLocale !== newLocale) {
|
|
124
|
-
(0, _nativeStore.nativeStoreSet)(localeCookieName, newLocale);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// return new locale
|
|
128
|
-
return newLocale;
|
|
58
|
+
* Choose a locale to use
|
|
59
|
+
* (1) use provided locale
|
|
60
|
+
* (2) use cookie locale
|
|
61
|
+
* (3) use preferred locale
|
|
62
|
+
* (5) fallback to defaultLocale
|
|
63
|
+
* Update the cookie locale to be correct
|
|
64
|
+
*/
|
|
65
|
+
function getNewLocale({ _locale, locale, locales, defaultLocale, localeCookieName, customMapping, enableI18n }) {
|
|
66
|
+
if (!enableI18n) return defaultLocale;
|
|
67
|
+
if (_locale && _locale === locale && (0, _generaltranslation_format.determineLocale)(_locale, locales, customMapping) === locale) return (0, _generaltranslation_format.resolveAliasLocale)(_locale, customMapping);
|
|
68
|
+
let storedLocale = require_utils_nativeStore.nativeStoreGet(localeCookieName);
|
|
69
|
+
if (storedLocale) storedLocale = (0, _generaltranslation_format.resolveAliasLocale)(storedLocale, customMapping);
|
|
70
|
+
let preferredLocales = require_utils_getNativeLocales.getNativeLocales();
|
|
71
|
+
if (preferredLocales.length === 0) preferredLocales = [defaultLocale];
|
|
72
|
+
preferredLocales = preferredLocales.map((l) => (0, _generaltranslation_format.resolveAliasLocale)(l, customMapping));
|
|
73
|
+
let newLocale = (0, _generaltranslation_format.determineLocale)([
|
|
74
|
+
..._locale ? [_locale] : [],
|
|
75
|
+
...storedLocale ? [storedLocale] : [],
|
|
76
|
+
...preferredLocales
|
|
77
|
+
], locales, customMapping) || defaultLocale;
|
|
78
|
+
if (newLocale) newLocale = (0, _generaltranslation_format.resolveAliasLocale)(newLocale, customMapping);
|
|
79
|
+
if (storedLocale && storedLocale !== newLocale) require_utils_nativeStore.nativeStoreSet(localeCookieName, newLocale);
|
|
80
|
+
return newLocale;
|
|
129
81
|
}
|
|
130
|
-
function createSetLocale({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// validate locale
|
|
146
|
-
const validatedLocale = (0, _generaltranslation.resolveAliasLocale)((0, _generaltranslation.determineLocale)(newLocale, locales, customMapping) || locale || defaultLocale, customMapping);
|
|
147
|
-
if (validatedLocale !== newLocale) {
|
|
148
|
-
console.warn((0, _errors.createUnsupportedLocaleWarning)(validatedLocale, newLocale, _constants.PACKAGE_NAME));
|
|
149
|
-
}
|
|
150
|
-
// persist locale
|
|
151
|
-
_setLocale(validatedLocale);
|
|
152
|
-
return validatedLocale;
|
|
153
|
-
};
|
|
154
|
-
// update locale and persist it in native store
|
|
155
|
-
const setLocale = newLocale => {
|
|
156
|
-
if (!enableI18n) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
newLocale = (0, _generaltranslation.resolveAliasLocale)(newLocale, customMapping);
|
|
160
|
-
const validatedLocale = setLocaleWithoutPersist(newLocale);
|
|
161
|
-
(0, _nativeStore.nativeStoreSet)(localeCookieName, validatedLocale);
|
|
162
|
-
};
|
|
163
|
-
return [setLocale, setLocaleWithoutPersist];
|
|
82
|
+
function createSetLocale({ locale, locales, defaultLocale, _setLocale, localeCookieName, customMapping, enableI18n }) {
|
|
83
|
+
locale = (0, _generaltranslation_format.resolveAliasLocale)(locale, customMapping);
|
|
84
|
+
const setLocaleWithoutPersist = (newLocale) => {
|
|
85
|
+
if (!enableI18n) return defaultLocale;
|
|
86
|
+
const validatedLocale = (0, _generaltranslation_format.resolveAliasLocale)((0, _generaltranslation_format.determineLocale)(newLocale, locales, customMapping) || locale || defaultLocale, customMapping);
|
|
87
|
+
if (validatedLocale !== newLocale) console.warn((0, _generaltranslation_react_core_errors.createUnsupportedLocaleWarning)(validatedLocale, newLocale, require_errors_dir_constants.PACKAGE_NAME));
|
|
88
|
+
_setLocale(validatedLocale);
|
|
89
|
+
return validatedLocale;
|
|
90
|
+
};
|
|
91
|
+
const setLocale = (newLocale) => {
|
|
92
|
+
if (!enableI18n) return;
|
|
93
|
+
newLocale = (0, _generaltranslation_format.resolveAliasLocale)(newLocale, customMapping);
|
|
94
|
+
require_utils_nativeStore.nativeStoreSet(localeCookieName, setLocaleWithoutPersist(newLocale));
|
|
95
|
+
};
|
|
96
|
+
return [setLocale, setLocaleWithoutPersist];
|
|
164
97
|
}
|
|
98
|
+
//#endregion
|
|
99
|
+
exports.useDetermineLocale = useDetermineLocale;
|
|
100
|
+
|
|
165
101
|
//# sourceMappingURL=useDetermineLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDetermineLocale.js","names":["libraryDefaultLocale","nativeStoreGet","getNativeLocales","PACKAGE_NAME"],"sources":["../../../../../src/provider/hooks/locale/useDetermineLocale.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { Dispatch, SetStateAction } from 'react';\nimport {\n determineLocale,\n resolveAliasLocale,\n} from '@generaltranslation/format';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport type {\n UseDetermineLocaleParams,\n UseDetermineLocaleReturn,\n} from '@generaltranslation/react-core/types';\nimport { createUnsupportedLocaleWarning } from '@generaltranslation/react-core/errors';\nimport { PACKAGE_NAME } from '../../../errors-dir/constants';\nimport { getNativeLocales } from '../../../utils/getNativeLocales';\nimport { nativeStoreGet, nativeStoreSet } from '../../../utils/nativeStore';\n\nexport function useDetermineLocale({\n locale: _locale = '',\n defaultLocale = libraryDefaultLocale,\n locales = [],\n localeCookieName = 'generaltranslation.locale',\n ssr = false, // not relevant\n customMapping,\n enableI18n,\n}: UseDetermineLocaleParams): UseDetermineLocaleReturn {\n // resolve alias locale\n _locale = resolveAliasLocale(_locale, customMapping);\n locales = locales.map((locale) => resolveAliasLocale(locale, customMapping));\n\n const initializeLocale = () => {\n if (!enableI18n) {\n return defaultLocale;\n }\n const result = resolveAliasLocale(\n ssr\n ? _locale\n ? determineLocale(_locale, locales, customMapping) || ''\n : ''\n : getNewLocale({\n _locale,\n locale: _locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n }),\n customMapping\n );\n return result;\n };\n\n // maintaining the state of locale\n const [locale, _setLocale] = useState<string>(initializeLocale());\n\n // Functions for setting internal locale state\n const [setLocale, setLocaleWithoutPersist] = createSetLocale({\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n _setLocale,\n customMapping,\n enableI18n,\n });\n\n // check browser for locales\n useEffect(() => {\n const newLocale = getNewLocale({\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n });\n setLocaleWithoutPersist(newLocale);\n }, [\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n ]);\n\n return [locale, setLocale];\n}\n\n// ----- HELPER FUNCTIONS ---- //\n\n/**\n * Choose a locale to use\n * (1) use provided locale\n * (2) use cookie locale\n * (3) use preferred locale\n * (5) fallback to defaultLocale\n * Update the cookie locale to be correct\n */\nfunction getNewLocale({\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n}: {\n _locale: string;\n locale: string;\n locales: string[];\n defaultLocale: string;\n localeCookieName: string;\n customMapping?: CustomMapping;\n enableI18n: boolean;\n}): string {\n if (!enableI18n) {\n return defaultLocale;\n }\n // No change, return\n if (\n _locale &&\n _locale === locale &&\n determineLocale(_locale, locales, customMapping) === locale\n ) {\n return resolveAliasLocale(_locale, customMapping);\n }\n\n // Check for locale in native store\n let storedLocale = nativeStoreGet(localeCookieName);\n if (storedLocale) {\n storedLocale = resolveAliasLocale(storedLocale, customMapping);\n }\n\n // check user's configured locales\n let preferredLocales = getNativeLocales();\n if (preferredLocales.length === 0) preferredLocales = [defaultLocale];\n preferredLocales = preferredLocales.map((l) =>\n resolveAliasLocale(l, customMapping)\n );\n\n // determine locale\n let newLocale =\n determineLocale(\n [\n ...(_locale ? [_locale] : []), // prefer user passed locale\n ...(storedLocale ? [storedLocale] : []), // then prefer stored locale\n ...preferredLocales, // then prefer browser locale\n ],\n locales,\n customMapping\n ) || defaultLocale;\n if (newLocale) {\n newLocale = resolveAliasLocale(newLocale, customMapping);\n }\n\n // if stored locale not valid, change it back to whatever we use for fallback\n if (storedLocale && storedLocale !== newLocale) {\n nativeStoreSet(localeCookieName, newLocale);\n }\n\n // return new locale\n return newLocale;\n}\n\nfunction createSetLocale({\n locale,\n locales,\n defaultLocale,\n _setLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n}: {\n locale: string;\n locales: string[];\n defaultLocale: string;\n localeCookieName: string;\n _setLocale: Dispatch<SetStateAction<string>>;\n customMapping?: CustomMapping;\n enableI18n: boolean;\n}): [(newLocale: string) => void, (newLocale: string) => void] {\n locale = resolveAliasLocale(locale, customMapping);\n // Just update the internal state, don't persist it\n const setLocaleWithoutPersist = (newLocale: string): string => {\n if (!enableI18n) {\n return defaultLocale;\n }\n // validate locale\n const validatedLocale = resolveAliasLocale(\n determineLocale(newLocale, locales, customMapping) ||\n locale ||\n defaultLocale,\n customMapping\n );\n if (validatedLocale !== newLocale) {\n console.warn(\n createUnsupportedLocaleWarning(validatedLocale, newLocale, PACKAGE_NAME)\n );\n }\n // persist locale\n _setLocale(validatedLocale);\n\n return validatedLocale;\n };\n // update locale and persist it in native store\n const setLocale = (newLocale: string): void => {\n if (!enableI18n) {\n return;\n }\n newLocale = resolveAliasLocale(newLocale, customMapping);\n const validatedLocale = setLocaleWithoutPersist(newLocale);\n nativeStoreSet(localeCookieName, validatedLocale);\n };\n return [setLocale, setLocaleWithoutPersist];\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,mBAAmB,EACjC,QAAQ,UAAU,IAClB,gBAAgBA,4BAAAA,sBAChB,UAAU,EAAE,EACZ,mBAAmB,6BACnB,MAAM,OACN,eACA,cACqD;AAErD,YAAA,GAAA,2BAAA,oBAA6B,SAAS,cAAc;AACpD,WAAU,QAAQ,KAAK,YAAA,GAAA,2BAAA,oBAA8B,QAAQ,cAAc,CAAC;CAE5E,MAAM,yBAAyB;AAC7B,MAAI,CAAC,WACH,QAAO;AAkBT,UAAA,GAAA,2BAAA,oBAfE,MACI,WAAA,GAAA,2BAAA,iBACkB,SAAS,SAAS,cAAc,IAAI,KACpD,KACF,aAAa;GACX;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;GACD,CAAC,EACN,cAEW;;CAIf,MAAM,CAAC,QAAQ,eAAA,GAAA,MAAA,UAA+B,kBAAkB,CAAC;CAGjE,MAAM,CAAC,WAAW,2BAA2B,gBAAgB;EAC3D;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGF,EAAA,GAAA,MAAA,iBAAgB;AAUd,0BATkB,aAAa;GAC7B;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACgC,CAAC;IACjC;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO,CAAC,QAAQ,UAAU;;;;;;;;;;AAa5B,SAAS,aAAa,EACpB,SACA,QACA,SACA,eACA,kBACA,eACA,cASS;AACT,KAAI,CAAC,WACH,QAAO;AAGT,KACE,WACA,YAAY,WAAA,GAAA,2BAAA,iBACI,SAAS,SAAS,cAAc,KAAK,OAErD,SAAA,GAAA,2BAAA,oBAA0B,SAAS,cAAc;CAInD,IAAI,eAAeC,0BAAAA,eAAe,iBAAiB;AACnD,KAAI,aACF,iBAAA,GAAA,2BAAA,oBAAkC,cAAc,cAAc;CAIhE,IAAI,mBAAmBC,+BAAAA,kBAAkB;AACzC,KAAI,iBAAiB,WAAW,EAAG,oBAAmB,CAAC,cAAc;AACrE,oBAAmB,iBAAiB,KAAK,OAAA,GAAA,2BAAA,oBACpB,GAAG,cAAc,CACrC;CAGD,IAAI,aAAA,GAAA,2BAAA,iBAEA;EACE,GAAI,UAAU,CAAC,QAAQ,GAAG,EAAE;EAC5B,GAAI,eAAe,CAAC,aAAa,GAAG,EAAE;EACtC,GAAG;EACJ,EACD,SACA,cACD,IAAI;AACP,KAAI,UACF,cAAA,GAAA,2BAAA,oBAA+B,WAAW,cAAc;AAI1D,KAAI,gBAAgB,iBAAiB,UACnC,2BAAA,eAAe,kBAAkB,UAAU;AAI7C,QAAO;;AAGT,SAAS,gBAAgB,EACvB,QACA,SACA,eACA,YACA,kBACA,eACA,cAS6D;AAC7D,WAAA,GAAA,2BAAA,oBAA4B,QAAQ,cAAc;CAElD,MAAM,2BAA2B,cAA8B;AAC7D,MAAI,CAAC,WACH,QAAO;EAGT,MAAM,mBAAA,GAAA,2BAAA,qBAAA,GAAA,2BAAA,iBACY,WAAW,SAAS,cAAc,IAChD,UACA,eACF,cACD;AACD,MAAI,oBAAoB,UACtB,SAAQ,MAAA,GAAA,sCAAA,gCACyB,iBAAiB,WAAWC,6BAAAA,aAAa,CACzE;AAGH,aAAW,gBAAgB;AAE3B,SAAO;;CAGT,MAAM,aAAa,cAA4B;AAC7C,MAAI,CAAC,WACH;AAEF,eAAA,GAAA,2BAAA,oBAA+B,WAAW,cAAc;AAExD,4BAAA,eAAe,kBADS,wBAAwB,UACA,CAAC;;AAEnD,QAAO,CAAC,WAAW,wBAAwB"}
|