gt-i18n 1.0.6 → 1.0.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # gt-i18n
2
2
 
3
+ ## 1.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`bbf4eb0`](https://github.com/generaltranslation/gt/commit/bbf4eb0cf77160baa615776619acd7afe35697ba), [`f53bb5e`](https://github.com/generaltranslation/gt/commit/f53bb5ea4b4989a2a4ad3aebf464011f01e029ad)]:
8
+ - generaltranslation@9.0.4
9
+ - @generaltranslation/format@0.1.3
10
+
11
+ ## 1.0.7
12
+
13
+ ### Patch Changes
14
+
15
+ - [#1916](https://github.com/generaltranslation/gt/pull/1916) [`c658e7e`](https://github.com/generaltranslation/gt/commit/c658e7e1f6929965e3752a6828e3658dd8c527a8) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Unify `gt.config.json` types so complete config objects can be spread into compiler plugins and runtime initializers while file settings remain optional.
16
+
17
+ - Updated dependencies [[`c658e7e`](https://github.com/generaltranslation/gt/commit/c658e7e1f6929965e3752a6828e3658dd8c527a8)]:
18
+ - generaltranslation@9.0.3
19
+
3
20
  ## 1.0.6
4
21
 
5
22
  ### Patch Changes
@@ -3,58 +3,8 @@ import { RuntimeTranslateManyOptions } from "generaltranslation/internal";
3
3
  import { LocaleConfig } from "@generaltranslation/format";
4
4
  import { GTRuntime } from "generaltranslation/runtime";
5
5
  import { CustomMapping } from "@generaltranslation/format/types";
6
- //#region src/config/types.d.ts
7
- /**
8
- * TODO: this disagrees with the type in react-core/src/types-dir/config.ts, we need to move this
9
- * General Config:
10
- * @param defaultLocale - The default locale to use
11
- * @param locales - The locales to support
12
- * @param customMapping - The custom mapping to use (for aliasing locale codes and other properties)
13
- * @param enableI18n - Whether to enable i18n
14
- *
15
- * Remote Store/Cache Config:
16
- * @param projectId - The project id
17
- * @param devApiKey - The dev api key
18
- * @param _versionId - The version id
19
- * @param _branchId - The branch id
20
- * @param cacheUrl - The cache url
21
- * @param runtimeUrl - The runtime url
22
- * @param timeout - The timeout
23
- * @param modelProvider - The model provider
24
- */
25
- type GTConfig = {
26
- defaultLocale?: string;
27
- locales?: string[];
28
- customMapping?: CustomMapping;
29
- enableI18n?: boolean;
30
- projectId?: string;
31
- devApiKey?: string;
32
- apiKey?: string;
33
- _versionId?: string;
34
- _branchId?: string;
35
- cacheUrl?: string | null;
36
- cacheExpiryTime?: number;
37
- runtimeUrl?: string | null;
38
- modelProvider?: string;
39
- _disableDevHotReload?: boolean;
40
- files?: {
41
- gt?: {
42
- output?: string;
43
- parsingFlags?: {
44
- /**
45
- * Dev hot reload config, gt-react browser runtime only.
46
- * - `true` enables strings hot reload (jsx handled at runtime via Suspense)
47
- * - `{ strings?: boolean; jsx?: boolean }` enables selectively
48
- */
49
- devHotReload?: boolean | {
50
- strings?: boolean;
51
- jsx?: boolean;
52
- };
53
- };
54
- };
55
- };
56
- };
57
- //#endregion
6
+ import { GTConfig } from "generaltranslation/types";
7
+
58
8
  //#region src/i18n-cache/translations-manager/TranslationsCache.d.ts
59
9
  type TranslationBatchConfig = {
60
10
  maxConcurrentRequests?: number;
@@ -236,4 +186,4 @@ declare class WritableConditionStore extends ReadonlyConditionStore implements W
236
186
  }
237
187
  //#endregion
238
188
  export { Hash as _, I18nConfig as a, AsyncReadonlyConditionStoreInterface as c, I18nCacheConstructorParams as d, LocaleResolverConfig as f, TranslationsLoader as g, WritableConditionStoreInterface as h, ReadonlyConditionStoreParams as i, DictionaryConfig as l, ScopedConditionStoreInterface as m, WritableConditionStoreParams as n, I18nConfigParams as o, ReadonlyConditionStoreInterface as p, ReadonlyConditionStore as r, LocaleCandidates as s, WritableConditionStore as t, I18nCacheConfig as u, Locale as v, GTConfig as y };
239
- //# sourceMappingURL=WritableConditionStore-BUblH4YU.d.mts.map
189
+ //# sourceMappingURL=WritableConditionStore-8482OsuJ.d.mts.map
@@ -1,61 +1,10 @@
1
1
  import { n as Dictionary, t as DictionaryLoader } from "./DictionaryCache-DjAdDNiM.cjs";
2
2
  import { CustomMapping } from "@generaltranslation/format/types";
3
3
  import { RuntimeTranslateManyOptions } from "generaltranslation/internal";
4
+ import { GTConfig } from "generaltranslation/types";
4
5
  import { LocaleConfig } from "@generaltranslation/format";
5
6
  import { GTRuntime } from "generaltranslation/runtime";
6
7
 
7
- //#region src/config/types.d.ts
8
- /**
9
- * TODO: this disagrees with the type in react-core/src/types-dir/config.ts, we need to move this
10
- * General Config:
11
- * @param defaultLocale - The default locale to use
12
- * @param locales - The locales to support
13
- * @param customMapping - The custom mapping to use (for aliasing locale codes and other properties)
14
- * @param enableI18n - Whether to enable i18n
15
- *
16
- * Remote Store/Cache Config:
17
- * @param projectId - The project id
18
- * @param devApiKey - The dev api key
19
- * @param _versionId - The version id
20
- * @param _branchId - The branch id
21
- * @param cacheUrl - The cache url
22
- * @param runtimeUrl - The runtime url
23
- * @param timeout - The timeout
24
- * @param modelProvider - The model provider
25
- */
26
- type GTConfig = {
27
- defaultLocale?: string;
28
- locales?: string[];
29
- customMapping?: CustomMapping;
30
- enableI18n?: boolean;
31
- projectId?: string;
32
- devApiKey?: string;
33
- apiKey?: string;
34
- _versionId?: string;
35
- _branchId?: string;
36
- cacheUrl?: string | null;
37
- cacheExpiryTime?: number;
38
- runtimeUrl?: string | null;
39
- modelProvider?: string;
40
- _disableDevHotReload?: boolean;
41
- files?: {
42
- gt?: {
43
- output?: string;
44
- parsingFlags?: {
45
- /**
46
- * Dev hot reload config, gt-react browser runtime only.
47
- * - `true` enables strings hot reload (jsx handled at runtime via Suspense)
48
- * - `{ strings?: boolean; jsx?: boolean }` enables selectively
49
- */
50
- devHotReload?: boolean | {
51
- strings?: boolean;
52
- jsx?: boolean;
53
- };
54
- };
55
- };
56
- };
57
- };
58
- //#endregion
59
8
  //#region src/i18n-cache/translations-manager/TranslationsCache.d.ts
60
9
  type TranslationBatchConfig = {
61
10
  maxConcurrentRequests?: number;
@@ -237,4 +186,4 @@ declare class WritableConditionStore extends ReadonlyConditionStore implements W
237
186
  }
238
187
  //#endregion
239
188
  export { Hash as _, I18nConfig as a, AsyncReadonlyConditionStoreInterface as c, I18nCacheConstructorParams as d, LocaleResolverConfig as f, TranslationsLoader as g, WritableConditionStoreInterface as h, ReadonlyConditionStoreParams as i, DictionaryConfig as l, ScopedConditionStoreInterface as m, WritableConditionStoreParams as n, I18nConfigParams as o, ReadonlyConditionStoreInterface as p, ReadonlyConditionStore as r, LocaleCandidates as s, WritableConditionStore as t, I18nCacheConfig as u, Locale as v, GTConfig as y };
240
- //# sourceMappingURL=WritableConditionStore-ekDSlgJ7.d.cts.map
189
+ //# sourceMappingURL=WritableConditionStore-DG-jgrei.d.cts.map
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_versionId = require("./versionId-CT-IBMV6.cjs");
2
+ const require_versionId = require("./versionId-D617MMZw.cjs");
3
3
  let generaltranslation_internal = require("generaltranslation/internal");
4
4
  let _generaltranslation_format = require("@generaltranslation/format");
5
5
  let generaltranslation = require("generaltranslation");
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { D as logger_default, S as extractVariables, _ as resolveStringContentWithFallback, a as getDefaultLocale, b as interpolateIcuMessage, c as getLocales, d as getWritableConditionStore, g as resolveStringContent, i as hashMessage, l as getRegion, n as isEncodedTranslationOptions, o as getLocale, r as decodeOptions, s as getLocaleProperties, t as getVersionId, u as resolveCanonicalLocale, x as createInterpolationFailureMessage } from "./versionId-JokehdDv.mjs";
1
+ import { D as logger_default, S as extractVariables, _ as resolveStringContentWithFallback, a as getDefaultLocale, b as interpolateIcuMessage, c as getLocales, d as getWritableConditionStore, g as resolveStringContent, i as hashMessage, l as getRegion, n as isEncodedTranslationOptions, o as getLocale, r as decodeOptions, s as getLocaleProperties, t as getVersionId, u as resolveCanonicalLocale, x as createInterpolationFailureMessage } from "./versionId-DEb3k2mY.mjs";
2
2
  import { VAR_IDENTIFIER, encode, libraryDefaultLocale } from "generaltranslation/internal";
3
3
  import { formatMessage } from "@generaltranslation/format";
4
4
  import { declareVar, decodeVars, derive } from "generaltranslation";
@@ -1,4 +1,4 @@
1
1
  import { a as JsxTranslationOptions, c as NormalizedLookupOptions, d as TranslationOptions, f as TranslationVariables, i as GTTranslationOptions, l as RuntimeTranslationOptions, n as DictionaryLookupOptions, o as LookupOptions, r as EncodedTranslationOptions, s as LookupOptionsFor, t as DictionaryEntryOptions, u as TranslationMetadata } from "./options-BXeFwN0R.cjs";
2
- import { _ as Hash, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, f as LocaleResolverConfig, g as TranslationsLoader, h as WritableConditionStoreInterface, i as ReadonlyConditionStoreParams, l as DictionaryConfig, m as ScopedConditionStoreInterface, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, s as LocaleCandidates, u as I18nCacheConfig, v as Locale, y as GTConfig } from "./WritableConditionStore-ekDSlgJ7.cjs";
2
+ import { _ as Hash, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, f as LocaleResolverConfig, g as TranslationsLoader, h as WritableConditionStoreInterface, i as ReadonlyConditionStoreParams, l as DictionaryConfig, m as ScopedConditionStoreInterface, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, s as LocaleCandidates, u as I18nCacheConfig, v as Locale, y as GTConfig } from "./WritableConditionStore-DG-jgrei.cjs";
3
3
  import { a as DictionaryLeaf, c as DictionaryValue, i as DictionaryKey, n as Dictionary, o as DictionaryObject, r as DictionaryEntry, s as DictionaryPath, t as DictionaryLoader } from "./DictionaryCache-DjAdDNiM.cjs";
4
4
  export { type AsyncReadonlyConditionStoreInterface, type Dictionary, type DictionaryConfig, type DictionaryEntry, DictionaryEntryOptions, type DictionaryKey, type DictionaryLeaf, type DictionaryLoader, DictionaryLookupOptions, type DictionaryObject, type DictionaryPath, type DictionaryValue, EncodedTranslationOptions, type GTConfig, GTTranslationOptions, type Hash, type I18nCacheConfig, type I18nCacheConstructorParams, type I18nConfigParams, JsxTranslationOptions, type Locale, type LocaleCandidates, type LocaleResolverConfig, LookupOptions, LookupOptionsFor, NormalizedLookupOptions, type ReadonlyConditionStoreInterface, type ReadonlyConditionStoreParams, RuntimeTranslationOptions, type ScopedConditionStoreInterface, TranslationMetadata, TranslationOptions, TranslationVariables, type TranslationsLoader, type WritableConditionStoreInterface, type WritableConditionStoreParams };
@@ -1,4 +1,4 @@
1
1
  import { a as JsxTranslationOptions, c as NormalizedLookupOptions, d as TranslationOptions, f as TranslationVariables, i as GTTranslationOptions, l as RuntimeTranslationOptions, n as DictionaryLookupOptions, o as LookupOptions, r as EncodedTranslationOptions, s as LookupOptionsFor, t as DictionaryEntryOptions, u as TranslationMetadata } from "./options-DDUyXaLT.mjs";
2
- import { _ as Hash, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, f as LocaleResolverConfig, g as TranslationsLoader, h as WritableConditionStoreInterface, i as ReadonlyConditionStoreParams, l as DictionaryConfig, m as ScopedConditionStoreInterface, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, s as LocaleCandidates, u as I18nCacheConfig, v as Locale, y as GTConfig } from "./WritableConditionStore-BUblH4YU.mjs";
2
+ import { _ as Hash, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, f as LocaleResolverConfig, g as TranslationsLoader, h as WritableConditionStoreInterface, i as ReadonlyConditionStoreParams, l as DictionaryConfig, m as ScopedConditionStoreInterface, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, s as LocaleCandidates, u as I18nCacheConfig, v as Locale, y as GTConfig } from "./WritableConditionStore-8482OsuJ.mjs";
3
3
  import { a as DictionaryLeaf, c as DictionaryValue, i as DictionaryKey, n as Dictionary, o as DictionaryObject, r as DictionaryEntry, s as DictionaryPath, t as DictionaryLoader } from "./DictionaryCache-B7oTBs5W.mjs";
4
4
  export { type AsyncReadonlyConditionStoreInterface, type Dictionary, type DictionaryConfig, type DictionaryEntry, DictionaryEntryOptions, type DictionaryKey, type DictionaryLeaf, type DictionaryLoader, DictionaryLookupOptions, type DictionaryObject, type DictionaryPath, type DictionaryValue, EncodedTranslationOptions, type GTConfig, GTTranslationOptions, type Hash, type I18nCacheConfig, type I18nCacheConstructorParams, type I18nConfigParams, JsxTranslationOptions, type Locale, type LocaleCandidates, type LocaleResolverConfig, LookupOptions, LookupOptionsFor, NormalizedLookupOptions, type ReadonlyConditionStoreInterface, type ReadonlyConditionStoreParams, RuntimeTranslationOptions, type ScopedConditionStoreInterface, TranslationMetadata, TranslationOptions, TranslationVariables, type TranslationsLoader, type WritableConditionStoreInterface, type WritableConditionStoreParams };
package/dist/internal.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_versionId = require("./versionId-CT-IBMV6.cjs");
2
+ const require_versionId = require("./versionId-D617MMZw.cjs");
3
3
  let generaltranslation_internal = require("generaltranslation/internal");
4
4
  let _generaltranslation_format = require("@generaltranslation/format");
5
5
  //#region src/translation-functions/internal/getGT.ts
@@ -1,7 +1,7 @@
1
1
  import { a as JsxTranslationOptions, c as NormalizedLookupOptions, f as TranslationVariables, l as RuntimeTranslationOptions, n as DictionaryLookupOptions, o as LookupOptions, r as EncodedTranslationOptions, s as LookupOptionsFor } from "./options-BXeFwN0R.cjs";
2
2
  import { o as TFunctionType, r as MFunctionType, t as DictionaryObjectTranslation } from "./functions-BiA2tWER.cjs";
3
3
  import { t as getVersionId } from "./versionId-0COhh5UX.cjs";
4
- import { _ as Hash, a as I18nConfig, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, i as ReadonlyConditionStoreParams, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, r as ReadonlyConditionStore, s as LocaleCandidates, t as WritableConditionStore, u as I18nCacheConfig, v as Locale } from "./WritableConditionStore-ekDSlgJ7.cjs";
4
+ import { _ as Hash, a as I18nConfig, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, i as ReadonlyConditionStoreParams, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, r as ReadonlyConditionStore, s as LocaleCandidates, t as WritableConditionStore, u as I18nCacheConfig, v as Locale } from "./WritableConditionStore-DG-jgrei.cjs";
5
5
  import { c as DictionaryValue, l as Translation, n as Dictionary, o as DictionaryObject, r as DictionaryEntry } from "./DictionaryCache-DjAdDNiM.cjs";
6
6
  import { n as getGT, r as getGTInternal } from "./types-wiJpMiR8.cjs";
7
7
  import { DataFormat, JsxChildren, StringFormat } from "@generaltranslation/format/types";
@@ -1,7 +1,7 @@
1
1
  import { a as JsxTranslationOptions, c as NormalizedLookupOptions, f as TranslationVariables, l as RuntimeTranslationOptions, n as DictionaryLookupOptions, o as LookupOptions, r as EncodedTranslationOptions, s as LookupOptionsFor } from "./options-DDUyXaLT.mjs";
2
2
  import { o as TFunctionType, r as MFunctionType, t as DictionaryObjectTranslation } from "./functions-BZ_xopQU.mjs";
3
3
  import { t as getVersionId } from "./versionId-Zel3fqtC.mjs";
4
- import { _ as Hash, a as I18nConfig, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, i as ReadonlyConditionStoreParams, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, r as ReadonlyConditionStore, s as LocaleCandidates, t as WritableConditionStore, u as I18nCacheConfig, v as Locale } from "./WritableConditionStore-BUblH4YU.mjs";
4
+ import { _ as Hash, a as I18nConfig, c as AsyncReadonlyConditionStoreInterface, d as I18nCacheConstructorParams, i as ReadonlyConditionStoreParams, n as WritableConditionStoreParams, o as I18nConfigParams, p as ReadonlyConditionStoreInterface, r as ReadonlyConditionStore, s as LocaleCandidates, t as WritableConditionStore, u as I18nCacheConfig, v as Locale } from "./WritableConditionStore-8482OsuJ.mjs";
5
5
  import { c as DictionaryValue, l as Translation, n as Dictionary, o as DictionaryObject, r as DictionaryEntry } from "./DictionaryCache-B7oTBs5W.mjs";
6
6
  import { n as getGT, r as getGTInternal } from "./types-CRivFf_D.mjs";
7
7
  import { DataFormat, JsxChildren, StringFormat } from "@generaltranslation/format/types";
package/dist/internal.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as getI18nCache, C as getI18nConfig, D as logger_default, E as I18nConfig, M as createGlobalSingleton, O as getRuntimeEnvironment, S as extractVariables, T as setI18nConfig, d as getWritableConditionStore, f as createConditionStoreSingleton, h as resolveJsxWithRuntimeFallback, i as hashMessage, j as setI18nCache, k as getLoadTranslationsType, m as prefetchStringContentWithRuntimeFallback, n as isEncodedTranslationOptions, o as getLocale, p as createLookupOptions, r as decodeOptions, t as getVersionId, v as resolveStringContentWithRuntimeFallback, w as initializeI18nConfig, y as interpolateMessage } from "./versionId-JokehdDv.mjs";
1
+ import { A as getI18nCache, C as getI18nConfig, D as logger_default, E as I18nConfig, M as createGlobalSingleton, O as getRuntimeEnvironment, S as extractVariables, T as setI18nConfig, d as getWritableConditionStore, f as createConditionStoreSingleton, h as resolveJsxWithRuntimeFallback, i as hashMessage, j as setI18nCache, k as getLoadTranslationsType, m as prefetchStringContentWithRuntimeFallback, n as isEncodedTranslationOptions, o as getLocale, p as createLookupOptions, r as decodeOptions, t as getVersionId, v as resolveStringContentWithRuntimeFallback, w as initializeI18nConfig, y as interpolateMessage } from "./versionId-DEb3k2mY.mjs";
2
2
  import { createDiagnosticMessage, defaultCacheUrl, defaultRuntimeApiUrl } from "generaltranslation/internal";
3
3
  import { resolveCanonicalLocale } from "@generaltranslation/format";
4
4
  //#region src/translation-functions/internal/getGT.ts
@@ -301,7 +301,7 @@ var I18nConfig = class extends _generaltranslation_format.LocaleConfig {
301
301
  }
302
302
  };
303
303
  function getLocaleConfigParams(params, gtServicesEnabled) {
304
- const { defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales = [defaultLocale], customMapping } = params;
304
+ const { defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales = [], customMapping } = params;
305
305
  validateI18nConfigParams({
306
306
  ...params,
307
307
  defaultLocale,
@@ -314,7 +314,7 @@ function getLocaleConfigParams(params, gtServicesEnabled) {
314
314
  customMapping: customMapping || {}
315
315
  };
316
316
  }
317
- function getLocaleResolverConfigParams({ defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales, customMapping } = {}) {
317
+ function getLocaleResolverConfigParams({ defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales = [], customMapping } = {}) {
318
318
  return {
319
319
  defaultLocale,
320
320
  locales: locales?.length ? locales : [defaultLocale],
@@ -874,4 +874,4 @@ Object.defineProperty(exports, "setI18nConfig", {
874
874
  }
875
875
  });
876
876
 
877
- //# sourceMappingURL=versionId-CT-IBMV6.cjs.map
877
+ //# sourceMappingURL=versionId-D617MMZw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionId-D617MMZw.cjs","names":["readImportMetaEnv","globalObj","defaultCacheUrl","defaultRuntimeApiUrl","LocaleConfig","GTRuntime","libraryDefaultLocale","VAR_IDENTIFIER"],"sources":["../src/logs/logLevel.ts","../src/globals/createGlobalSingleton.ts","../src/i18n-cache/singleton-operations.ts","../src/i18n-cache/utils/getLoadTranslationsType.ts","../src/i18n-cache/utils/getTranslationApiType.ts","../src/utils/getRuntimeEnvironment.ts","../src/logs/logger.ts","../src/i18n-config/validation.ts","../src/i18n-config/I18nConfig.ts","../src/i18n-config/singleton-operations.ts","../src/utils/extractVariables.ts","../src/translation-functions/utils/messages.ts","../src/translation-functions/utils/formatMessage.ts","../src/translation-functions/utils/interpolation/interpolateIcuMessage.ts","../src/translation-functions/utils/interpolation/interpolateStringMessage.ts","../src/translation-functions/utils/interpolation/interpolateMessage.ts","../src/translation-functions/internal/helpers.ts","../src/condition-store/createConditionStoreSingleton.ts","../src/condition-store/singleton-operations.ts","../src/helpers/locale.ts","../src/utils/hashMessage.ts","../src/translation-functions/msg/decodeOptions.ts","../src/translation-functions/utils/isEncodedTranslationOptions.ts","../src/helpers/versionId.ts"],"sourcesContent":["export type GeneralTranslationLogLevel = string | undefined;\n\ntype LogLevelEnvironment = {\n _GENERALTRANSLATION_LOG_LEVEL?: string;\n};\n\nconst debugLogLevel = 'DEBUG';\n\nexport function getGeneralTranslationLogLevel(): GeneralTranslationLogLevel {\n const processLogLevel = readProcessEnvLogLevel();\n if (processLogLevel !== undefined) {\n return processLogLevel;\n }\n\n return readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: LogLevelEnvironment;\n }\n ).env?._GENERALTRANSLATION_LOG_LEVEL\n );\n}\n\nexport function isDebugLogLevel(logLevel: GeneralTranslationLogLevel): boolean {\n return logLevel?.toUpperCase() === debugLogLevel;\n}\n\nfunction readProcessEnvLogLevel(): GeneralTranslationLogLevel {\n if (typeof process !== 'object') {\n return undefined;\n }\n return process.env?._GENERALTRANSLATION_LOG_LEVEL;\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n} from '../logs/logLevel';\n\n/**\n * Shared global registry stored on `globalThis.__generaltranslation`. Each\n * package namespace (e.g. `i18n`, `reactCore`) owns a bag of singleton slots.\n */\ntype SingletonRegistry = Record<string, Record<string, unknown> | undefined>;\n\ntype GlobalWithRegistry = {\n __generaltranslation?: SingletonRegistry;\n};\n\ntype DebugLoggingConfig = {\n isDebugLoggingEnabled: () => boolean;\n};\n\nfunction getNamespace(namespace: string): Record<string, unknown> {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation[namespace] ??= {};\n return globalObj.__generaltranslation[namespace]!;\n}\n\nfunction getExistingNamespace(\n namespace: string\n): Record<string, unknown> | undefined {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n return globalObj.__generaltranslation?.[namespace];\n}\n\nexport type GlobalSingleton<T> = {\n get: () => T;\n set: (next: T) => void;\n isInitialized: () => boolean;\n};\n\n/**\n * Creates a global singleton backed by `globalThis.__generaltranslation`.\n *\n * Centralizes the global-registry plumbing and overwrite warning shared by the\n * i18nConfig, i18nCache, i18nStore, and conditionStore singletons.\n *\n * @param namespace - The package namespace bag (e.g. `i18n`, `reactCore`).\n * @param key - The slot within the namespace and the name used in the warning.\n * @param source - Diagnostic source for the overwrite warning.\n * @param notInitialized - Lazily builds the error thrown when read before set.\n */\nexport function createGlobalSingleton<T>({\n namespace,\n key,\n source,\n notInitialized,\n}: {\n namespace: string;\n key: string;\n source: string;\n notInitialized: () => string | Error;\n}): GlobalSingleton<T> {\n function get(): T {\n const value = getNamespace(namespace)[key];\n if (value === undefined || value === null) {\n const error = notInitialized();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n return value as T;\n }\n\n function set(next: T): void {\n const ns = getNamespace(namespace);\n if (ns[key] !== undefined && ns[key] !== next) {\n if (shouldLogDebugWarnings()) {\n console.warn(\n createDiagnosticMessage({\n source,\n severity: 'Warning',\n whatHappened: `Global ${key} singleton instance was already initialized`,\n })\n );\n }\n return;\n }\n ns[key] = next as unknown;\n }\n\n function isInitialized(): boolean {\n const value = getNamespace(namespace)[key];\n return value !== undefined && value !== null;\n }\n\n return { get, set, isInitialized };\n}\n\nfunction shouldLogDebugWarnings(): boolean {\n const config = getExistingNamespace('i18n')?.i18nConfig;\n if (hasDebugLoggingConfig(config)) {\n return config.isDebugLoggingEnabled();\n }\n return isDebugLogLevel(getGeneralTranslationLogLevel());\n}\n\nfunction hasDebugLoggingConfig(value: unknown): value is DebugLoggingConfig {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<DebugLoggingConfig>).isDebugLoggingEnabled ===\n 'function'\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nCache } from './I18nCache';\nimport { Translation } from './translations-manager/utils/types/translation-data';\n\nconst i18nCacheSingleton = createGlobalSingleton<I18nCache>({\n namespace: 'i18n',\n key: 'i18nCache',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nCache before it has been initialized',\n why: 'the internal I18nCache singleton is unavailable',\n fix: 'Initialize GT before accessing I18nCache (call initializeGT() from your GT framework package).',\n }),\n});\n\n/**\n * Get the singleton instance of I18nCache\n * @returns The singleton instance of I18nCache\n * @template U - The type of the translation that will be cached\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function getI18nCache<U extends Translation = Translation>():\n | I18nCache<U>\n | I18nCache<Translation> {\n return i18nCacheSingleton.get();\n}\n\n/**\n * Configure the singleton instance of I18nCache\n * @param config - The configuration for the I18nCache\n *\n * Wrapper libraries will export a configure function that will call this function.\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function setI18nCache<TranslationValue extends Translation>(\n i18nCacheInstance: I18nCache<TranslationValue>\n): void {\n i18nCacheSingleton.set(i18nCacheInstance as unknown as I18nCache);\n}\n","import { TranslationsLoader } from '../translations-manager/translations-loaders/types';\nimport { defaultCacheUrl } from 'generaltranslation/internal';\n\n/**\n * Loader translations type\n * - GT_REMOTE: use the default remote store URL {@link defaultCacheUrl}\n * - REMOTE: use a custom remote store URL\n * - CUSTOM: use a custom translations loader\n * - DISABLED: no translations loading\n */\nexport enum LoadTranslationsType {\n GT_REMOTE = 'gt-remote',\n REMOTE = 'remote',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the load translations type\n *\n * cacheUrl = null means disabled\n */\nexport function getLoadTranslationsType(config: {\n projectId?: string;\n cacheUrl?: string | null;\n loadTranslations?: TranslationsLoader;\n}): LoadTranslationsType {\n if (config.loadTranslations) {\n return LoadTranslationsType.CUSTOM;\n } else if (\n (config.cacheUrl === undefined || config.cacheUrl === defaultCacheUrl) &&\n config.projectId\n ) {\n return LoadTranslationsType.GT_REMOTE;\n } else if (config.cacheUrl) {\n return LoadTranslationsType.REMOTE;\n } else {\n return LoadTranslationsType.DISABLED;\n }\n}\n","import { defaultRuntimeApiUrl } from 'generaltranslation/internal';\n\n/**\n * Runtime API translation type\n * - GT: use the default runtime API URL {@link defaultRuntimeApiUrl}\n * - CUSTOM: use a custom runtime API URL\n * - DISABLED: no runtime API translation\n */\nexport enum TranslationApiType {\n GT = 'gt',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the runtime translation type\n * @param params - The parameters to validate\n * @returns The runtime translation type\n */\nexport function getTranslationApiType(params: {\n projectId?: string;\n devApiKey?: string;\n apiKey?: string;\n runtimeUrl?: string | null;\n}): TranslationApiType {\n const usesDefaultRuntimeUrl =\n params.runtimeUrl === undefined ||\n params.runtimeUrl === defaultRuntimeApiUrl;\n\n if (\n usesDefaultRuntimeUrl &&\n params.projectId &&\n (params.devApiKey || params.apiKey)\n ) {\n return TranslationApiType.GT;\n } else if (params.runtimeUrl && !usesDefaultRuntimeUrl) {\n return TranslationApiType.CUSTOM;\n } else {\n return TranslationApiType.DISABLED;\n }\n}\n","export type RuntimeEnvironment = {\n DEV?: boolean;\n MODE?: string;\n NODE_ENV?: string;\n};\n\nexport function getRuntimeEnvironment(): 'development' | 'production' {\n // We have to explicitly check `process.env.NODE_ENV` because it often gets string-replaced by bundler.\n // Destructuring or checking via other means may not work as expected.\n if (typeof process === 'object' && process.env?.NODE_ENV === 'development') {\n return 'development';\n }\n\n const importMetaMode = readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.MODE\n );\n if (importMetaMode) {\n return importMetaMode === 'development' ? 'development' : 'production';\n }\n if (\n readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.DEV\n ) === true\n ) {\n return 'development';\n }\n\n return 'production';\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","export default {\n warn(message: string) {\n console.warn(message);\n },\n\n error(message: string) {\n console.error(message);\n },\n\n info(message: string) {\n // eslint-disable-next-line no-console\n console.info(message);\n },\n\n debug(message: string) {\n // eslint-disable-next-line no-console\n console.debug(message);\n },\n};\n","import { isValidLocale } from '@generaltranslation/format';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport logger from '../logs/logger';\nimport type { I18nConfigParams } from './I18nConfig';\n\nexport function validateI18nConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): void {\n if (!gtServicesEnabled) {\n return;\n }\n\n const invalidLocales = getInvalidLocales(params);\n const invalidCustomMappingLocales = getInvalidCustomMappingLocales(params);\n const invalidLocaleConfig = [\n ...invalidLocales,\n ...invalidCustomMappingLocales,\n ];\n\n invalidLocaleConfig.forEach((locale) => {\n logger.error(`I18nConfig: ${getInvalidLocaleMessage(locale)}`);\n });\n\n if (invalidLocaleConfig.length > 0) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Invalid I18nConfig locale configuration',\n details: invalidLocaleConfig.map(\n (locale) => `Invalid locale: ${locale}`\n ),\n fix: 'Use valid BCP 47 locale codes or add custom mappings.',\n })\n );\n }\n}\n\nfunction getInvalidLocales({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams): string[] {\n const localesToValidate = new Set([\n ...(defaultLocale ? [defaultLocale] : []),\n ...(locales || []),\n ]);\n\n return Array.from(localesToValidate).filter(\n (locale) => !isValidLocale(locale, customMapping)\n );\n}\n\nfunction getInvalidCustomMappingLocales({\n customMapping,\n}: I18nConfigParams): string[] {\n return Object.values(customMapping || {}).flatMap((value) => {\n const locale = typeof value === 'string' ? value : value.code;\n return locale && !isValidLocale(locale) ? [locale] : [];\n });\n}\n\nfunction getInvalidLocaleMessage(locale: string): string {\n return createDiagnosticMessage({\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n}\n","import {\n LocaleConfig,\n type LocaleConfigConstructorParams,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { GTRuntime } from 'generaltranslation/runtime';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { GTConfig } from '../config/types';\nimport {\n getLoadTranslationsType,\n LoadTranslationsType,\n} from '../i18n-cache/utils/getLoadTranslationsType';\nimport {\n getTranslationApiType,\n TranslationApiType,\n} from '../i18n-cache/utils/getTranslationApiType';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n type GeneralTranslationLogLevel,\n} from '../logs/logLevel';\nimport { getRuntimeEnvironment } from '../utils/getRuntimeEnvironment';\nimport { validateI18nConfigParams } from './validation';\n\nexport type I18nConfigParams = Pick<\n GTConfig,\n | 'defaultLocale'\n | 'locales'\n | 'customMapping'\n | 'projectId'\n | 'devApiKey'\n | 'apiKey'\n | 'cacheUrl'\n | 'runtimeUrl'\n | '_disableDevHotReload'\n>;\n\ntype RuntimeConfig = Pick<\n I18nConfigParams,\n 'projectId' | 'devApiKey' | 'apiKey' | 'runtimeUrl' | '_disableDevHotReload'\n>;\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nexport class I18nConfig extends LocaleConfig {\n private runtimeConfig: RuntimeConfig;\n private gtServicesEnabled: boolean;\n private logLevel: GeneralTranslationLogLevel;\n\n constructor(params: I18nConfigParams = {}) {\n const gtServicesEnabled = resolveGTServicesEnabled(params);\n super(getLocaleConfigParams(params, gtServicesEnabled));\n this.runtimeConfig = {\n projectId: params.projectId,\n devApiKey: params.devApiKey,\n apiKey: params.apiKey,\n runtimeUrl: params.runtimeUrl,\n _disableDevHotReload: params._disableDevHotReload,\n };\n this.gtServicesEnabled = gtServicesEnabled;\n this.logLevel = getGeneralTranslationLogLevel();\n }\n\n getDefaultLocale(): string {\n return this.defaultLocale;\n }\n\n getLocales(): string[] {\n return this.locales;\n }\n\n getCustomMapping(): CustomMapping {\n return this.customMapping || {};\n }\n\n getProjectId(): string | undefined {\n return this.runtimeConfig.projectId;\n }\n\n /**\n * Get a GT instance bound to the resolved target locale. When omitted, the\n * instance is locale agnostic.\n *\n * TODO: keep a cache to avoid creating new instances unnecessarily.\n */\n getGTClass(locale?: string): GTRuntime {\n return this.getGTClassClean(\n locale ? this.resolveLocale(locale) : undefined\n );\n }\n\n determineLocale(\n locales: LocaleCandidates,\n approvedLocales: string[] = this.locales\n ): string | undefined {\n if (locales == null || (Array.isArray(locales) && locales.length === 0)) {\n return undefined;\n }\n return super.determineLocale(locales, approvedLocales);\n }\n\n determineSupportedLocale(\n candidates: LocaleCandidates,\n config?: I18nConfigParams\n ): string | undefined {\n return this.determineSupportedLocaleWithConfig(\n candidates,\n this.getLocaleConfig(config)\n );\n }\n\n resolveSupportedLocale(\n candidates?: LocaleCandidates,\n config?: I18nConfigParams\n ): string {\n const localeConfig = this.getLocaleConfig(config);\n return (\n this.determineSupportedLocaleWithConfig(candidates, localeConfig) ||\n localeConfig.defaultLocale\n );\n }\n\n resolveLocale(locale: string): string {\n const resolvedLocale = this.determineSupportedLocale(locale);\n if (!this.isValidLocale(locale) || !resolvedLocale) {\n throw new Error(\n `Locale \"${locale}\" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`\n );\n }\n return resolvedLocale;\n }\n\n /**\n * Returns true when development hot reload runtime translation requests can run.\n */\n isDevHotReloadEnabled(): boolean {\n return (\n !this.runtimeConfig._disableDevHotReload &&\n !!this.runtimeConfig.devApiKey &&\n !!this.runtimeConfig.projectId &&\n this.runtimeConfig.runtimeUrl !== null &&\n this.runtimeConfig.runtimeUrl !== '' &&\n getRuntimeEnvironment() === 'development'\n );\n }\n\n isGTServicesEnabled(): boolean {\n return this.gtServicesEnabled;\n }\n\n isDebugLoggingEnabled(): boolean {\n return isDebugLogLevel(this.logLevel);\n }\n\n /**\n * Create a GT instance without resolving the target locale first.\n */\n private getGTClassClean(locale?: string) {\n return new GTRuntime({\n sourceLocale: this.getDefaultLocale(),\n targetLocale: locale,\n // GT validates approved locales before constructing its LocaleConfig, so\n // pass canonical locales here while preserving alias target locales.\n locales: Array.from(\n new Set(\n this.getLocales().map((locale) => this.resolveCanonicalLocale(locale))\n )\n ),\n customMapping: this.getCustomMapping(),\n projectId: this.runtimeConfig.projectId,\n baseUrl: this.runtimeConfig.runtimeUrl || undefined,\n apiKey: this.runtimeConfig.apiKey,\n devApiKey: this.runtimeConfig.devApiKey,\n });\n }\n\n private getLocaleConfig(config?: I18nConfigParams): LocaleConfig {\n if (!config || !hasI18nConfigParams(config)) {\n return this;\n }\n return new LocaleConfig(getLocaleResolverConfigParams(config));\n }\n\n private determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n localeConfig: LocaleConfig\n ): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n return localeConfig.determineLocale(candidates);\n }\n}\n\nfunction getLocaleConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): LocaleConfigConstructorParams {\n const {\n defaultLocale = libraryDefaultLocale,\n locales = [],\n customMapping,\n } = params;\n\n validateI18nConfigParams(\n {\n ...params,\n defaultLocale,\n locales,\n customMapping,\n },\n gtServicesEnabled\n );\n\n return {\n defaultLocale,\n locales: Array.from(new Set([defaultLocale, ...locales])),\n customMapping: customMapping || {},\n };\n}\n\nfunction getLocaleResolverConfigParams({\n defaultLocale = libraryDefaultLocale,\n locales = [],\n customMapping,\n}: I18nConfigParams = {}): LocaleConfigConstructorParams {\n return {\n defaultLocale,\n locales: locales?.length ? locales : [defaultLocale],\n customMapping: customMapping || {},\n };\n}\n\nfunction hasI18nConfigParams(config: I18nConfigParams): boolean {\n return (\n config.defaultLocale !== undefined ||\n config.locales !== undefined ||\n config.customMapping !== undefined\n );\n}\n\nfunction resolveGTServicesEnabled(config: I18nConfigParams): boolean {\n return (\n getLoadTranslationsType(config) === LoadTranslationsType.GT_REMOTE ||\n getTranslationApiType(config) === TranslationApiType.GT\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nConfig, type I18nConfigParams } from './I18nConfig';\n\nconst i18nConfigSingleton = createGlobalSingleton<I18nConfig>({\n namespace: 'i18n',\n key: 'i18nConfig',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nConfig before it has been initialized',\n why: 'the internal I18nConfig singleton is unavailable',\n fix: 'Initialize GT before reading locale config (call initializeGT() from your GT framework package).',\n }),\n});\n\nexport const getI18nConfig = i18nConfigSingleton.get;\nexport const setI18nConfig = i18nConfigSingleton.set;\nexport const isI18nConfigInitialized = i18nConfigSingleton.isInitialized;\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {}\n): I18nConfig {\n const nextI18nConfig = new I18nConfig(params);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n","import { TranslationVariables } from '../translation-functions/types/options';\n\n/**\n * Given an object of options, returns an object with no gt-related options\n *\n * TODO: next major version, this should extract any sugar syntax options\n * TODO: next major version, options should be Record<string, string>\n */\nexport function extractVariables<T extends TranslationVariables>(\n options: T\n): TranslationVariables {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key]) =>\n key !== '$id' &&\n key !== '$context' &&\n key !== '$maxChars' &&\n key !== '$hash' && // this is already being done in @gt/react-core\n key !== '$_hash' &&\n key !== '$_source' &&\n key !== '$_fallback' &&\n key !== '$format' &&\n key !== '$locale' &&\n key !== '$requiresReview'\n )\n );\n}\n","export const createInterpolationFailureMessage = (message: string) =>\n `String interpolation failed for message: \"${message}\".`;\n","import type { StringFormat } from '@generaltranslation/format/types';\nimport logger from '../../logs/logger';\nimport { createInterpolationFailureMessage } from './messages';\nimport { formatMessage as _formatMessage } from '@generaltranslation/format';\n\n/**\n * Given an encoded message and variables, formats the message.\n * On error, the original encoded message is returned with a warning.\n * @param encodedMsg\n * @param variables\n * @returns\n */\nexport function formatMessage(\n encodedMsg: string,\n variables: Record<string, string>,\n locales?: string | string[],\n dataFormat?: StringFormat\n): string {\n try {\n return _formatMessage(encodedMsg, { variables, locales, dataFormat });\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n return encodedMsg;\n }\n}\n","import { extractVariables } from '../../../utils/extractVariables';\nimport { formatMessage } from '../formatMessage';\nimport {\n VAR_IDENTIFIER,\n extractVars,\n condenseVars,\n} from 'generaltranslation/internal';\nimport { formatCutoff } from '@generaltranslation/format';\nimport logger from '../../../logs/logger';\nimport { createInterpolationFailureMessage } from '../messages';\nimport type { TranslationOptions } from '../../types/options';\n\n/**\n * Applies string interpolation and cutoff formatting. Fallsback to the original message if interpolation fails.\n * @param {string} message - The message to interpolate.\n * @param {TranslationOptions} options - The options to interpolate.\n * @returns {string} - The interpolated message.\n */\nexport function interpolateIcuMessage<T extends string | null | undefined>(\n encodedMsg: T,\n options: TranslationOptions\n): T extends string ? string : T {\n // Return if the encoded message is null or undefined\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Get the source to use as a fallback\n const source = options.$_fallback;\n\n // Remove any gt related options\n const variables = extractVariables(options);\n\n try {\n // Extract declared variable values from the source/fallback\n const declaredVars = extractVars(source || '');\n\n // Condense indexed selects to arguments if declared vars exist\n const message = Object.keys(declaredVars).length\n ? condenseVars(encodedMsg)\n : encodedMsg;\n\n // Interpolate the message\n const interpolatedMessage = formatMessage(\n message,\n {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n options.$locale,\n options.$format\n );\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(interpolatedMessage, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n\n // If formatting the translation failed and we have a fallback, try formatting the source instead\n if (options.$_fallback != null) {\n return interpolateIcuMessage(options.$_fallback, {\n ...options,\n $_fallback: undefined,\n }) as T extends string ? string : T;\n }\n\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(encodedMsg, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n }\n}\n","import { formatCutoff } from '@generaltranslation/format';\nimport { TranslationOptions } from '../../types/options';\n\n/**\n * String interpolation function\n */\nexport function interpolateStringMessage(\n encodedMsg: string,\n options: TranslationOptions\n): string {\n const cutoffMessage = formatCutoff(encodedMsg, {\n locales: options.$locale,\n maxChars: options.$maxChars,\n });\n return cutoffMessage;\n}\n","import {\n TranslationOptions,\n NormalizedLookupOptions,\n} from '../../types/options';\nimport { interpolateIcuMessage } from './interpolateIcuMessage';\nimport { interpolateStringMessage } from './interpolateStringMessage';\nimport type { StringFormat } from '@generaltranslation/format/types';\n\n/**\n * Options for string interpolation\n * @internal\n */\nexport type InterpolationOptions = NormalizedLookupOptions<StringFormat>;\n\n/**\n * Interpolation router function for all {@link StringFormat} types\n */\nexport function interpolateMessage({\n source,\n target,\n options,\n sourceLocale,\n}: {\n source: string;\n target?: string;\n options: InterpolationOptions;\n sourceLocale?: string;\n}): string {\n // Format translation\n if (target != null) {\n return routeInterpolation(target, {\n $_fallback: source,\n ...options,\n });\n }\n\n // Format source\n // Missing translations format the source with the source locale, not the target locale.\n // TODO: Consider formatting dates, numbers, etc. with the target locale while keeping plurals in the source locale.\n return routeInterpolation(source, getSourceOptions(options, sourceLocale));\n}\n\n// ----- HELPERS ----- //\n\n/**\n * Route to appropriate formatting function\n */\nfunction routeInterpolation(\n content: string,\n options: TranslationOptions\n): string {\n switch (options.$format ?? 'STRING') {\n case 'ICU':\n return interpolateIcuMessage(content, options);\n case 'I18NEXT':\n case 'STRING':\n return interpolateStringMessage(content, options);\n default:\n // e.g. $format: 'NONE'\n return content;\n }\n}\n\nfunction getSourceOptions(\n options: InterpolationOptions,\n sourceLocale?: string\n): InterpolationOptions {\n if (!sourceLocale) return options;\n return {\n ...options,\n $locale: sourceLocale,\n };\n}\n","import { getI18nCache } from '../../i18n-cache/singleton-operations';\nimport { getI18nConfig } from '../../i18n-config/singleton-operations';\nimport { NormalizedLookupOptions, LookupOptionsFor } from '../types/options';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport type {\n DataFormat,\n JsxChildren,\n StringContent,\n StringFormat,\n} from '@generaltranslation/format/types';\n\n// ----- JSX TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n */\nexport function resolveJsx(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation;\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveJsxWithFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren {\n const translation = resolveJsx(locale, content, options);\n return translation ?? content;\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveJsxWithRuntimeFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): Promise<JsxChildren> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation ?? content;\n}\n\n// ----- STRING CONTENT TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n * And interpolate\n */\nexport function resolveStringContent(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n if (translation == null) return undefined;\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveStringContentWithFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<StringContent> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to runtime translate, without interpolating.\n * For prefetch calls whose result is discarded — variable values only exist\n * at the render-time call site, so interpolating here would fail for any\n * message with placeholders.\n */\nexport async function prefetchStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<void> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n}\n\n/**\n * Add the default format to caller-provided lookup options.\n */\nexport function createLookupOptions<T extends DataFormat>(\n locale: string,\n options: LookupOptionsFor<T>,\n defaultFormat: T\n): NormalizedLookupOptions<T> {\n return {\n ...options,\n $format: (options.$format ?? defaultFormat) as T,\n $locale: locale,\n };\n}\n","import { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport type {\n AsyncReadonlyConditionStoreInterface,\n ReadonlyConditionStoreInterface,\n} from '../i18n-cache/types';\n\nexport function createConditionStoreSingleton<\n T extends\n | ReadonlyConditionStoreInterface\n | AsyncReadonlyConditionStoreInterface,\n>(notInitializedMessage: string) {\n const singleton = createGlobalSingleton<T>({\n namespace: 'i18n',\n key: 'conditionStore',\n source: 'gt-i18n',\n notInitialized: () => notInitializedMessage,\n });\n\n return {\n getConditionStore: singleton.get,\n setConditionStore: singleton.set,\n isConditionStoreInitialized: singleton.isInitialized,\n };\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createConditionStoreSingleton } from './createConditionStoreSingleton';\nimport { WritableConditionStore } from './WritableConditionStore';\n\nexport const {\n getConditionStore: getWritableConditionStore,\n setConditionStore: setWritableConditionStore,\n} = createConditionStoreSingleton<WritableConditionStore>(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read the locale before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Initialize GT before calling translation functions (e.g. call initializeGT() from your GT framework package).',\n })\n);\n","import { getWritableConditionStore } from '../condition-store/singleton-operations';\nimport { getI18nConfig } from '../i18n-config/singleton-operations';\n\n/**\n * Get the current locale\n * @returns The current locale\n *\n * @example\n * const locale = getLocale();\n * console.log(locale); // 'en-US'\n */\nexport function getLocale() {\n return getWritableConditionStore().getLocale();\n}\n\n/**\n * Get the current region\n * @returns The current region, or undefined if no region is set\n *\n * @example\n * const region = getRegion();\n * console.log(region); // 'US' or undefined\n */\nexport function getRegion() {\n return getWritableConditionStore().getRegion();\n}\n\n/**\n * Get the configured locales\n * @returns The configured locales\n *\n * @example\n * const locales = getLocales();\n * console.log(locales); // ['en-US', 'es-ES']\n */\nexport function getLocales() {\n return getI18nConfig().getLocales();\n}\n\n/**\n * Get the default locale\n * @returns The default locale\n *\n * @example\n * const defaultLocale = getDefaultLocale();\n * console.log(defaultLocale); // 'en-US'\n */\nexport function getDefaultLocale() {\n return getI18nConfig().getDefaultLocale();\n}\n\n/**\n * Get the locale properties\n * @param {string} [locale] - The locale to get the properties for. When not provided, uses the current locale.\n * @returns The locale properties\n *\n * @example\n * const localeProperties = getLocaleProperties();\n *\n * @example\n * const localeProperties = getLocaleProperties('en-US');\n */\nexport function getLocaleProperties(locale = getLocale()) {\n return getI18nConfig().getLocaleProperties(locale);\n}\n\n/**\n * Resolve a locale to its canonical locale code using the configured custom mapping.\n * @param {string} locale - The locale to resolve.\n * @returns The canonical locale code.\n *\n * @example\n * const canonicalLocale = resolveCanonicalLocale('brand-french');\n * console.log(canonicalLocale); // 'fr-FR'\n */\nexport function resolveCanonicalLocale(locale: string) {\n return getI18nConfig().resolveCanonicalLocale(locale);\n}\n","import { hashSource } from 'generaltranslation/id';\nimport { indexVars } from 'generaltranslation/internal';\nimport { LookupOptions } from '../translation-functions/types/options';\nimport { Translation } from '../types';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\n/**\n * Hash a message string\n */\nexport function hashMessage<T extends Translation>(\n message: T,\n options: LookupOptions\n): string {\n const metadataOptions = options as {\n $_hash?: string;\n $context?: string;\n $id?: string;\n $maxChars?: number;\n $requiresReview?: boolean;\n };\n if (metadataOptions.$_hash != null) {\n return metadataOptions.$_hash;\n }\n\n return hashSource({\n source:\n options.$format === 'ICU' ? indexVars(message as IcuMessage) : message,\n ...(metadataOptions.$context && { context: metadataOptions.$context }),\n ...(metadataOptions.$maxChars != null && {\n maxChars: Math.abs(metadataOptions.$maxChars),\n }),\n ...(metadataOptions.$requiresReview === true && { requiresReview: true }),\n dataFormat: options.$format,\n });\n}\n","import { decode } from 'generaltranslation/internal';\nimport type { TranslationOptions } from '../types/options';\n\n/**\n * Decodes the options from an encoded message.\n * @param encodedMsg The message to decode.\n * @returns The decoded options.\n */\nexport function decodeOptions(encodedMsg: string): TranslationOptions | null {\n if (encodedMsg.lastIndexOf(':') === -1) {\n return null;\n }\n\n // Extract encoded options\n const optionsEncoding = encodedMsg.slice(encodedMsg.lastIndexOf(':') + 1);\n\n try {\n // Parse options\n const options = JSON.parse(decode(optionsEncoding));\n return options;\n } catch {\n return null;\n }\n}\n","import { EncodedTranslationOptions } from '../types/options';\n\n/**\n * Given a decoded options object, validate that includes required decoded options\n * These required options are added by msg() during the encoding process.\n */\nexport function isEncodedTranslationOptions(\n decodedOptions: Record<string, unknown> // TODO: next major version, this should be Record<string, string>\n): decodedOptions is EncodedTranslationOptions {\n return !!(decodedOptions.$_hash && decodedOptions.$_source);\n}\n","import { getI18nCache } from '../i18n-cache/singleton-operations';\n\n/**\n * Get the version ID for the current source\n * @returns The version ID, if set\n *\n * @example\n * const versionId = getVersionId();\n * console.log(versionId); // 'abc123'\n */\nexport function getVersionId() {\n const i18nCache = getI18nCache();\n return i18nCache.getVersionId();\n}\n"],"mappings":";;;;;AAMA,MAAM,gBAAgB;AAEtB,SAAgB,gCAA4D;CAC1E,MAAM,kBAAkB,wBAAwB;AAChD,KAAI,oBAAoB,KAAA,EACtB,QAAO;AAGT,QAAOA,2BAAAA,EAAAA,EAMD,KAAK,8BACV;;AAGH,SAAgB,gBAAgB,UAA+C;AAC7E,QAAO,UAAU,aAAa,KAAK;;AAGrC,SAAS,yBAAqD;AAC5D,KAAI,OAAO,YAAY,SACrB;AAEF,QAAO,QAAQ,KAAK;;AAGtB,SAASA,oBAAqB,WAA+C;AAC3E,KAAI;AACF,SAAO,WAAW;SACZ;AACN;;;;;ACnBJ,SAAS,aAAa,WAA4C;CAChE,MAAM,YAAY;AAClB,WAAU,yBAAyB,EAAE;AAErC,WAAU,qBAAqB,eAAe,EAAE;AAChD,QAAO,UAAU,qBAAqB;;AAGxC,SAAS,qBACP,WACqC;AAErC,QAAOC,WAAU,uBAAu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oBAAoB,SAAS,WAAW,EAAE;AACxD,QAAO,eAAe,CAAC,oBAAoB,OAAO;;;;;;;;;;;AAYpD,SAAgB,uBAAuB,QAAgB;AACrD,QAAO,eAAe,CAAC,uBAAuB,OAAO;;;;;;;ACnEvD,SAAgB,YACd,SACA,SACQ;CACR,MAAM,kBAAkB;AAOxB,KAAI,gBAAgB,UAAU,KAC5B,QAAO,gBAAgB;AAGzB,SAAA,GAAA,sBAAA,YAAkB;EAChB,QACE,QAAQ,YAAY,SAAA,GAAA,4BAAA,WAAkB,QAAsB,GAAG;EACjE,GAAI,gBAAgB,YAAY,EAAE,SAAS,gBAAgB,UAAU;EACrE,GAAI,gBAAgB,aAAa,QAAQ,EACvC,UAAU,KAAK,IAAI,gBAAgB,UAAU,EAC9C;EACD,GAAI,gBAAgB,oBAAoB,QAAQ,EAAE,gBAAgB,MAAM;EACxE,YAAY,QAAQ;EACrB,CAAC;;;;;;;;;ACzBJ,SAAgB,cAAc,YAA+C;AAC3E,KAAI,WAAW,YAAY,IAAI,KAAK,GAClC,QAAO;CAIT,MAAM,kBAAkB,WAAW,MAAM,WAAW,YAAY,IAAI,GAAG,EAAE;AAEzE,KAAI;AAGF,SADgB,KAAK,OAAA,GAAA,4BAAA,QAAa,gBAAgB,CACpC;SACR;AACN,SAAO;;;;;;;;;ACfX,SAAgB,4BACd,gBAC6C;AAC7C,QAAO,CAAC,EAAE,eAAe,UAAU,eAAe;;;;;;;;;;;;ACCpD,SAAgB,eAAe;AAE7B,QADkB,cACF,CAAC,cAAc"}
@@ -301,7 +301,7 @@ var I18nConfig = class extends LocaleConfig {
301
301
  }
302
302
  };
303
303
  function getLocaleConfigParams(params, gtServicesEnabled) {
304
- const { defaultLocale = libraryDefaultLocale, locales = [defaultLocale], customMapping } = params;
304
+ const { defaultLocale = libraryDefaultLocale, locales = [], customMapping } = params;
305
305
  validateI18nConfigParams({
306
306
  ...params,
307
307
  defaultLocale,
@@ -314,7 +314,7 @@ function getLocaleConfigParams(params, gtServicesEnabled) {
314
314
  customMapping: customMapping || {}
315
315
  };
316
316
  }
317
- function getLocaleResolverConfigParams({ defaultLocale = libraryDefaultLocale, locales, customMapping } = {}) {
317
+ function getLocaleResolverConfigParams({ defaultLocale = libraryDefaultLocale, locales = [], customMapping } = {}) {
318
318
  return {
319
319
  defaultLocale,
320
320
  locales: locales?.length ? locales : [defaultLocale],
@@ -683,4 +683,4 @@ function getVersionId() {
683
683
  //#endregion
684
684
  export { getI18nCache as A, getI18nConfig as C, logger_default as D, I18nConfig as E, createGlobalSingleton as M, getRuntimeEnvironment as O, extractVariables as S, setI18nConfig as T, resolveStringContentWithFallback as _, getDefaultLocale as a, interpolateIcuMessage as b, getLocales as c, getWritableConditionStore as d, createConditionStoreSingleton as f, resolveStringContent as g, resolveJsxWithRuntimeFallback as h, hashMessage as i, setI18nCache as j, getLoadTranslationsType as k, getRegion as l, prefetchStringContentWithRuntimeFallback as m, isEncodedTranslationOptions as n, getLocale as o, createLookupOptions as p, decodeOptions as r, getLocaleProperties as s, getVersionId as t, resolveCanonicalLocale$1 as u, resolveStringContentWithRuntimeFallback as v, initializeI18nConfig as w, createInterpolationFailureMessage as x, interpolateMessage as y };
685
685
 
686
- //# sourceMappingURL=versionId-JokehdDv.mjs.map
686
+ //# sourceMappingURL=versionId-DEb3k2mY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionId-DEb3k2mY.mjs","names":["readImportMetaEnv","globalObj","formatMessage","_formatMessage","formatMessage","resolveCanonicalLocale"],"sources":["../src/logs/logLevel.ts","../src/globals/createGlobalSingleton.ts","../src/i18n-cache/singleton-operations.ts","../src/i18n-cache/utils/getLoadTranslationsType.ts","../src/i18n-cache/utils/getTranslationApiType.ts","../src/utils/getRuntimeEnvironment.ts","../src/logs/logger.ts","../src/i18n-config/validation.ts","../src/i18n-config/I18nConfig.ts","../src/i18n-config/singleton-operations.ts","../src/utils/extractVariables.ts","../src/translation-functions/utils/messages.ts","../src/translation-functions/utils/formatMessage.ts","../src/translation-functions/utils/interpolation/interpolateIcuMessage.ts","../src/translation-functions/utils/interpolation/interpolateStringMessage.ts","../src/translation-functions/utils/interpolation/interpolateMessage.ts","../src/translation-functions/internal/helpers.ts","../src/condition-store/createConditionStoreSingleton.ts","../src/condition-store/singleton-operations.ts","../src/helpers/locale.ts","../src/utils/hashMessage.ts","../src/translation-functions/msg/decodeOptions.ts","../src/translation-functions/utils/isEncodedTranslationOptions.ts","../src/helpers/versionId.ts"],"sourcesContent":["export type GeneralTranslationLogLevel = string | undefined;\n\ntype LogLevelEnvironment = {\n _GENERALTRANSLATION_LOG_LEVEL?: string;\n};\n\nconst debugLogLevel = 'DEBUG';\n\nexport function getGeneralTranslationLogLevel(): GeneralTranslationLogLevel {\n const processLogLevel = readProcessEnvLogLevel();\n if (processLogLevel !== undefined) {\n return processLogLevel;\n }\n\n return readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: LogLevelEnvironment;\n }\n ).env?._GENERALTRANSLATION_LOG_LEVEL\n );\n}\n\nexport function isDebugLogLevel(logLevel: GeneralTranslationLogLevel): boolean {\n return logLevel?.toUpperCase() === debugLogLevel;\n}\n\nfunction readProcessEnvLogLevel(): GeneralTranslationLogLevel {\n if (typeof process !== 'object') {\n return undefined;\n }\n return process.env?._GENERALTRANSLATION_LOG_LEVEL;\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n} from '../logs/logLevel';\n\n/**\n * Shared global registry stored on `globalThis.__generaltranslation`. Each\n * package namespace (e.g. `i18n`, `reactCore`) owns a bag of singleton slots.\n */\ntype SingletonRegistry = Record<string, Record<string, unknown> | undefined>;\n\ntype GlobalWithRegistry = {\n __generaltranslation?: SingletonRegistry;\n};\n\ntype DebugLoggingConfig = {\n isDebugLoggingEnabled: () => boolean;\n};\n\nfunction getNamespace(namespace: string): Record<string, unknown> {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation[namespace] ??= {};\n return globalObj.__generaltranslation[namespace]!;\n}\n\nfunction getExistingNamespace(\n namespace: string\n): Record<string, unknown> | undefined {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n return globalObj.__generaltranslation?.[namespace];\n}\n\nexport type GlobalSingleton<T> = {\n get: () => T;\n set: (next: T) => void;\n isInitialized: () => boolean;\n};\n\n/**\n * Creates a global singleton backed by `globalThis.__generaltranslation`.\n *\n * Centralizes the global-registry plumbing and overwrite warning shared by the\n * i18nConfig, i18nCache, i18nStore, and conditionStore singletons.\n *\n * @param namespace - The package namespace bag (e.g. `i18n`, `reactCore`).\n * @param key - The slot within the namespace and the name used in the warning.\n * @param source - Diagnostic source for the overwrite warning.\n * @param notInitialized - Lazily builds the error thrown when read before set.\n */\nexport function createGlobalSingleton<T>({\n namespace,\n key,\n source,\n notInitialized,\n}: {\n namespace: string;\n key: string;\n source: string;\n notInitialized: () => string | Error;\n}): GlobalSingleton<T> {\n function get(): T {\n const value = getNamespace(namespace)[key];\n if (value === undefined || value === null) {\n const error = notInitialized();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n return value as T;\n }\n\n function set(next: T): void {\n const ns = getNamespace(namespace);\n if (ns[key] !== undefined && ns[key] !== next) {\n if (shouldLogDebugWarnings()) {\n console.warn(\n createDiagnosticMessage({\n source,\n severity: 'Warning',\n whatHappened: `Global ${key} singleton instance was already initialized`,\n })\n );\n }\n return;\n }\n ns[key] = next as unknown;\n }\n\n function isInitialized(): boolean {\n const value = getNamespace(namespace)[key];\n return value !== undefined && value !== null;\n }\n\n return { get, set, isInitialized };\n}\n\nfunction shouldLogDebugWarnings(): boolean {\n const config = getExistingNamespace('i18n')?.i18nConfig;\n if (hasDebugLoggingConfig(config)) {\n return config.isDebugLoggingEnabled();\n }\n return isDebugLogLevel(getGeneralTranslationLogLevel());\n}\n\nfunction hasDebugLoggingConfig(value: unknown): value is DebugLoggingConfig {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<DebugLoggingConfig>).isDebugLoggingEnabled ===\n 'function'\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nCache } from './I18nCache';\nimport { Translation } from './translations-manager/utils/types/translation-data';\n\nconst i18nCacheSingleton = createGlobalSingleton<I18nCache>({\n namespace: 'i18n',\n key: 'i18nCache',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nCache before it has been initialized',\n why: 'the internal I18nCache singleton is unavailable',\n fix: 'Initialize GT before accessing I18nCache (call initializeGT() from your GT framework package).',\n }),\n});\n\n/**\n * Get the singleton instance of I18nCache\n * @returns The singleton instance of I18nCache\n * @template U - The type of the translation that will be cached\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function getI18nCache<U extends Translation = Translation>():\n | I18nCache<U>\n | I18nCache<Translation> {\n return i18nCacheSingleton.get();\n}\n\n/**\n * Configure the singleton instance of I18nCache\n * @param config - The configuration for the I18nCache\n *\n * Wrapper libraries will export a configure function that will call this function.\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function setI18nCache<TranslationValue extends Translation>(\n i18nCacheInstance: I18nCache<TranslationValue>\n): void {\n i18nCacheSingleton.set(i18nCacheInstance as unknown as I18nCache);\n}\n","import { TranslationsLoader } from '../translations-manager/translations-loaders/types';\nimport { defaultCacheUrl } from 'generaltranslation/internal';\n\n/**\n * Loader translations type\n * - GT_REMOTE: use the default remote store URL {@link defaultCacheUrl}\n * - REMOTE: use a custom remote store URL\n * - CUSTOM: use a custom translations loader\n * - DISABLED: no translations loading\n */\nexport enum LoadTranslationsType {\n GT_REMOTE = 'gt-remote',\n REMOTE = 'remote',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the load translations type\n *\n * cacheUrl = null means disabled\n */\nexport function getLoadTranslationsType(config: {\n projectId?: string;\n cacheUrl?: string | null;\n loadTranslations?: TranslationsLoader;\n}): LoadTranslationsType {\n if (config.loadTranslations) {\n return LoadTranslationsType.CUSTOM;\n } else if (\n (config.cacheUrl === undefined || config.cacheUrl === defaultCacheUrl) &&\n config.projectId\n ) {\n return LoadTranslationsType.GT_REMOTE;\n } else if (config.cacheUrl) {\n return LoadTranslationsType.REMOTE;\n } else {\n return LoadTranslationsType.DISABLED;\n }\n}\n","import { defaultRuntimeApiUrl } from 'generaltranslation/internal';\n\n/**\n * Runtime API translation type\n * - GT: use the default runtime API URL {@link defaultRuntimeApiUrl}\n * - CUSTOM: use a custom runtime API URL\n * - DISABLED: no runtime API translation\n */\nexport enum TranslationApiType {\n GT = 'gt',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the runtime translation type\n * @param params - The parameters to validate\n * @returns The runtime translation type\n */\nexport function getTranslationApiType(params: {\n projectId?: string;\n devApiKey?: string;\n apiKey?: string;\n runtimeUrl?: string | null;\n}): TranslationApiType {\n const usesDefaultRuntimeUrl =\n params.runtimeUrl === undefined ||\n params.runtimeUrl === defaultRuntimeApiUrl;\n\n if (\n usesDefaultRuntimeUrl &&\n params.projectId &&\n (params.devApiKey || params.apiKey)\n ) {\n return TranslationApiType.GT;\n } else if (params.runtimeUrl && !usesDefaultRuntimeUrl) {\n return TranslationApiType.CUSTOM;\n } else {\n return TranslationApiType.DISABLED;\n }\n}\n","export type RuntimeEnvironment = {\n DEV?: boolean;\n MODE?: string;\n NODE_ENV?: string;\n};\n\nexport function getRuntimeEnvironment(): 'development' | 'production' {\n // We have to explicitly check `process.env.NODE_ENV` because it often gets string-replaced by bundler.\n // Destructuring or checking via other means may not work as expected.\n if (typeof process === 'object' && process.env?.NODE_ENV === 'development') {\n return 'development';\n }\n\n const importMetaMode = readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.MODE\n );\n if (importMetaMode) {\n return importMetaMode === 'development' ? 'development' : 'production';\n }\n if (\n readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.DEV\n ) === true\n ) {\n return 'development';\n }\n\n return 'production';\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","export default {\n warn(message: string) {\n console.warn(message);\n },\n\n error(message: string) {\n console.error(message);\n },\n\n info(message: string) {\n // eslint-disable-next-line no-console\n console.info(message);\n },\n\n debug(message: string) {\n // eslint-disable-next-line no-console\n console.debug(message);\n },\n};\n","import { isValidLocale } from '@generaltranslation/format';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport logger from '../logs/logger';\nimport type { I18nConfigParams } from './I18nConfig';\n\nexport function validateI18nConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): void {\n if (!gtServicesEnabled) {\n return;\n }\n\n const invalidLocales = getInvalidLocales(params);\n const invalidCustomMappingLocales = getInvalidCustomMappingLocales(params);\n const invalidLocaleConfig = [\n ...invalidLocales,\n ...invalidCustomMappingLocales,\n ];\n\n invalidLocaleConfig.forEach((locale) => {\n logger.error(`I18nConfig: ${getInvalidLocaleMessage(locale)}`);\n });\n\n if (invalidLocaleConfig.length > 0) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Invalid I18nConfig locale configuration',\n details: invalidLocaleConfig.map(\n (locale) => `Invalid locale: ${locale}`\n ),\n fix: 'Use valid BCP 47 locale codes or add custom mappings.',\n })\n );\n }\n}\n\nfunction getInvalidLocales({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams): string[] {\n const localesToValidate = new Set([\n ...(defaultLocale ? [defaultLocale] : []),\n ...(locales || []),\n ]);\n\n return Array.from(localesToValidate).filter(\n (locale) => !isValidLocale(locale, customMapping)\n );\n}\n\nfunction getInvalidCustomMappingLocales({\n customMapping,\n}: I18nConfigParams): string[] {\n return Object.values(customMapping || {}).flatMap((value) => {\n const locale = typeof value === 'string' ? value : value.code;\n return locale && !isValidLocale(locale) ? [locale] : [];\n });\n}\n\nfunction getInvalidLocaleMessage(locale: string): string {\n return createDiagnosticMessage({\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n}\n","import {\n LocaleConfig,\n type LocaleConfigConstructorParams,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { GTRuntime } from 'generaltranslation/runtime';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { GTConfig } from '../config/types';\nimport {\n getLoadTranslationsType,\n LoadTranslationsType,\n} from '../i18n-cache/utils/getLoadTranslationsType';\nimport {\n getTranslationApiType,\n TranslationApiType,\n} from '../i18n-cache/utils/getTranslationApiType';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n type GeneralTranslationLogLevel,\n} from '../logs/logLevel';\nimport { getRuntimeEnvironment } from '../utils/getRuntimeEnvironment';\nimport { validateI18nConfigParams } from './validation';\n\nexport type I18nConfigParams = Pick<\n GTConfig,\n | 'defaultLocale'\n | 'locales'\n | 'customMapping'\n | 'projectId'\n | 'devApiKey'\n | 'apiKey'\n | 'cacheUrl'\n | 'runtimeUrl'\n | '_disableDevHotReload'\n>;\n\ntype RuntimeConfig = Pick<\n I18nConfigParams,\n 'projectId' | 'devApiKey' | 'apiKey' | 'runtimeUrl' | '_disableDevHotReload'\n>;\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nexport class I18nConfig extends LocaleConfig {\n private runtimeConfig: RuntimeConfig;\n private gtServicesEnabled: boolean;\n private logLevel: GeneralTranslationLogLevel;\n\n constructor(params: I18nConfigParams = {}) {\n const gtServicesEnabled = resolveGTServicesEnabled(params);\n super(getLocaleConfigParams(params, gtServicesEnabled));\n this.runtimeConfig = {\n projectId: params.projectId,\n devApiKey: params.devApiKey,\n apiKey: params.apiKey,\n runtimeUrl: params.runtimeUrl,\n _disableDevHotReload: params._disableDevHotReload,\n };\n this.gtServicesEnabled = gtServicesEnabled;\n this.logLevel = getGeneralTranslationLogLevel();\n }\n\n getDefaultLocale(): string {\n return this.defaultLocale;\n }\n\n getLocales(): string[] {\n return this.locales;\n }\n\n getCustomMapping(): CustomMapping {\n return this.customMapping || {};\n }\n\n getProjectId(): string | undefined {\n return this.runtimeConfig.projectId;\n }\n\n /**\n * Get a GT instance bound to the resolved target locale. When omitted, the\n * instance is locale agnostic.\n *\n * TODO: keep a cache to avoid creating new instances unnecessarily.\n */\n getGTClass(locale?: string): GTRuntime {\n return this.getGTClassClean(\n locale ? this.resolveLocale(locale) : undefined\n );\n }\n\n determineLocale(\n locales: LocaleCandidates,\n approvedLocales: string[] = this.locales\n ): string | undefined {\n if (locales == null || (Array.isArray(locales) && locales.length === 0)) {\n return undefined;\n }\n return super.determineLocale(locales, approvedLocales);\n }\n\n determineSupportedLocale(\n candidates: LocaleCandidates,\n config?: I18nConfigParams\n ): string | undefined {\n return this.determineSupportedLocaleWithConfig(\n candidates,\n this.getLocaleConfig(config)\n );\n }\n\n resolveSupportedLocale(\n candidates?: LocaleCandidates,\n config?: I18nConfigParams\n ): string {\n const localeConfig = this.getLocaleConfig(config);\n return (\n this.determineSupportedLocaleWithConfig(candidates, localeConfig) ||\n localeConfig.defaultLocale\n );\n }\n\n resolveLocale(locale: string): string {\n const resolvedLocale = this.determineSupportedLocale(locale);\n if (!this.isValidLocale(locale) || !resolvedLocale) {\n throw new Error(\n `Locale \"${locale}\" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`\n );\n }\n return resolvedLocale;\n }\n\n /**\n * Returns true when development hot reload runtime translation requests can run.\n */\n isDevHotReloadEnabled(): boolean {\n return (\n !this.runtimeConfig._disableDevHotReload &&\n !!this.runtimeConfig.devApiKey &&\n !!this.runtimeConfig.projectId &&\n this.runtimeConfig.runtimeUrl !== null &&\n this.runtimeConfig.runtimeUrl !== '' &&\n getRuntimeEnvironment() === 'development'\n );\n }\n\n isGTServicesEnabled(): boolean {\n return this.gtServicesEnabled;\n }\n\n isDebugLoggingEnabled(): boolean {\n return isDebugLogLevel(this.logLevel);\n }\n\n /**\n * Create a GT instance without resolving the target locale first.\n */\n private getGTClassClean(locale?: string) {\n return new GTRuntime({\n sourceLocale: this.getDefaultLocale(),\n targetLocale: locale,\n // GT validates approved locales before constructing its LocaleConfig, so\n // pass canonical locales here while preserving alias target locales.\n locales: Array.from(\n new Set(\n this.getLocales().map((locale) => this.resolveCanonicalLocale(locale))\n )\n ),\n customMapping: this.getCustomMapping(),\n projectId: this.runtimeConfig.projectId,\n baseUrl: this.runtimeConfig.runtimeUrl || undefined,\n apiKey: this.runtimeConfig.apiKey,\n devApiKey: this.runtimeConfig.devApiKey,\n });\n }\n\n private getLocaleConfig(config?: I18nConfigParams): LocaleConfig {\n if (!config || !hasI18nConfigParams(config)) {\n return this;\n }\n return new LocaleConfig(getLocaleResolverConfigParams(config));\n }\n\n private determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n localeConfig: LocaleConfig\n ): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n return localeConfig.determineLocale(candidates);\n }\n}\n\nfunction getLocaleConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): LocaleConfigConstructorParams {\n const {\n defaultLocale = libraryDefaultLocale,\n locales = [],\n customMapping,\n } = params;\n\n validateI18nConfigParams(\n {\n ...params,\n defaultLocale,\n locales,\n customMapping,\n },\n gtServicesEnabled\n );\n\n return {\n defaultLocale,\n locales: Array.from(new Set([defaultLocale, ...locales])),\n customMapping: customMapping || {},\n };\n}\n\nfunction getLocaleResolverConfigParams({\n defaultLocale = libraryDefaultLocale,\n locales = [],\n customMapping,\n}: I18nConfigParams = {}): LocaleConfigConstructorParams {\n return {\n defaultLocale,\n locales: locales?.length ? locales : [defaultLocale],\n customMapping: customMapping || {},\n };\n}\n\nfunction hasI18nConfigParams(config: I18nConfigParams): boolean {\n return (\n config.defaultLocale !== undefined ||\n config.locales !== undefined ||\n config.customMapping !== undefined\n );\n}\n\nfunction resolveGTServicesEnabled(config: I18nConfigParams): boolean {\n return (\n getLoadTranslationsType(config) === LoadTranslationsType.GT_REMOTE ||\n getTranslationApiType(config) === TranslationApiType.GT\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nConfig, type I18nConfigParams } from './I18nConfig';\n\nconst i18nConfigSingleton = createGlobalSingleton<I18nConfig>({\n namespace: 'i18n',\n key: 'i18nConfig',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nConfig before it has been initialized',\n why: 'the internal I18nConfig singleton is unavailable',\n fix: 'Initialize GT before reading locale config (call initializeGT() from your GT framework package).',\n }),\n});\n\nexport const getI18nConfig = i18nConfigSingleton.get;\nexport const setI18nConfig = i18nConfigSingleton.set;\nexport const isI18nConfigInitialized = i18nConfigSingleton.isInitialized;\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {}\n): I18nConfig {\n const nextI18nConfig = new I18nConfig(params);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n","import { TranslationVariables } from '../translation-functions/types/options';\n\n/**\n * Given an object of options, returns an object with no gt-related options\n *\n * TODO: next major version, this should extract any sugar syntax options\n * TODO: next major version, options should be Record<string, string>\n */\nexport function extractVariables<T extends TranslationVariables>(\n options: T\n): TranslationVariables {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key]) =>\n key !== '$id' &&\n key !== '$context' &&\n key !== '$maxChars' &&\n key !== '$hash' && // this is already being done in @gt/react-core\n key !== '$_hash' &&\n key !== '$_source' &&\n key !== '$_fallback' &&\n key !== '$format' &&\n key !== '$locale' &&\n key !== '$requiresReview'\n )\n );\n}\n","export const createInterpolationFailureMessage = (message: string) =>\n `String interpolation failed for message: \"${message}\".`;\n","import type { StringFormat } from '@generaltranslation/format/types';\nimport logger from '../../logs/logger';\nimport { createInterpolationFailureMessage } from './messages';\nimport { formatMessage as _formatMessage } from '@generaltranslation/format';\n\n/**\n * Given an encoded message and variables, formats the message.\n * On error, the original encoded message is returned with a warning.\n * @param encodedMsg\n * @param variables\n * @returns\n */\nexport function formatMessage(\n encodedMsg: string,\n variables: Record<string, string>,\n locales?: string | string[],\n dataFormat?: StringFormat\n): string {\n try {\n return _formatMessage(encodedMsg, { variables, locales, dataFormat });\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n return encodedMsg;\n }\n}\n","import { extractVariables } from '../../../utils/extractVariables';\nimport { formatMessage } from '../formatMessage';\nimport {\n VAR_IDENTIFIER,\n extractVars,\n condenseVars,\n} from 'generaltranslation/internal';\nimport { formatCutoff } from '@generaltranslation/format';\nimport logger from '../../../logs/logger';\nimport { createInterpolationFailureMessage } from '../messages';\nimport type { TranslationOptions } from '../../types/options';\n\n/**\n * Applies string interpolation and cutoff formatting. Fallsback to the original message if interpolation fails.\n * @param {string} message - The message to interpolate.\n * @param {TranslationOptions} options - The options to interpolate.\n * @returns {string} - The interpolated message.\n */\nexport function interpolateIcuMessage<T extends string | null | undefined>(\n encodedMsg: T,\n options: TranslationOptions\n): T extends string ? string : T {\n // Return if the encoded message is null or undefined\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Get the source to use as a fallback\n const source = options.$_fallback;\n\n // Remove any gt related options\n const variables = extractVariables(options);\n\n try {\n // Extract declared variable values from the source/fallback\n const declaredVars = extractVars(source || '');\n\n // Condense indexed selects to arguments if declared vars exist\n const message = Object.keys(declaredVars).length\n ? condenseVars(encodedMsg)\n : encodedMsg;\n\n // Interpolate the message\n const interpolatedMessage = formatMessage(\n message,\n {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n options.$locale,\n options.$format\n );\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(interpolatedMessage, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n\n // If formatting the translation failed and we have a fallback, try formatting the source instead\n if (options.$_fallback != null) {\n return interpolateIcuMessage(options.$_fallback, {\n ...options,\n $_fallback: undefined,\n }) as T extends string ? string : T;\n }\n\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(encodedMsg, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n }\n}\n","import { formatCutoff } from '@generaltranslation/format';\nimport { TranslationOptions } from '../../types/options';\n\n/**\n * String interpolation function\n */\nexport function interpolateStringMessage(\n encodedMsg: string,\n options: TranslationOptions\n): string {\n const cutoffMessage = formatCutoff(encodedMsg, {\n locales: options.$locale,\n maxChars: options.$maxChars,\n });\n return cutoffMessage;\n}\n","import {\n TranslationOptions,\n NormalizedLookupOptions,\n} from '../../types/options';\nimport { interpolateIcuMessage } from './interpolateIcuMessage';\nimport { interpolateStringMessage } from './interpolateStringMessage';\nimport type { StringFormat } from '@generaltranslation/format/types';\n\n/**\n * Options for string interpolation\n * @internal\n */\nexport type InterpolationOptions = NormalizedLookupOptions<StringFormat>;\n\n/**\n * Interpolation router function for all {@link StringFormat} types\n */\nexport function interpolateMessage({\n source,\n target,\n options,\n sourceLocale,\n}: {\n source: string;\n target?: string;\n options: InterpolationOptions;\n sourceLocale?: string;\n}): string {\n // Format translation\n if (target != null) {\n return routeInterpolation(target, {\n $_fallback: source,\n ...options,\n });\n }\n\n // Format source\n // Missing translations format the source with the source locale, not the target locale.\n // TODO: Consider formatting dates, numbers, etc. with the target locale while keeping plurals in the source locale.\n return routeInterpolation(source, getSourceOptions(options, sourceLocale));\n}\n\n// ----- HELPERS ----- //\n\n/**\n * Route to appropriate formatting function\n */\nfunction routeInterpolation(\n content: string,\n options: TranslationOptions\n): string {\n switch (options.$format ?? 'STRING') {\n case 'ICU':\n return interpolateIcuMessage(content, options);\n case 'I18NEXT':\n case 'STRING':\n return interpolateStringMessage(content, options);\n default:\n // e.g. $format: 'NONE'\n return content;\n }\n}\n\nfunction getSourceOptions(\n options: InterpolationOptions,\n sourceLocale?: string\n): InterpolationOptions {\n if (!sourceLocale) return options;\n return {\n ...options,\n $locale: sourceLocale,\n };\n}\n","import { getI18nCache } from '../../i18n-cache/singleton-operations';\nimport { getI18nConfig } from '../../i18n-config/singleton-operations';\nimport { NormalizedLookupOptions, LookupOptionsFor } from '../types/options';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport type {\n DataFormat,\n JsxChildren,\n StringContent,\n StringFormat,\n} from '@generaltranslation/format/types';\n\n// ----- JSX TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n */\nexport function resolveJsx(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation;\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveJsxWithFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren {\n const translation = resolveJsx(locale, content, options);\n return translation ?? content;\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveJsxWithRuntimeFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): Promise<JsxChildren> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation ?? content;\n}\n\n// ----- STRING CONTENT TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n * And interpolate\n */\nexport function resolveStringContent(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n if (translation == null) return undefined;\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveStringContentWithFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<StringContent> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to runtime translate, without interpolating.\n * For prefetch calls whose result is discarded — variable values only exist\n * at the render-time call site, so interpolating here would fail for any\n * message with placeholders.\n */\nexport async function prefetchStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<void> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n}\n\n/**\n * Add the default format to caller-provided lookup options.\n */\nexport function createLookupOptions<T extends DataFormat>(\n locale: string,\n options: LookupOptionsFor<T>,\n defaultFormat: T\n): NormalizedLookupOptions<T> {\n return {\n ...options,\n $format: (options.$format ?? defaultFormat) as T,\n $locale: locale,\n };\n}\n","import { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport type {\n AsyncReadonlyConditionStoreInterface,\n ReadonlyConditionStoreInterface,\n} from '../i18n-cache/types';\n\nexport function createConditionStoreSingleton<\n T extends\n | ReadonlyConditionStoreInterface\n | AsyncReadonlyConditionStoreInterface,\n>(notInitializedMessage: string) {\n const singleton = createGlobalSingleton<T>({\n namespace: 'i18n',\n key: 'conditionStore',\n source: 'gt-i18n',\n notInitialized: () => notInitializedMessage,\n });\n\n return {\n getConditionStore: singleton.get,\n setConditionStore: singleton.set,\n isConditionStoreInitialized: singleton.isInitialized,\n };\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createConditionStoreSingleton } from './createConditionStoreSingleton';\nimport { WritableConditionStore } from './WritableConditionStore';\n\nexport const {\n getConditionStore: getWritableConditionStore,\n setConditionStore: setWritableConditionStore,\n} = createConditionStoreSingleton<WritableConditionStore>(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read the locale before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Initialize GT before calling translation functions (e.g. call initializeGT() from your GT framework package).',\n })\n);\n","import { getWritableConditionStore } from '../condition-store/singleton-operations';\nimport { getI18nConfig } from '../i18n-config/singleton-operations';\n\n/**\n * Get the current locale\n * @returns The current locale\n *\n * @example\n * const locale = getLocale();\n * console.log(locale); // 'en-US'\n */\nexport function getLocale() {\n return getWritableConditionStore().getLocale();\n}\n\n/**\n * Get the current region\n * @returns The current region, or undefined if no region is set\n *\n * @example\n * const region = getRegion();\n * console.log(region); // 'US' or undefined\n */\nexport function getRegion() {\n return getWritableConditionStore().getRegion();\n}\n\n/**\n * Get the configured locales\n * @returns The configured locales\n *\n * @example\n * const locales = getLocales();\n * console.log(locales); // ['en-US', 'es-ES']\n */\nexport function getLocales() {\n return getI18nConfig().getLocales();\n}\n\n/**\n * Get the default locale\n * @returns The default locale\n *\n * @example\n * const defaultLocale = getDefaultLocale();\n * console.log(defaultLocale); // 'en-US'\n */\nexport function getDefaultLocale() {\n return getI18nConfig().getDefaultLocale();\n}\n\n/**\n * Get the locale properties\n * @param {string} [locale] - The locale to get the properties for. When not provided, uses the current locale.\n * @returns The locale properties\n *\n * @example\n * const localeProperties = getLocaleProperties();\n *\n * @example\n * const localeProperties = getLocaleProperties('en-US');\n */\nexport function getLocaleProperties(locale = getLocale()) {\n return getI18nConfig().getLocaleProperties(locale);\n}\n\n/**\n * Resolve a locale to its canonical locale code using the configured custom mapping.\n * @param {string} locale - The locale to resolve.\n * @returns The canonical locale code.\n *\n * @example\n * const canonicalLocale = resolveCanonicalLocale('brand-french');\n * console.log(canonicalLocale); // 'fr-FR'\n */\nexport function resolveCanonicalLocale(locale: string) {\n return getI18nConfig().resolveCanonicalLocale(locale);\n}\n","import { hashSource } from 'generaltranslation/id';\nimport { indexVars } from 'generaltranslation/internal';\nimport { LookupOptions } from '../translation-functions/types/options';\nimport { Translation } from '../types';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\n/**\n * Hash a message string\n */\nexport function hashMessage<T extends Translation>(\n message: T,\n options: LookupOptions\n): string {\n const metadataOptions = options as {\n $_hash?: string;\n $context?: string;\n $id?: string;\n $maxChars?: number;\n $requiresReview?: boolean;\n };\n if (metadataOptions.$_hash != null) {\n return metadataOptions.$_hash;\n }\n\n return hashSource({\n source:\n options.$format === 'ICU' ? indexVars(message as IcuMessage) : message,\n ...(metadataOptions.$context && { context: metadataOptions.$context }),\n ...(metadataOptions.$maxChars != null && {\n maxChars: Math.abs(metadataOptions.$maxChars),\n }),\n ...(metadataOptions.$requiresReview === true && { requiresReview: true }),\n dataFormat: options.$format,\n });\n}\n","import { decode } from 'generaltranslation/internal';\nimport type { TranslationOptions } from '../types/options';\n\n/**\n * Decodes the options from an encoded message.\n * @param encodedMsg The message to decode.\n * @returns The decoded options.\n */\nexport function decodeOptions(encodedMsg: string): TranslationOptions | null {\n if (encodedMsg.lastIndexOf(':') === -1) {\n return null;\n }\n\n // Extract encoded options\n const optionsEncoding = encodedMsg.slice(encodedMsg.lastIndexOf(':') + 1);\n\n try {\n // Parse options\n const options = JSON.parse(decode(optionsEncoding));\n return options;\n } catch {\n return null;\n }\n}\n","import { EncodedTranslationOptions } from '../types/options';\n\n/**\n * Given a decoded options object, validate that includes required decoded options\n * These required options are added by msg() during the encoding process.\n */\nexport function isEncodedTranslationOptions(\n decodedOptions: Record<string, unknown> // TODO: next major version, this should be Record<string, string>\n): decodedOptions is EncodedTranslationOptions {\n return !!(decodedOptions.$_hash && decodedOptions.$_source);\n}\n","import { getI18nCache } from '../i18n-cache/singleton-operations';\n\n/**\n * Get the version ID for the current source\n * @returns The version ID, if set\n *\n * @example\n * const versionId = getVersionId();\n * console.log(versionId); // 'abc123'\n */\nexport function getVersionId() {\n const i18nCache = getI18nCache();\n return i18nCache.getVersionId();\n}\n"],"mappings":";;;;;AAMA,MAAM,gBAAgB;AAEtB,SAAgB,gCAA4D;CAC1E,MAAM,kBAAkB,wBAAwB;AAChD,KAAI,oBAAoB,KAAA,EACtB,QAAO;AAGT,QAAOA,0BAGD,OAAO,KAGP,KAAK,8BACV;;AAGH,SAAgB,gBAAgB,UAA+C;AAC7E,QAAO,UAAU,aAAa,KAAK;;AAGrC,SAAS,yBAAqD;AAC5D,KAAI,OAAO,YAAY,SACrB;AAEF,QAAO,QAAQ,KAAK;;AAGtB,SAASA,oBAAqB,WAA+C;AAC3E,KAAI;AACF,SAAO,WAAW;S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;;;;;;;;;;;AAYpD,SAAgBC,yBAAuB,QAAgB;AACrD,QAAO,eAAe,CAAC,uBAAuB,OAAO;;;;;;;ACnEvD,SAAgB,YACd,SACA,SACQ;CACR,MAAM,kBAAkB;AAOxB,KAAI,gBAAgB,UAAU,KAC5B,QAAO,gBAAgB;AAGzB,QAAO,WAAW;EAChB,QACE,QAAQ,YAAY,QAAQ,UAAU,QAAsB,GAAG;EACjE,GAAI,gBAAgB,YAAY,EAAE,SAAS,gBAAgB,UAAU;EACrE,GAAI,gBAAgB,aAAa,QAAQ,EACvC,UAAU,KAAK,IAAI,gBAAgB,UAAU,EAC9C;EACD,GAAI,gBAAgB,oBAAoB,QAAQ,EAAE,gBAAgB,MAAM;EACxE,YAAY,QAAQ;EACrB,CAAC;;;;;;;;;ACzBJ,SAAgB,cAAc,YAA+C;AAC3E,KAAI,WAAW,YAAY,IAAI,KAAK,GAClC,QAAO;CAIT,MAAM,kBAAkB,WAAW,MAAM,WAAW,YAAY,IAAI,GAAG,EAAE;AAEzE,KAAI;AAGF,SADgB,KAAK,MAAM,OAAO,gBAAgB,CACpC;SACR;AACN,SAAO;;;;;;;;;ACfX,SAAgB,4BACd,gBAC6C;AAC7C,QAAO,CAAC,EAAE,eAAe,UAAU,eAAe;;;;;;;;;;;;ACCpD,SAAgB,eAAe;AAE7B,QADkB,cACF,CAAC,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-i18n",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Pure JS i18n library for General Translation",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -40,8 +40,8 @@
40
40
  "definition": "dist/index.d.cts"
41
41
  },
42
42
  "dependencies": {
43
- "@generaltranslation/format": "0.1.2",
44
- "generaltranslation": "9.0.2"
43
+ "@generaltranslation/format": "0.1.3",
44
+ "generaltranslation": "9.0.4"
45
45
  },
46
46
  "exports": {
47
47
  ".": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"versionId-CT-IBMV6.cjs","names":["readImportMetaEnv","globalObj","defaultCacheUrl","defaultRuntimeApiUrl","LocaleConfig","GTRuntime","libraryDefaultLocale","VAR_IDENTIFIER"],"sources":["../src/logs/logLevel.ts","../src/globals/createGlobalSingleton.ts","../src/i18n-cache/singleton-operations.ts","../src/i18n-cache/utils/getLoadTranslationsType.ts","../src/i18n-cache/utils/getTranslationApiType.ts","../src/utils/getRuntimeEnvironment.ts","../src/logs/logger.ts","../src/i18n-config/validation.ts","../src/i18n-config/I18nConfig.ts","../src/i18n-config/singleton-operations.ts","../src/utils/extractVariables.ts","../src/translation-functions/utils/messages.ts","../src/translation-functions/utils/formatMessage.ts","../src/translation-functions/utils/interpolation/interpolateIcuMessage.ts","../src/translation-functions/utils/interpolation/interpolateStringMessage.ts","../src/translation-functions/utils/interpolation/interpolateMessage.ts","../src/translation-functions/internal/helpers.ts","../src/condition-store/createConditionStoreSingleton.ts","../src/condition-store/singleton-operations.ts","../src/helpers/locale.ts","../src/utils/hashMessage.ts","../src/translation-functions/msg/decodeOptions.ts","../src/translation-functions/utils/isEncodedTranslationOptions.ts","../src/helpers/versionId.ts"],"sourcesContent":["export type GeneralTranslationLogLevel = string | undefined;\n\ntype LogLevelEnvironment = {\n _GENERALTRANSLATION_LOG_LEVEL?: string;\n};\n\nconst debugLogLevel = 'DEBUG';\n\nexport function getGeneralTranslationLogLevel(): GeneralTranslationLogLevel {\n const processLogLevel = readProcessEnvLogLevel();\n if (processLogLevel !== undefined) {\n return processLogLevel;\n }\n\n return readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: LogLevelEnvironment;\n }\n ).env?._GENERALTRANSLATION_LOG_LEVEL\n );\n}\n\nexport function isDebugLogLevel(logLevel: GeneralTranslationLogLevel): boolean {\n return logLevel?.toUpperCase() === debugLogLevel;\n}\n\nfunction readProcessEnvLogLevel(): GeneralTranslationLogLevel {\n if (typeof process !== 'object') {\n return undefined;\n }\n return process.env?._GENERALTRANSLATION_LOG_LEVEL;\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n} from '../logs/logLevel';\n\n/**\n * Shared global registry stored on `globalThis.__generaltranslation`. Each\n * package namespace (e.g. `i18n`, `reactCore`) owns a bag of singleton slots.\n */\ntype SingletonRegistry = Record<string, Record<string, unknown> | undefined>;\n\ntype GlobalWithRegistry = {\n __generaltranslation?: SingletonRegistry;\n};\n\ntype DebugLoggingConfig = {\n isDebugLoggingEnabled: () => boolean;\n};\n\nfunction getNamespace(namespace: string): Record<string, unknown> {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation[namespace] ??= {};\n return globalObj.__generaltranslation[namespace]!;\n}\n\nfunction getExistingNamespace(\n namespace: string\n): Record<string, unknown> | undefined {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n return globalObj.__generaltranslation?.[namespace];\n}\n\nexport type GlobalSingleton<T> = {\n get: () => T;\n set: (next: T) => void;\n isInitialized: () => boolean;\n};\n\n/**\n * Creates a global singleton backed by `globalThis.__generaltranslation`.\n *\n * Centralizes the global-registry plumbing and overwrite warning shared by the\n * i18nConfig, i18nCache, i18nStore, and conditionStore singletons.\n *\n * @param namespace - The package namespace bag (e.g. `i18n`, `reactCore`).\n * @param key - The slot within the namespace and the name used in the warning.\n * @param source - Diagnostic source for the overwrite warning.\n * @param notInitialized - Lazily builds the error thrown when read before set.\n */\nexport function createGlobalSingleton<T>({\n namespace,\n key,\n source,\n notInitialized,\n}: {\n namespace: string;\n key: string;\n source: string;\n notInitialized: () => string | Error;\n}): GlobalSingleton<T> {\n function get(): T {\n const value = getNamespace(namespace)[key];\n if (value === undefined || value === null) {\n const error = notInitialized();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n return value as T;\n }\n\n function set(next: T): void {\n const ns = getNamespace(namespace);\n if (ns[key] !== undefined && ns[key] !== next) {\n if (shouldLogDebugWarnings()) {\n console.warn(\n createDiagnosticMessage({\n source,\n severity: 'Warning',\n whatHappened: `Global ${key} singleton instance was already initialized`,\n })\n );\n }\n return;\n }\n ns[key] = next as unknown;\n }\n\n function isInitialized(): boolean {\n const value = getNamespace(namespace)[key];\n return value !== undefined && value !== null;\n }\n\n return { get, set, isInitialized };\n}\n\nfunction shouldLogDebugWarnings(): boolean {\n const config = getExistingNamespace('i18n')?.i18nConfig;\n if (hasDebugLoggingConfig(config)) {\n return config.isDebugLoggingEnabled();\n }\n return isDebugLogLevel(getGeneralTranslationLogLevel());\n}\n\nfunction hasDebugLoggingConfig(value: unknown): value is DebugLoggingConfig {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<DebugLoggingConfig>).isDebugLoggingEnabled ===\n 'function'\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nCache } from './I18nCache';\nimport { Translation } from './translations-manager/utils/types/translation-data';\n\nconst i18nCacheSingleton = createGlobalSingleton<I18nCache>({\n namespace: 'i18n',\n key: 'i18nCache',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nCache before it has been initialized',\n why: 'the internal I18nCache singleton is unavailable',\n fix: 'Initialize GT before accessing I18nCache (call initializeGT() from your GT framework package).',\n }),\n});\n\n/**\n * Get the singleton instance of I18nCache\n * @returns The singleton instance of I18nCache\n * @template U - The type of the translation that will be cached\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function getI18nCache<U extends Translation = Translation>():\n | I18nCache<U>\n | I18nCache<Translation> {\n return i18nCacheSingleton.get();\n}\n\n/**\n * Configure the singleton instance of I18nCache\n * @param config - The configuration for the I18nCache\n *\n * Wrapper libraries will export a configure function that will call this function.\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function setI18nCache<TranslationValue extends Translation>(\n i18nCacheInstance: I18nCache<TranslationValue>\n): void {\n i18nCacheSingleton.set(i18nCacheInstance as unknown as I18nCache);\n}\n","import { TranslationsLoader } from '../translations-manager/translations-loaders/types';\nimport { defaultCacheUrl } from 'generaltranslation/internal';\n\n/**\n * Loader translations type\n * - GT_REMOTE: use the default remote store URL {@link defaultCacheUrl}\n * - REMOTE: use a custom remote store URL\n * - CUSTOM: use a custom translations loader\n * - DISABLED: no translations loading\n */\nexport enum LoadTranslationsType {\n GT_REMOTE = 'gt-remote',\n REMOTE = 'remote',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the load translations type\n *\n * cacheUrl = null means disabled\n */\nexport function getLoadTranslationsType(config: {\n projectId?: string;\n cacheUrl?: string | null;\n loadTranslations?: TranslationsLoader;\n}): LoadTranslationsType {\n if (config.loadTranslations) {\n return LoadTranslationsType.CUSTOM;\n } else if (\n (config.cacheUrl === undefined || config.cacheUrl === defaultCacheUrl) &&\n config.projectId\n ) {\n return LoadTranslationsType.GT_REMOTE;\n } else if (config.cacheUrl) {\n return LoadTranslationsType.REMOTE;\n } else {\n return LoadTranslationsType.DISABLED;\n }\n}\n","import { defaultRuntimeApiUrl } from 'generaltranslation/internal';\n\n/**\n * Runtime API translation type\n * - GT: use the default runtime API URL {@link defaultRuntimeApiUrl}\n * - CUSTOM: use a custom runtime API URL\n * - DISABLED: no runtime API translation\n */\nexport enum TranslationApiType {\n GT = 'gt',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the runtime translation type\n * @param params - The parameters to validate\n * @returns The runtime translation type\n */\nexport function getTranslationApiType(params: {\n projectId?: string;\n devApiKey?: string;\n apiKey?: string;\n runtimeUrl?: string | null;\n}): TranslationApiType {\n const usesDefaultRuntimeUrl =\n params.runtimeUrl === undefined ||\n params.runtimeUrl === defaultRuntimeApiUrl;\n\n if (\n usesDefaultRuntimeUrl &&\n params.projectId &&\n (params.devApiKey || params.apiKey)\n ) {\n return TranslationApiType.GT;\n } else if (params.runtimeUrl && !usesDefaultRuntimeUrl) {\n return TranslationApiType.CUSTOM;\n } else {\n return TranslationApiType.DISABLED;\n }\n}\n","export type RuntimeEnvironment = {\n DEV?: boolean;\n MODE?: string;\n NODE_ENV?: string;\n};\n\nexport function getRuntimeEnvironment(): 'development' | 'production' {\n // We have to explicitly check `process.env.NODE_ENV` because it often gets string-replaced by bundler.\n // Destructuring or checking via other means may not work as expected.\n if (typeof process === 'object' && process.env?.NODE_ENV === 'development') {\n return 'development';\n }\n\n const importMetaMode = readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.MODE\n );\n if (importMetaMode) {\n return importMetaMode === 'development' ? 'development' : 'production';\n }\n if (\n readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.DEV\n ) === true\n ) {\n return 'development';\n }\n\n return 'production';\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","export default {\n warn(message: string) {\n console.warn(message);\n },\n\n error(message: string) {\n console.error(message);\n },\n\n info(message: string) {\n // eslint-disable-next-line no-console\n console.info(message);\n },\n\n debug(message: string) {\n // eslint-disable-next-line no-console\n console.debug(message);\n },\n};\n","import { isValidLocale } from '@generaltranslation/format';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport logger from '../logs/logger';\nimport type { I18nConfigParams } from './I18nConfig';\n\nexport function validateI18nConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): void {\n if (!gtServicesEnabled) {\n return;\n }\n\n const invalidLocales = getInvalidLocales(params);\n const invalidCustomMappingLocales = getInvalidCustomMappingLocales(params);\n const invalidLocaleConfig = [\n ...invalidLocales,\n ...invalidCustomMappingLocales,\n ];\n\n invalidLocaleConfig.forEach((locale) => {\n logger.error(`I18nConfig: ${getInvalidLocaleMessage(locale)}`);\n });\n\n if (invalidLocaleConfig.length > 0) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Invalid I18nConfig locale configuration',\n details: invalidLocaleConfig.map(\n (locale) => `Invalid locale: ${locale}`\n ),\n fix: 'Use valid BCP 47 locale codes or add custom mappings.',\n })\n );\n }\n}\n\nfunction getInvalidLocales({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams): string[] {\n const localesToValidate = new Set([\n ...(defaultLocale ? [defaultLocale] : []),\n ...(locales || []),\n ]);\n\n return Array.from(localesToValidate).filter(\n (locale) => !isValidLocale(locale, customMapping)\n );\n}\n\nfunction getInvalidCustomMappingLocales({\n customMapping,\n}: I18nConfigParams): string[] {\n return Object.values(customMapping || {}).flatMap((value) => {\n const locale = typeof value === 'string' ? value : value.code;\n return locale && !isValidLocale(locale) ? [locale] : [];\n });\n}\n\nfunction getInvalidLocaleMessage(locale: string): string {\n return createDiagnosticMessage({\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n}\n","import {\n LocaleConfig,\n type LocaleConfigConstructorParams,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { GTRuntime } from 'generaltranslation/runtime';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { GTConfig } from '../config/types';\nimport {\n getLoadTranslationsType,\n LoadTranslationsType,\n} from '../i18n-cache/utils/getLoadTranslationsType';\nimport {\n getTranslationApiType,\n TranslationApiType,\n} from '../i18n-cache/utils/getTranslationApiType';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n type GeneralTranslationLogLevel,\n} from '../logs/logLevel';\nimport { getRuntimeEnvironment } from '../utils/getRuntimeEnvironment';\nimport { validateI18nConfigParams } from './validation';\n\nexport type I18nConfigParams = Pick<\n GTConfig,\n | 'defaultLocale'\n | 'locales'\n | 'customMapping'\n | 'projectId'\n | 'devApiKey'\n | 'apiKey'\n | 'cacheUrl'\n | 'runtimeUrl'\n | '_disableDevHotReload'\n>;\n\ntype RuntimeConfig = Pick<\n I18nConfigParams,\n 'projectId' | 'devApiKey' | 'apiKey' | 'runtimeUrl' | '_disableDevHotReload'\n>;\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nexport class I18nConfig extends LocaleConfig {\n private runtimeConfig: RuntimeConfig;\n private gtServicesEnabled: boolean;\n private logLevel: GeneralTranslationLogLevel;\n\n constructor(params: I18nConfigParams = {}) {\n const gtServicesEnabled = resolveGTServicesEnabled(params);\n super(getLocaleConfigParams(params, gtServicesEnabled));\n this.runtimeConfig = {\n projectId: params.projectId,\n devApiKey: params.devApiKey,\n apiKey: params.apiKey,\n runtimeUrl: params.runtimeUrl,\n _disableDevHotReload: params._disableDevHotReload,\n };\n this.gtServicesEnabled = gtServicesEnabled;\n this.logLevel = getGeneralTranslationLogLevel();\n }\n\n getDefaultLocale(): string {\n return this.defaultLocale;\n }\n\n getLocales(): string[] {\n return this.locales;\n }\n\n getCustomMapping(): CustomMapping {\n return this.customMapping || {};\n }\n\n getProjectId(): string | undefined {\n return this.runtimeConfig.projectId;\n }\n\n /**\n * Get a GT instance bound to the resolved target locale. When omitted, the\n * instance is locale agnostic.\n *\n * TODO: keep a cache to avoid creating new instances unnecessarily.\n */\n getGTClass(locale?: string): GTRuntime {\n return this.getGTClassClean(\n locale ? this.resolveLocale(locale) : undefined\n );\n }\n\n determineLocale(\n locales: LocaleCandidates,\n approvedLocales: string[] = this.locales\n ): string | undefined {\n if (locales == null || (Array.isArray(locales) && locales.length === 0)) {\n return undefined;\n }\n return super.determineLocale(locales, approvedLocales);\n }\n\n determineSupportedLocale(\n candidates: LocaleCandidates,\n config?: I18nConfigParams\n ): string | undefined {\n return this.determineSupportedLocaleWithConfig(\n candidates,\n this.getLocaleConfig(config)\n );\n }\n\n resolveSupportedLocale(\n candidates?: LocaleCandidates,\n config?: I18nConfigParams\n ): string {\n const localeConfig = this.getLocaleConfig(config);\n return (\n this.determineSupportedLocaleWithConfig(candidates, localeConfig) ||\n localeConfig.defaultLocale\n );\n }\n\n resolveLocale(locale: string): string {\n const resolvedLocale = this.determineSupportedLocale(locale);\n if (!this.isValidLocale(locale) || !resolvedLocale) {\n throw new Error(\n `Locale \"${locale}\" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`\n );\n }\n return resolvedLocale;\n }\n\n /**\n * Returns true when development hot reload runtime translation requests can run.\n */\n isDevHotReloadEnabled(): boolean {\n return (\n !this.runtimeConfig._disableDevHotReload &&\n !!this.runtimeConfig.devApiKey &&\n !!this.runtimeConfig.projectId &&\n this.runtimeConfig.runtimeUrl !== null &&\n this.runtimeConfig.runtimeUrl !== '' &&\n getRuntimeEnvironment() === 'development'\n );\n }\n\n isGTServicesEnabled(): boolean {\n return this.gtServicesEnabled;\n }\n\n isDebugLoggingEnabled(): boolean {\n return isDebugLogLevel(this.logLevel);\n }\n\n /**\n * Create a GT instance without resolving the target locale first.\n */\n private getGTClassClean(locale?: string) {\n return new GTRuntime({\n sourceLocale: this.getDefaultLocale(),\n targetLocale: locale,\n // GT validates approved locales before constructing its LocaleConfig, so\n // pass canonical locales here while preserving alias target locales.\n locales: Array.from(\n new Set(\n this.getLocales().map((locale) => this.resolveCanonicalLocale(locale))\n )\n ),\n customMapping: this.getCustomMapping(),\n projectId: this.runtimeConfig.projectId,\n baseUrl: this.runtimeConfig.runtimeUrl || undefined,\n apiKey: this.runtimeConfig.apiKey,\n devApiKey: this.runtimeConfig.devApiKey,\n });\n }\n\n private getLocaleConfig(config?: I18nConfigParams): LocaleConfig {\n if (!config || !hasI18nConfigParams(config)) {\n return this;\n }\n return new LocaleConfig(getLocaleResolverConfigParams(config));\n }\n\n private determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n localeConfig: LocaleConfig\n ): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n return localeConfig.determineLocale(candidates);\n }\n}\n\nfunction getLocaleConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): LocaleConfigConstructorParams {\n const {\n defaultLocale = libraryDefaultLocale,\n locales = [defaultLocale],\n customMapping,\n } = params;\n\n validateI18nConfigParams(\n {\n ...params,\n defaultLocale,\n locales,\n customMapping,\n },\n gtServicesEnabled\n );\n\n return {\n defaultLocale,\n locales: Array.from(new Set([defaultLocale, ...locales])),\n customMapping: customMapping || {},\n };\n}\n\nfunction getLocaleResolverConfigParams({\n defaultLocale = libraryDefaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams = {}): LocaleConfigConstructorParams {\n return {\n defaultLocale,\n locales: locales?.length ? locales : [defaultLocale],\n customMapping: customMapping || {},\n };\n}\n\nfunction hasI18nConfigParams(config: I18nConfigParams): boolean {\n return (\n config.defaultLocale !== undefined ||\n config.locales !== undefined ||\n config.customMapping !== undefined\n );\n}\n\nfunction resolveGTServicesEnabled(config: I18nConfigParams): boolean {\n return (\n getLoadTranslationsType(config) === LoadTranslationsType.GT_REMOTE ||\n getTranslationApiType(config) === TranslationApiType.GT\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nConfig, type I18nConfigParams } from './I18nConfig';\n\nconst i18nConfigSingleton = createGlobalSingleton<I18nConfig>({\n namespace: 'i18n',\n key: 'i18nConfig',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nConfig before it has been initialized',\n why: 'the internal I18nConfig singleton is unavailable',\n fix: 'Initialize GT before reading locale config (call initializeGT() from your GT framework package).',\n }),\n});\n\nexport const getI18nConfig = i18nConfigSingleton.get;\nexport const setI18nConfig = i18nConfigSingleton.set;\nexport const isI18nConfigInitialized = i18nConfigSingleton.isInitialized;\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {}\n): I18nConfig {\n const nextI18nConfig = new I18nConfig(params);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n","import { TranslationVariables } from '../translation-functions/types/options';\n\n/**\n * Given an object of options, returns an object with no gt-related options\n *\n * TODO: next major version, this should extract any sugar syntax options\n * TODO: next major version, options should be Record<string, string>\n */\nexport function extractVariables<T extends TranslationVariables>(\n options: T\n): TranslationVariables {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key]) =>\n key !== '$id' &&\n key !== '$context' &&\n key !== '$maxChars' &&\n key !== '$hash' && // this is already being done in @gt/react-core\n key !== '$_hash' &&\n key !== '$_source' &&\n key !== '$_fallback' &&\n key !== '$format' &&\n key !== '$locale' &&\n key !== '$requiresReview'\n )\n );\n}\n","export const createInterpolationFailureMessage = (message: string) =>\n `String interpolation failed for message: \"${message}\".`;\n","import type { StringFormat } from '@generaltranslation/format/types';\nimport logger from '../../logs/logger';\nimport { createInterpolationFailureMessage } from './messages';\nimport { formatMessage as _formatMessage } from '@generaltranslation/format';\n\n/**\n * Given an encoded message and variables, formats the message.\n * On error, the original encoded message is returned with a warning.\n * @param encodedMsg\n * @param variables\n * @returns\n */\nexport function formatMessage(\n encodedMsg: string,\n variables: Record<string, string>,\n locales?: string | string[],\n dataFormat?: StringFormat\n): string {\n try {\n return _formatMessage(encodedMsg, { variables, locales, dataFormat });\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n return encodedMsg;\n }\n}\n","import { extractVariables } from '../../../utils/extractVariables';\nimport { formatMessage } from '../formatMessage';\nimport {\n VAR_IDENTIFIER,\n extractVars,\n condenseVars,\n} from 'generaltranslation/internal';\nimport { formatCutoff } from '@generaltranslation/format';\nimport logger from '../../../logs/logger';\nimport { createInterpolationFailureMessage } from '../messages';\nimport type { TranslationOptions } from '../../types/options';\n\n/**\n * Applies string interpolation and cutoff formatting. Fallsback to the original message if interpolation fails.\n * @param {string} message - The message to interpolate.\n * @param {TranslationOptions} options - The options to interpolate.\n * @returns {string} - The interpolated message.\n */\nexport function interpolateIcuMessage<T extends string | null | undefined>(\n encodedMsg: T,\n options: TranslationOptions\n): T extends string ? string : T {\n // Return if the encoded message is null or undefined\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Get the source to use as a fallback\n const source = options.$_fallback;\n\n // Remove any gt related options\n const variables = extractVariables(options);\n\n try {\n // Extract declared variable values from the source/fallback\n const declaredVars = extractVars(source || '');\n\n // Condense indexed selects to arguments if declared vars exist\n const message = Object.keys(declaredVars).length\n ? condenseVars(encodedMsg)\n : encodedMsg;\n\n // Interpolate the message\n const interpolatedMessage = formatMessage(\n message,\n {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n options.$locale,\n options.$format\n );\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(interpolatedMessage, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n\n // If formatting the translation failed and we have a fallback, try formatting the source instead\n if (options.$_fallback != null) {\n return interpolateIcuMessage(options.$_fallback, {\n ...options,\n $_fallback: undefined,\n }) as T extends string ? string : T;\n }\n\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(encodedMsg, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n }\n}\n","import { formatCutoff } from '@generaltranslation/format';\nimport { TranslationOptions } from '../../types/options';\n\n/**\n * String interpolation function\n */\nexport function interpolateStringMessage(\n encodedMsg: string,\n options: TranslationOptions\n): string {\n const cutoffMessage = formatCutoff(encodedMsg, {\n locales: options.$locale,\n maxChars: options.$maxChars,\n });\n return cutoffMessage;\n}\n","import {\n TranslationOptions,\n NormalizedLookupOptions,\n} from '../../types/options';\nimport { interpolateIcuMessage } from './interpolateIcuMessage';\nimport { interpolateStringMessage } from './interpolateStringMessage';\nimport type { StringFormat } from '@generaltranslation/format/types';\n\n/**\n * Options for string interpolation\n * @internal\n */\nexport type InterpolationOptions = NormalizedLookupOptions<StringFormat>;\n\n/**\n * Interpolation router function for all {@link StringFormat} types\n */\nexport function interpolateMessage({\n source,\n target,\n options,\n sourceLocale,\n}: {\n source: string;\n target?: string;\n options: InterpolationOptions;\n sourceLocale?: string;\n}): string {\n // Format translation\n if (target != null) {\n return routeInterpolation(target, {\n $_fallback: source,\n ...options,\n });\n }\n\n // Format source\n // Missing translations format the source with the source locale, not the target locale.\n // TODO: Consider formatting dates, numbers, etc. with the target locale while keeping plurals in the source locale.\n return routeInterpolation(source, getSourceOptions(options, sourceLocale));\n}\n\n// ----- HELPERS ----- //\n\n/**\n * Route to appropriate formatting function\n */\nfunction routeInterpolation(\n content: string,\n options: TranslationOptions\n): string {\n switch (options.$format ?? 'STRING') {\n case 'ICU':\n return interpolateIcuMessage(content, options);\n case 'I18NEXT':\n case 'STRING':\n return interpolateStringMessage(content, options);\n default:\n // e.g. $format: 'NONE'\n return content;\n }\n}\n\nfunction getSourceOptions(\n options: InterpolationOptions,\n sourceLocale?: string\n): InterpolationOptions {\n if (!sourceLocale) return options;\n return {\n ...options,\n $locale: sourceLocale,\n };\n}\n","import { getI18nCache } from '../../i18n-cache/singleton-operations';\nimport { getI18nConfig } from '../../i18n-config/singleton-operations';\nimport { NormalizedLookupOptions, LookupOptionsFor } from '../types/options';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport type {\n DataFormat,\n JsxChildren,\n StringContent,\n StringFormat,\n} from '@generaltranslation/format/types';\n\n// ----- JSX TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n */\nexport function resolveJsx(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation;\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveJsxWithFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren {\n const translation = resolveJsx(locale, content, options);\n return translation ?? content;\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveJsxWithRuntimeFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): Promise<JsxChildren> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation ?? content;\n}\n\n// ----- STRING CONTENT TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n * And interpolate\n */\nexport function resolveStringContent(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n if (translation == null) return undefined;\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveStringContentWithFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<StringContent> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to runtime translate, without interpolating.\n * For prefetch calls whose result is discarded — variable values only exist\n * at the render-time call site, so interpolating here would fail for any\n * message with placeholders.\n */\nexport async function prefetchStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<void> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n}\n\n/**\n * Add the default format to caller-provided lookup options.\n */\nexport function createLookupOptions<T extends DataFormat>(\n locale: string,\n options: LookupOptionsFor<T>,\n defaultFormat: T\n): NormalizedLookupOptions<T> {\n return {\n ...options,\n $format: (options.$format ?? defaultFormat) as T,\n $locale: locale,\n };\n}\n","import { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport type {\n AsyncReadonlyConditionStoreInterface,\n ReadonlyConditionStoreInterface,\n} from '../i18n-cache/types';\n\nexport function createConditionStoreSingleton<\n T extends\n | ReadonlyConditionStoreInterface\n | AsyncReadonlyConditionStoreInterface,\n>(notInitializedMessage: string) {\n const singleton = createGlobalSingleton<T>({\n namespace: 'i18n',\n key: 'conditionStore',\n source: 'gt-i18n',\n notInitialized: () => notInitializedMessage,\n });\n\n return {\n getConditionStore: singleton.get,\n setConditionStore: singleton.set,\n isConditionStoreInitialized: singleton.isInitialized,\n };\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createConditionStoreSingleton } from './createConditionStoreSingleton';\nimport { WritableConditionStore } from './WritableConditionStore';\n\nexport const {\n getConditionStore: getWritableConditionStore,\n setConditionStore: setWritableConditionStore,\n} = createConditionStoreSingleton<WritableConditionStore>(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read the locale before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Initialize GT before calling translation functions (e.g. call initializeGT() from your GT framework package).',\n })\n);\n","import { getWritableConditionStore } from '../condition-store/singleton-operations';\nimport { getI18nConfig } from '../i18n-config/singleton-operations';\n\n/**\n * Get the current locale\n * @returns The current locale\n *\n * @example\n * const locale = getLocale();\n * console.log(locale); // 'en-US'\n */\nexport function getLocale() {\n return getWritableConditionStore().getLocale();\n}\n\n/**\n * Get the current region\n * @returns The current region, or undefined if no region is set\n *\n * @example\n * const region = getRegion();\n * console.log(region); // 'US' or undefined\n */\nexport function getRegion() {\n return getWritableConditionStore().getRegion();\n}\n\n/**\n * Get the configured locales\n * @returns The configured locales\n *\n * @example\n * const locales = getLocales();\n * console.log(locales); // ['en-US', 'es-ES']\n */\nexport function getLocales() {\n return getI18nConfig().getLocales();\n}\n\n/**\n * Get the default locale\n * @returns The default locale\n *\n * @example\n * const defaultLocale = getDefaultLocale();\n * console.log(defaultLocale); // 'en-US'\n */\nexport function getDefaultLocale() {\n return getI18nConfig().getDefaultLocale();\n}\n\n/**\n * Get the locale properties\n * @param {string} [locale] - The locale to get the properties for. When not provided, uses the current locale.\n * @returns The locale properties\n *\n * @example\n * const localeProperties = getLocaleProperties();\n *\n * @example\n * const localeProperties = getLocaleProperties('en-US');\n */\nexport function getLocaleProperties(locale = getLocale()) {\n return getI18nConfig().getLocaleProperties(locale);\n}\n\n/**\n * Resolve a locale to its canonical locale code using the configured custom mapping.\n * @param {string} locale - The locale to resolve.\n * @returns The canonical locale code.\n *\n * @example\n * const canonicalLocale = resolveCanonicalLocale('brand-french');\n * console.log(canonicalLocale); // 'fr-FR'\n */\nexport function resolveCanonicalLocale(locale: string) {\n return getI18nConfig().resolveCanonicalLocale(locale);\n}\n","import { hashSource } from 'generaltranslation/id';\nimport { indexVars } from 'generaltranslation/internal';\nimport { LookupOptions } from '../translation-functions/types/options';\nimport { Translation } from '../types';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\n/**\n * Hash a message string\n */\nexport function hashMessage<T extends Translation>(\n message: T,\n options: LookupOptions\n): string {\n const metadataOptions = options as {\n $_hash?: string;\n $context?: string;\n $id?: string;\n $maxChars?: number;\n $requiresReview?: boolean;\n };\n if (metadataOptions.$_hash != null) {\n return metadataOptions.$_hash;\n }\n\n return hashSource({\n source:\n options.$format === 'ICU' ? indexVars(message as IcuMessage) : message,\n ...(metadataOptions.$context && { context: metadataOptions.$context }),\n ...(metadataOptions.$maxChars != null && {\n maxChars: Math.abs(metadataOptions.$maxChars),\n }),\n ...(metadataOptions.$requiresReview === true && { requiresReview: true }),\n dataFormat: options.$format,\n });\n}\n","import { decode } from 'generaltranslation/internal';\nimport type { TranslationOptions } from '../types/options';\n\n/**\n * Decodes the options from an encoded message.\n * @param encodedMsg The message to decode.\n * @returns The decoded options.\n */\nexport function decodeOptions(encodedMsg: string): TranslationOptions | null {\n if (encodedMsg.lastIndexOf(':') === -1) {\n return null;\n }\n\n // Extract encoded options\n const optionsEncoding = encodedMsg.slice(encodedMsg.lastIndexOf(':') + 1);\n\n try {\n // Parse options\n const options = JSON.parse(decode(optionsEncoding));\n return options;\n } catch {\n return null;\n }\n}\n","import { EncodedTranslationOptions } from '../types/options';\n\n/**\n * Given a decoded options object, validate that includes required decoded options\n * These required options are added by msg() during the encoding process.\n */\nexport function isEncodedTranslationOptions(\n decodedOptions: Record<string, unknown> // TODO: next major version, this should be Record<string, string>\n): decodedOptions is EncodedTranslationOptions {\n return !!(decodedOptions.$_hash && decodedOptions.$_source);\n}\n","import { getI18nCache } from '../i18n-cache/singleton-operations';\n\n/**\n * Get the version ID for the current source\n * @returns The version ID, if set\n *\n * @example\n * const versionId = getVersionId();\n * console.log(versionId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AAc,YAA+C;AAC3E,KAAI,WAAW,YAAY,IAAI,KAAK,GAClC,QAAO;CAIT,MAAM,kBAAkB,WAAW,MAAM,WAAW,YAAY,IAAI,GAAG,EAAE;AAEzE,KAAI;AAGF,SADgB,KAAK,OAAA,GAAA,4BAAA,QAAa,gBAAgB,CACpC;SACR;AACN,SAAO;;;;;;;;;ACfX,SAAgB,4BACd,gBAC6C;AAC7C,QAAO,CAAC,EAAE,eAAe,UAAU,eAAe;;;;;;;;;;;;ACCpD,SAAgB,eAAe;AAE7B,QADkB,cACF,CAAC,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"versionId-JokehdDv.mjs","names":["readImportMetaEnv","globalObj","formatMessage","_formatMessage","formatMessage","resolveCanonicalLocale"],"sources":["../src/logs/logLevel.ts","../src/globals/createGlobalSingleton.ts","../src/i18n-cache/singleton-operations.ts","../src/i18n-cache/utils/getLoadTranslationsType.ts","../src/i18n-cache/utils/getTranslationApiType.ts","../src/utils/getRuntimeEnvironment.ts","../src/logs/logger.ts","../src/i18n-config/validation.ts","../src/i18n-config/I18nConfig.ts","../src/i18n-config/singleton-operations.ts","../src/utils/extractVariables.ts","../src/translation-functions/utils/messages.ts","../src/translation-functions/utils/formatMessage.ts","../src/translation-functions/utils/interpolation/interpolateIcuMessage.ts","../src/translation-functions/utils/interpolation/interpolateStringMessage.ts","../src/translation-functions/utils/interpolation/interpolateMessage.ts","../src/translation-functions/internal/helpers.ts","../src/condition-store/createConditionStoreSingleton.ts","../src/condition-store/singleton-operations.ts","../src/helpers/locale.ts","../src/utils/hashMessage.ts","../src/translation-functions/msg/decodeOptions.ts","../src/translation-functions/utils/isEncodedTranslationOptions.ts","../src/helpers/versionId.ts"],"sourcesContent":["export type GeneralTranslationLogLevel = string | undefined;\n\ntype LogLevelEnvironment = {\n _GENERALTRANSLATION_LOG_LEVEL?: string;\n};\n\nconst debugLogLevel = 'DEBUG';\n\nexport function getGeneralTranslationLogLevel(): GeneralTranslationLogLevel {\n const processLogLevel = readProcessEnvLogLevel();\n if (processLogLevel !== undefined) {\n return processLogLevel;\n }\n\n return readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: LogLevelEnvironment;\n }\n ).env?._GENERALTRANSLATION_LOG_LEVEL\n );\n}\n\nexport function isDebugLogLevel(logLevel: GeneralTranslationLogLevel): boolean {\n return logLevel?.toUpperCase() === debugLogLevel;\n}\n\nfunction readProcessEnvLogLevel(): GeneralTranslationLogLevel {\n if (typeof process !== 'object') {\n return undefined;\n }\n return process.env?._GENERALTRANSLATION_LOG_LEVEL;\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n} from '../logs/logLevel';\n\n/**\n * Shared global registry stored on `globalThis.__generaltranslation`. Each\n * package namespace (e.g. `i18n`, `reactCore`) owns a bag of singleton slots.\n */\ntype SingletonRegistry = Record<string, Record<string, unknown> | undefined>;\n\ntype GlobalWithRegistry = {\n __generaltranslation?: SingletonRegistry;\n};\n\ntype DebugLoggingConfig = {\n isDebugLoggingEnabled: () => boolean;\n};\n\nfunction getNamespace(namespace: string): Record<string, unknown> {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation[namespace] ??= {};\n return globalObj.__generaltranslation[namespace]!;\n}\n\nfunction getExistingNamespace(\n namespace: string\n): Record<string, unknown> | undefined {\n const globalObj = globalThis as unknown as GlobalWithRegistry;\n return globalObj.__generaltranslation?.[namespace];\n}\n\nexport type GlobalSingleton<T> = {\n get: () => T;\n set: (next: T) => void;\n isInitialized: () => boolean;\n};\n\n/**\n * Creates a global singleton backed by `globalThis.__generaltranslation`.\n *\n * Centralizes the global-registry plumbing and overwrite warning shared by the\n * i18nConfig, i18nCache, i18nStore, and conditionStore singletons.\n *\n * @param namespace - The package namespace bag (e.g. `i18n`, `reactCore`).\n * @param key - The slot within the namespace and the name used in the warning.\n * @param source - Diagnostic source for the overwrite warning.\n * @param notInitialized - Lazily builds the error thrown when read before set.\n */\nexport function createGlobalSingleton<T>({\n namespace,\n key,\n source,\n notInitialized,\n}: {\n namespace: string;\n key: string;\n source: string;\n notInitialized: () => string | Error;\n}): GlobalSingleton<T> {\n function get(): T {\n const value = getNamespace(namespace)[key];\n if (value === undefined || value === null) {\n const error = notInitialized();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n return value as T;\n }\n\n function set(next: T): void {\n const ns = getNamespace(namespace);\n if (ns[key] !== undefined && ns[key] !== next) {\n if (shouldLogDebugWarnings()) {\n console.warn(\n createDiagnosticMessage({\n source,\n severity: 'Warning',\n whatHappened: `Global ${key} singleton instance was already initialized`,\n })\n );\n }\n return;\n }\n ns[key] = next as unknown;\n }\n\n function isInitialized(): boolean {\n const value = getNamespace(namespace)[key];\n return value !== undefined && value !== null;\n }\n\n return { get, set, isInitialized };\n}\n\nfunction shouldLogDebugWarnings(): boolean {\n const config = getExistingNamespace('i18n')?.i18nConfig;\n if (hasDebugLoggingConfig(config)) {\n return config.isDebugLoggingEnabled();\n }\n return isDebugLogLevel(getGeneralTranslationLogLevel());\n}\n\nfunction hasDebugLoggingConfig(value: unknown): value is DebugLoggingConfig {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<DebugLoggingConfig>).isDebugLoggingEnabled ===\n 'function'\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nCache } from './I18nCache';\nimport { Translation } from './translations-manager/utils/types/translation-data';\n\nconst i18nCacheSingleton = createGlobalSingleton<I18nCache>({\n namespace: 'i18n',\n key: 'i18nCache',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nCache before it has been initialized',\n why: 'the internal I18nCache singleton is unavailable',\n fix: 'Initialize GT before accessing I18nCache (call initializeGT() from your GT framework package).',\n }),\n});\n\n/**\n * Get the singleton instance of I18nCache\n * @returns The singleton instance of I18nCache\n * @template U - The type of the translation that will be cached\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function getI18nCache<U extends Translation = Translation>():\n | I18nCache<U>\n | I18nCache<Translation> {\n return i18nCacheSingleton.get();\n}\n\n/**\n * Configure the singleton instance of I18nCache\n * @param config - The configuration for the I18nCache\n *\n * Wrapper libraries will export a configure function that will call this function.\n *\n * Note: should not be consumed by gt-react, consumers should use a wrapper\n */\nexport function setI18nCache<TranslationValue extends Translation>(\n i18nCacheInstance: I18nCache<TranslationValue>\n): void {\n i18nCacheSingleton.set(i18nCacheInstance as unknown as I18nCache);\n}\n","import { TranslationsLoader } from '../translations-manager/translations-loaders/types';\nimport { defaultCacheUrl } from 'generaltranslation/internal';\n\n/**\n * Loader translations type\n * - GT_REMOTE: use the default remote store URL {@link defaultCacheUrl}\n * - REMOTE: use a custom remote store URL\n * - CUSTOM: use a custom translations loader\n * - DISABLED: no translations loading\n */\nexport enum LoadTranslationsType {\n GT_REMOTE = 'gt-remote',\n REMOTE = 'remote',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the load translations type\n *\n * cacheUrl = null means disabled\n */\nexport function getLoadTranslationsType(config: {\n projectId?: string;\n cacheUrl?: string | null;\n loadTranslations?: TranslationsLoader;\n}): LoadTranslationsType {\n if (config.loadTranslations) {\n return LoadTranslationsType.CUSTOM;\n } else if (\n (config.cacheUrl === undefined || config.cacheUrl === defaultCacheUrl) &&\n config.projectId\n ) {\n return LoadTranslationsType.GT_REMOTE;\n } else if (config.cacheUrl) {\n return LoadTranslationsType.REMOTE;\n } else {\n return LoadTranslationsType.DISABLED;\n }\n}\n","import { defaultRuntimeApiUrl } from 'generaltranslation/internal';\n\n/**\n * Runtime API translation type\n * - GT: use the default runtime API URL {@link defaultRuntimeApiUrl}\n * - CUSTOM: use a custom runtime API URL\n * - DISABLED: no runtime API translation\n */\nexport enum TranslationApiType {\n GT = 'gt',\n CUSTOM = 'custom',\n DISABLED = 'disabled',\n}\n\n/**\n * Based on the configurtion return the runtime translation type\n * @param params - The parameters to validate\n * @returns The runtime translation type\n */\nexport function getTranslationApiType(params: {\n projectId?: string;\n devApiKey?: string;\n apiKey?: string;\n runtimeUrl?: string | null;\n}): TranslationApiType {\n const usesDefaultRuntimeUrl =\n params.runtimeUrl === undefined ||\n params.runtimeUrl === defaultRuntimeApiUrl;\n\n if (\n usesDefaultRuntimeUrl &&\n params.projectId &&\n (params.devApiKey || params.apiKey)\n ) {\n return TranslationApiType.GT;\n } else if (params.runtimeUrl && !usesDefaultRuntimeUrl) {\n return TranslationApiType.CUSTOM;\n } else {\n return TranslationApiType.DISABLED;\n }\n}\n","export type RuntimeEnvironment = {\n DEV?: boolean;\n MODE?: string;\n NODE_ENV?: string;\n};\n\nexport function getRuntimeEnvironment(): 'development' | 'production' {\n // We have to explicitly check `process.env.NODE_ENV` because it often gets string-replaced by bundler.\n // Destructuring or checking via other means may not work as expected.\n if (typeof process === 'object' && process.env?.NODE_ENV === 'development') {\n return 'development';\n }\n\n const importMetaMode = readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.MODE\n );\n if (importMetaMode) {\n return importMetaMode === 'development' ? 'development' : 'production';\n }\n if (\n readImportMetaEnv(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnvironment;\n }\n ).env?.DEV\n ) === true\n ) {\n return 'development';\n }\n\n return 'production';\n}\n\nfunction readImportMetaEnv<T>(readValue: () => T | undefined): T | undefined {\n try {\n return readValue();\n } catch {\n return undefined;\n }\n}\n","export default {\n warn(message: string) {\n console.warn(message);\n },\n\n error(message: string) {\n console.error(message);\n },\n\n info(message: string) {\n // eslint-disable-next-line no-console\n console.info(message);\n },\n\n debug(message: string) {\n // eslint-disable-next-line no-console\n console.debug(message);\n },\n};\n","import { isValidLocale } from '@generaltranslation/format';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport logger from '../logs/logger';\nimport type { I18nConfigParams } from './I18nConfig';\n\nexport function validateI18nConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): void {\n if (!gtServicesEnabled) {\n return;\n }\n\n const invalidLocales = getInvalidLocales(params);\n const invalidCustomMappingLocales = getInvalidCustomMappingLocales(params);\n const invalidLocaleConfig = [\n ...invalidLocales,\n ...invalidCustomMappingLocales,\n ];\n\n invalidLocaleConfig.forEach((locale) => {\n logger.error(`I18nConfig: ${getInvalidLocaleMessage(locale)}`);\n });\n\n if (invalidLocaleConfig.length > 0) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Invalid I18nConfig locale configuration',\n details: invalidLocaleConfig.map(\n (locale) => `Invalid locale: ${locale}`\n ),\n fix: 'Use valid BCP 47 locale codes or add custom mappings.',\n })\n );\n }\n}\n\nfunction getInvalidLocales({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams): string[] {\n const localesToValidate = new Set([\n ...(defaultLocale ? [defaultLocale] : []),\n ...(locales || []),\n ]);\n\n return Array.from(localesToValidate).filter(\n (locale) => !isValidLocale(locale, customMapping)\n );\n}\n\nfunction getInvalidCustomMappingLocales({\n customMapping,\n}: I18nConfigParams): string[] {\n return Object.values(customMapping || {}).flatMap((value) => {\n const locale = typeof value === 'string' ? value : value.code;\n return locale && !isValidLocale(locale) ? [locale] : [];\n });\n}\n\nfunction getInvalidLocaleMessage(locale: string): string {\n return createDiagnosticMessage({\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n}\n","import {\n LocaleConfig,\n type LocaleConfigConstructorParams,\n} from '@generaltranslation/format';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { GTRuntime } from 'generaltranslation/runtime';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { GTConfig } from '../config/types';\nimport {\n getLoadTranslationsType,\n LoadTranslationsType,\n} from '../i18n-cache/utils/getLoadTranslationsType';\nimport {\n getTranslationApiType,\n TranslationApiType,\n} from '../i18n-cache/utils/getTranslationApiType';\nimport {\n getGeneralTranslationLogLevel,\n isDebugLogLevel,\n type GeneralTranslationLogLevel,\n} from '../logs/logLevel';\nimport { getRuntimeEnvironment } from '../utils/getRuntimeEnvironment';\nimport { validateI18nConfigParams } from './validation';\n\nexport type I18nConfigParams = Pick<\n GTConfig,\n | 'defaultLocale'\n | 'locales'\n | 'customMapping'\n | 'projectId'\n | 'devApiKey'\n | 'apiKey'\n | 'cacheUrl'\n | 'runtimeUrl'\n | '_disableDevHotReload'\n>;\n\ntype RuntimeConfig = Pick<\n I18nConfigParams,\n 'projectId' | 'devApiKey' | 'apiKey' | 'runtimeUrl' | '_disableDevHotReload'\n>;\n\nexport type LocaleCandidates = string | string[] | undefined;\n\nexport class I18nConfig extends LocaleConfig {\n private runtimeConfig: RuntimeConfig;\n private gtServicesEnabled: boolean;\n private logLevel: GeneralTranslationLogLevel;\n\n constructor(params: I18nConfigParams = {}) {\n const gtServicesEnabled = resolveGTServicesEnabled(params);\n super(getLocaleConfigParams(params, gtServicesEnabled));\n this.runtimeConfig = {\n projectId: params.projectId,\n devApiKey: params.devApiKey,\n apiKey: params.apiKey,\n runtimeUrl: params.runtimeUrl,\n _disableDevHotReload: params._disableDevHotReload,\n };\n this.gtServicesEnabled = gtServicesEnabled;\n this.logLevel = getGeneralTranslationLogLevel();\n }\n\n getDefaultLocale(): string {\n return this.defaultLocale;\n }\n\n getLocales(): string[] {\n return this.locales;\n }\n\n getCustomMapping(): CustomMapping {\n return this.customMapping || {};\n }\n\n getProjectId(): string | undefined {\n return this.runtimeConfig.projectId;\n }\n\n /**\n * Get a GT instance bound to the resolved target locale. When omitted, the\n * instance is locale agnostic.\n *\n * TODO: keep a cache to avoid creating new instances unnecessarily.\n */\n getGTClass(locale?: string): GTRuntime {\n return this.getGTClassClean(\n locale ? this.resolveLocale(locale) : undefined\n );\n }\n\n determineLocale(\n locales: LocaleCandidates,\n approvedLocales: string[] = this.locales\n ): string | undefined {\n if (locales == null || (Array.isArray(locales) && locales.length === 0)) {\n return undefined;\n }\n return super.determineLocale(locales, approvedLocales);\n }\n\n determineSupportedLocale(\n candidates: LocaleCandidates,\n config?: I18nConfigParams\n ): string | undefined {\n return this.determineSupportedLocaleWithConfig(\n candidates,\n this.getLocaleConfig(config)\n );\n }\n\n resolveSupportedLocale(\n candidates?: LocaleCandidates,\n config?: I18nConfigParams\n ): string {\n const localeConfig = this.getLocaleConfig(config);\n return (\n this.determineSupportedLocaleWithConfig(candidates, localeConfig) ||\n localeConfig.defaultLocale\n );\n }\n\n resolveLocale(locale: string): string {\n const resolvedLocale = this.determineSupportedLocale(locale);\n if (!this.isValidLocale(locale) || !resolvedLocale) {\n throw new Error(\n `Locale \"${locale}\" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`\n );\n }\n return resolvedLocale;\n }\n\n /**\n * Returns true when development hot reload runtime translation requests can run.\n */\n isDevHotReloadEnabled(): boolean {\n return (\n !this.runtimeConfig._disableDevHotReload &&\n !!this.runtimeConfig.devApiKey &&\n !!this.runtimeConfig.projectId &&\n this.runtimeConfig.runtimeUrl !== null &&\n this.runtimeConfig.runtimeUrl !== '' &&\n getRuntimeEnvironment() === 'development'\n );\n }\n\n isGTServicesEnabled(): boolean {\n return this.gtServicesEnabled;\n }\n\n isDebugLoggingEnabled(): boolean {\n return isDebugLogLevel(this.logLevel);\n }\n\n /**\n * Create a GT instance without resolving the target locale first.\n */\n private getGTClassClean(locale?: string) {\n return new GTRuntime({\n sourceLocale: this.getDefaultLocale(),\n targetLocale: locale,\n // GT validates approved locales before constructing its LocaleConfig, so\n // pass canonical locales here while preserving alias target locales.\n locales: Array.from(\n new Set(\n this.getLocales().map((locale) => this.resolveCanonicalLocale(locale))\n )\n ),\n customMapping: this.getCustomMapping(),\n projectId: this.runtimeConfig.projectId,\n baseUrl: this.runtimeConfig.runtimeUrl || undefined,\n apiKey: this.runtimeConfig.apiKey,\n devApiKey: this.runtimeConfig.devApiKey,\n });\n }\n\n private getLocaleConfig(config?: I18nConfigParams): LocaleConfig {\n if (!config || !hasI18nConfigParams(config)) {\n return this;\n }\n return new LocaleConfig(getLocaleResolverConfigParams(config));\n }\n\n private determineSupportedLocaleWithConfig(\n candidates: LocaleCandidates,\n localeConfig: LocaleConfig\n ): string | undefined {\n if (\n candidates == null ||\n (Array.isArray(candidates) && candidates.length === 0)\n ) {\n return undefined;\n }\n return localeConfig.determineLocale(candidates);\n }\n}\n\nfunction getLocaleConfigParams(\n params: I18nConfigParams,\n gtServicesEnabled: boolean\n): LocaleConfigConstructorParams {\n const {\n defaultLocale = libraryDefaultLocale,\n locales = [defaultLocale],\n customMapping,\n } = params;\n\n validateI18nConfigParams(\n {\n ...params,\n defaultLocale,\n locales,\n customMapping,\n },\n gtServicesEnabled\n );\n\n return {\n defaultLocale,\n locales: Array.from(new Set([defaultLocale, ...locales])),\n customMapping: customMapping || {},\n };\n}\n\nfunction getLocaleResolverConfigParams({\n defaultLocale = libraryDefaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams = {}): LocaleConfigConstructorParams {\n return {\n defaultLocale,\n locales: locales?.length ? locales : [defaultLocale],\n customMapping: customMapping || {},\n };\n}\n\nfunction hasI18nConfigParams(config: I18nConfigParams): boolean {\n return (\n config.defaultLocale !== undefined ||\n config.locales !== undefined ||\n config.customMapping !== undefined\n );\n}\n\nfunction resolveGTServicesEnabled(config: I18nConfigParams): boolean {\n return (\n getLoadTranslationsType(config) === LoadTranslationsType.GT_REMOTE ||\n getTranslationApiType(config) === TranslationApiType.GT\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport { I18nConfig, type I18nConfigParams } from './I18nConfig';\n\nconst i18nConfigSingleton = createGlobalSingleton<I18nConfig>({\n namespace: 'i18n',\n key: 'i18nConfig',\n source: 'gt-i18n',\n notInitialized: () =>\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read I18nConfig before it has been initialized',\n why: 'the internal I18nConfig singleton is unavailable',\n fix: 'Initialize GT before reading locale config (call initializeGT() from your GT framework package).',\n }),\n});\n\nexport const getI18nConfig = i18nConfigSingleton.get;\nexport const setI18nConfig = i18nConfigSingleton.set;\nexport const isI18nConfigInitialized = i18nConfigSingleton.isInitialized;\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {}\n): I18nConfig {\n const nextI18nConfig = new I18nConfig(params);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n","import { TranslationVariables } from '../translation-functions/types/options';\n\n/**\n * Given an object of options, returns an object with no gt-related options\n *\n * TODO: next major version, this should extract any sugar syntax options\n * TODO: next major version, options should be Record<string, string>\n */\nexport function extractVariables<T extends TranslationVariables>(\n options: T\n): TranslationVariables {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key]) =>\n key !== '$id' &&\n key !== '$context' &&\n key !== '$maxChars' &&\n key !== '$hash' && // this is already being done in @gt/react-core\n key !== '$_hash' &&\n key !== '$_source' &&\n key !== '$_fallback' &&\n key !== '$format' &&\n key !== '$locale' &&\n key !== '$requiresReview'\n )\n );\n}\n","export const createInterpolationFailureMessage = (message: string) =>\n `String interpolation failed for message: \"${message}\".`;\n","import type { StringFormat } from '@generaltranslation/format/types';\nimport logger from '../../logs/logger';\nimport { createInterpolationFailureMessage } from './messages';\nimport { formatMessage as _formatMessage } from '@generaltranslation/format';\n\n/**\n * Given an encoded message and variables, formats the message.\n * On error, the original encoded message is returned with a warning.\n * @param encodedMsg\n * @param variables\n * @returns\n */\nexport function formatMessage(\n encodedMsg: string,\n variables: Record<string, string>,\n locales?: string | string[],\n dataFormat?: StringFormat\n): string {\n try {\n return _formatMessage(encodedMsg, { variables, locales, dataFormat });\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n return encodedMsg;\n }\n}\n","import { extractVariables } from '../../../utils/extractVariables';\nimport { formatMessage } from '../formatMessage';\nimport {\n VAR_IDENTIFIER,\n extractVars,\n condenseVars,\n} from 'generaltranslation/internal';\nimport { formatCutoff } from '@generaltranslation/format';\nimport logger from '../../../logs/logger';\nimport { createInterpolationFailureMessage } from '../messages';\nimport type { TranslationOptions } from '../../types/options';\n\n/**\n * Applies string interpolation and cutoff formatting. Fallsback to the original message if interpolation fails.\n * @param {string} message - The message to interpolate.\n * @param {TranslationOptions} options - The options to interpolate.\n * @returns {string} - The interpolated message.\n */\nexport function interpolateIcuMessage<T extends string | null | undefined>(\n encodedMsg: T,\n options: TranslationOptions\n): T extends string ? string : T {\n // Return if the encoded message is null or undefined\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Get the source to use as a fallback\n const source = options.$_fallback;\n\n // Remove any gt related options\n const variables = extractVariables(options);\n\n try {\n // Extract declared variable values from the source/fallback\n const declaredVars = extractVars(source || '');\n\n // Condense indexed selects to arguments if declared vars exist\n const message = Object.keys(declaredVars).length\n ? condenseVars(encodedMsg)\n : encodedMsg;\n\n // Interpolate the message\n const interpolatedMessage = formatMessage(\n message,\n {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n options.$locale,\n options.$format\n );\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(interpolatedMessage, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n } catch {\n logger.warn(createInterpolationFailureMessage(encodedMsg));\n\n // If formatting the translation failed and we have a fallback, try formatting the source instead\n if (options.$_fallback != null) {\n return interpolateIcuMessage(options.$_fallback, {\n ...options,\n $_fallback: undefined,\n }) as T extends string ? string : T;\n }\n\n // Apply cutoff formatting\n const cutoffMessage = formatCutoff(encodedMsg, {\n maxChars: options.$maxChars,\n });\n return cutoffMessage as T extends string ? string : T;\n }\n}\n","import { formatCutoff } from '@generaltranslation/format';\nimport { TranslationOptions } from '../../types/options';\n\n/**\n * String interpolation function\n */\nexport function interpolateStringMessage(\n encodedMsg: string,\n options: TranslationOptions\n): string {\n const cutoffMessage = formatCutoff(encodedMsg, {\n locales: options.$locale,\n maxChars: options.$maxChars,\n });\n return cutoffMessage;\n}\n","import {\n TranslationOptions,\n NormalizedLookupOptions,\n} from '../../types/options';\nimport { interpolateIcuMessage } from './interpolateIcuMessage';\nimport { interpolateStringMessage } from './interpolateStringMessage';\nimport type { StringFormat } from '@generaltranslation/format/types';\n\n/**\n * Options for string interpolation\n * @internal\n */\nexport type InterpolationOptions = NormalizedLookupOptions<StringFormat>;\n\n/**\n * Interpolation router function for all {@link StringFormat} types\n */\nexport function interpolateMessage({\n source,\n target,\n options,\n sourceLocale,\n}: {\n source: string;\n target?: string;\n options: InterpolationOptions;\n sourceLocale?: string;\n}): string {\n // Format translation\n if (target != null) {\n return routeInterpolation(target, {\n $_fallback: source,\n ...options,\n });\n }\n\n // Format source\n // Missing translations format the source with the source locale, not the target locale.\n // TODO: Consider formatting dates, numbers, etc. with the target locale while keeping plurals in the source locale.\n return routeInterpolation(source, getSourceOptions(options, sourceLocale));\n}\n\n// ----- HELPERS ----- //\n\n/**\n * Route to appropriate formatting function\n */\nfunction routeInterpolation(\n content: string,\n options: TranslationOptions\n): string {\n switch (options.$format ?? 'STRING') {\n case 'ICU':\n return interpolateIcuMessage(content, options);\n case 'I18NEXT':\n case 'STRING':\n return interpolateStringMessage(content, options);\n default:\n // e.g. $format: 'NONE'\n return content;\n }\n}\n\nfunction getSourceOptions(\n options: InterpolationOptions,\n sourceLocale?: string\n): InterpolationOptions {\n if (!sourceLocale) return options;\n return {\n ...options,\n $locale: sourceLocale,\n };\n}\n","import { getI18nCache } from '../../i18n-cache/singleton-operations';\nimport { getI18nConfig } from '../../i18n-config/singleton-operations';\nimport { NormalizedLookupOptions, LookupOptionsFor } from '../types/options';\nimport { interpolateMessage } from '../utils/interpolation/interpolateMessage';\nimport type {\n DataFormat,\n JsxChildren,\n StringContent,\n StringFormat,\n} from '@generaltranslation/format/types';\n\n// ----- JSX TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n */\nexport function resolveJsx(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation;\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveJsxWithFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): JsxChildren {\n const translation = resolveJsx(locale, content, options);\n return translation ?? content;\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveJsxWithRuntimeFallback(\n locale: string,\n content: JsxChildren,\n options: LookupOptionsFor<'JSX'> = {}\n): Promise<JsxChildren> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'JSX');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return translation ?? content;\n}\n\n// ----- STRING CONTENT TRANSLATION FUNCTIONS ----- //\n\n/**\n * Just do a simple lookup of the translation\n * And interpolate\n */\nexport function resolveStringContent(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent | undefined {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n if (translation == null) return undefined;\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to source\n */\nexport function resolveStringContentWithFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): StringContent {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = i18nCache.lookupTranslation(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation\n * fallback to runtime translate\n * Fallback to source\n */\nexport async function resolveStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<StringContent> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n const translation = await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n return interpolateMessage({\n source: content,\n target: translation,\n options: lookupOptions,\n sourceLocale: getI18nConfig().getDefaultLocale(),\n });\n}\n\n/**\n * Lookup translation, fallback to runtime translate, without interpolating.\n * For prefetch calls whose result is discarded — variable values only exist\n * at the render-time call site, so interpolating here would fail for any\n * message with placeholders.\n */\nexport async function prefetchStringContentWithRuntimeFallback(\n locale: string,\n content: StringContent,\n options: LookupOptionsFor<StringFormat> = {}\n): Promise<void> {\n const i18nCache = getI18nCache();\n const lookupOptions = createLookupOptions(locale, options, 'STRING');\n await i18nCache.lookupTranslationWithFallback(\n lookupOptions.$locale,\n content,\n lookupOptions\n );\n}\n\n/**\n * Add the default format to caller-provided lookup options.\n */\nexport function createLookupOptions<T extends DataFormat>(\n locale: string,\n options: LookupOptionsFor<T>,\n defaultFormat: T\n): NormalizedLookupOptions<T> {\n return {\n ...options,\n $format: (options.$format ?? defaultFormat) as T,\n $locale: locale,\n };\n}\n","import { createGlobalSingleton } from '../globals/createGlobalSingleton';\nimport type {\n AsyncReadonlyConditionStoreInterface,\n ReadonlyConditionStoreInterface,\n} from '../i18n-cache/types';\n\nexport function createConditionStoreSingleton<\n T extends\n | ReadonlyConditionStoreInterface\n | AsyncReadonlyConditionStoreInterface,\n>(notInitializedMessage: string) {\n const singleton = createGlobalSingleton<T>({\n namespace: 'i18n',\n key: 'conditionStore',\n source: 'gt-i18n',\n notInitialized: () => notInitializedMessage,\n });\n\n return {\n getConditionStore: singleton.get,\n setConditionStore: singleton.set,\n isConditionStoreInitialized: singleton.isInitialized,\n };\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createConditionStoreSingleton } from './createConditionStoreSingleton';\nimport { WritableConditionStore } from './WritableConditionStore';\n\nexport const {\n getConditionStore: getWritableConditionStore,\n setConditionStore: setWritableConditionStore,\n} = createConditionStoreSingleton<WritableConditionStore>(\n createDiagnosticMessage({\n source: 'gt-i18n',\n severity: 'Error',\n whatHappened: 'Cannot read the locale before GT has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Initialize GT before calling translation functions (e.g. call initializeGT() from your GT framework package).',\n })\n);\n","import { getWritableConditionStore } from '../condition-store/singleton-operations';\nimport { getI18nConfig } from '../i18n-config/singleton-operations';\n\n/**\n * Get the current locale\n * @returns The current locale\n *\n * @example\n * const locale = getLocale();\n * console.log(locale); // 'en-US'\n */\nexport function getLocale() {\n return getWritableConditionStore().getLocale();\n}\n\n/**\n * Get the current region\n * @returns The current region, or undefined if no region is set\n *\n * @example\n * const region = getRegion();\n * console.log(region); // 'US' or undefined\n */\nexport function getRegion() {\n return getWritableConditionStore().getRegion();\n}\n\n/**\n * Get the configured locales\n * @returns The configured locales\n *\n * @example\n * const locales = getLocales();\n * console.log(locales); // ['en-US', 'es-ES']\n */\nexport function getLocales() {\n return getI18nConfig().getLocales();\n}\n\n/**\n * Get the default locale\n * @returns The default locale\n *\n * @example\n * const defaultLocale = getDefaultLocale();\n * console.log(defaultLocale); // 'en-US'\n */\nexport function getDefaultLocale() {\n return getI18nConfig().getDefaultLocale();\n}\n\n/**\n * Get the locale properties\n * @param {string} [locale] - The locale to get the properties for. When not provided, uses the current locale.\n * @returns The locale properties\n *\n * @example\n * const localeProperties = getLocaleProperties();\n *\n * @example\n * const localeProperties = getLocaleProperties('en-US');\n */\nexport function getLocaleProperties(locale = getLocale()) {\n return getI18nConfig().getLocaleProperties(locale);\n}\n\n/**\n * Resolve a locale to its canonical locale code using the configured custom mapping.\n * @param {string} locale - The locale to resolve.\n * @returns The canonical locale code.\n *\n * @example\n * const canonicalLocale = resolveCanonicalLocale('brand-french');\n * console.log(canonicalLocale); // 'fr-FR'\n */\nexport function resolveCanonicalLocale(locale: string) {\n return getI18nConfig().resolveCanonicalLocale(locale);\n}\n","import { hashSource } from 'generaltranslation/id';\nimport { indexVars } from 'generaltranslation/internal';\nimport { LookupOptions } from '../translation-functions/types/options';\nimport { Translation } from '../types';\nimport type { IcuMessage } from '@generaltranslation/format/types';\n\n/**\n * Hash a message string\n */\nexport function hashMessage<T extends Translation>(\n message: T,\n options: LookupOptions\n): string {\n const metadataOptions = options as {\n $_hash?: string;\n $context?: string;\n $id?: string;\n $maxChars?: number;\n $requiresReview?: boolean;\n };\n if (metadataOptions.$_hash != null) {\n return metadataOptions.$_hash;\n }\n\n return hashSource({\n source:\n options.$format === 'ICU' ? indexVars(message as IcuMessage) : message,\n ...(metadataOptions.$context && { context: metadataOptions.$context }),\n ...(metadataOptions.$maxChars != null && {\n maxChars: Math.abs(metadataOptions.$maxChars),\n }),\n ...(metadataOptions.$requiresReview === true && { requiresReview: true }),\n dataFormat: options.$format,\n });\n}\n","import { decode } from 'generaltranslation/internal';\nimport type { TranslationOptions } from '../types/options';\n\n/**\n * Decodes the options from an encoded message.\n * @param encodedMsg The message to decode.\n * @returns The decoded options.\n */\nexport function decodeOptions(encodedMsg: string): TranslationOptions | null {\n if (encodedMsg.lastIndexOf(':') === -1) {\n return null;\n }\n\n // Extract encoded options\n const optionsEncoding = encodedMsg.slice(encodedMsg.lastIndexOf(':') + 1);\n\n try {\n // Parse options\n const options = JSON.parse(decode(optionsEncoding));\n return options;\n } catch {\n return null;\n }\n}\n","import { EncodedTranslationOptions } from '../types/options';\n\n/**\n * Given a decoded options object, validate that includes required decoded options\n * These required options are added by msg() during the encoding process.\n */\nexport function isEncodedTranslationOptions(\n decodedOptions: Record<string, unknown> // TODO: next major version, this should be Record<string, string>\n): decodedOptions is EncodedTranslationOptions {\n return !!(decodedOptions.$_hash && decodedOptions.$_source);\n}\n","import { getI18nCache } from '../i18n-cache/singleton-operations';\n\n/**\n * Get the version ID for the current source\n * @returns The version ID, if set\n *\n * @example\n * const versionId = getVersionId();\n * console.log(versionId); // 'abc123'\n */\nexport function getVersionId() {\n const i18nCache = getI18nCache();\n return i18nCache.getVersionId();\n}\n"],"mappings":";;;;;AAMA,MAAM,gBAAgB;AAEtB,SAAgB,gCAA4D;CAC1E,MAAM,kBAAkB,wBAAwB;AAChD,KAAI,oBAAoB,KAAA,EACtB,QAAO;AAGT,QAAOA,0BAGD,OAAO,KAGP,KAAK,8BACV;;AAGH,SAAgB,gBAAgB,UAA+C;AAC7E,QAAO,UAAU,aAAa,KAAK;;AAGrC,SAAS,yBAAqD;AAC5D,KAAI,OAAO,YAAY,SACrB;AAEF,QAAO,QAAQ,KAAK;;AAGtB,SAASA,oBAAqB,WAA+C;AAC3E,KAAI;AACF,SAAO,WAAW;SACZ;AACN;;;;;ACnBJ,SAAS,aAAa,WAA4C;CAChE,MAAM,YAAY;AAClB,WAAU,yBAAyB,EAAE;AAErC,WAAU,qBAAqB,eAAe,EAAE;AAChD,QAAO,UAAU,qBAAqB;;AAGxC,SAAS,qBACP,WACqC;AAErC,QAAOC,WAAU,uBAAuB;;;;;;;;;;;;;AAoB1C,SAAgB,sBAAyB,EACvC,WACA,KACA,QACA,kBAMqB;CACrB,SAAS,MAAS;EAChB,MAAM,QAAQ,aAAa,UAAU,CAAC;AACtC,MAAI,UAAU,KAAA,KAAa,UAAU,MAAM;GACzC,MAAM,QAAQ,gBAAgB;AAC9B,SAAM,OAAO,UAAU,WAAW,IAAI,MAAM,MAAM,GAAG;;AAEvD,SAAO;;C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