@intlayer/use-intl 9.0.0-canary.10

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.
Files changed (106) hide show
  1. package/README.md +330 -0
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/cjs/client/IntlProvider.cjs +30 -0
  4. package/dist/cjs/client/IntlProvider.cjs.map +1 -0
  5. package/dist/cjs/client/helpers.cjs +49 -0
  6. package/dist/cjs/client/helpers.cjs.map +1 -0
  7. package/dist/cjs/client/index.cjs +27 -0
  8. package/dist/cjs/client/index.cjs.map +1 -0
  9. package/dist/cjs/client/useLocale.cjs +20 -0
  10. package/dist/cjs/client/useLocale.cjs.map +1 -0
  11. package/dist/cjs/client/useTranslations.cjs +39 -0
  12. package/dist/cjs/client/useTranslations.cjs.map +1 -0
  13. package/dist/cjs/core/createFormatter.cjs +23 -0
  14. package/dist/cjs/core/createFormatter.cjs.map +1 -0
  15. package/dist/cjs/core/createTranslator.cjs +30 -0
  16. package/dist/cjs/core/createTranslator.cjs.map +1 -0
  17. package/dist/cjs/core/errors.cjs +42 -0
  18. package/dist/cjs/core/errors.cjs.map +1 -0
  19. package/dist/cjs/core/hasLocale.cjs +23 -0
  20. package/dist/cjs/core/hasLocale.cjs.map +1 -0
  21. package/dist/cjs/core/index.cjs +13 -0
  22. package/dist/cjs/core/initializeConfig.cjs +25 -0
  23. package/dist/cjs/core/initializeConfig.cjs.map +1 -0
  24. package/dist/cjs/core/types.cjs +0 -0
  25. package/dist/cjs/index.cjs +30 -0
  26. package/dist/cjs/plugin/index.cjs +80 -0
  27. package/dist/cjs/plugin/index.cjs.map +1 -0
  28. package/dist/cjs/shared/intlFormatter.cjs +63 -0
  29. package/dist/cjs/shared/intlFormatter.cjs.map +1 -0
  30. package/dist/cjs/shared/namespaceTranslator.cjs +122 -0
  31. package/dist/cjs/shared/namespaceTranslator.cjs.map +1 -0
  32. package/dist/cjs/shared/translateFunctionTypes.cjs +0 -0
  33. package/dist/cjs/useDictionary.cjs +37 -0
  34. package/dist/cjs/useDictionary.cjs.map +1 -0
  35. package/dist/cjs/useDictionaryDynamic.cjs +31 -0
  36. package/dist/cjs/useDictionaryDynamic.cjs.map +1 -0
  37. package/dist/esm/client/IntlProvider.mjs +28 -0
  38. package/dist/esm/client/IntlProvider.mjs.map +1 -0
  39. package/dist/esm/client/helpers.mjs +44 -0
  40. package/dist/esm/client/helpers.mjs.map +1 -0
  41. package/dist/esm/client/index.mjs +17 -0
  42. package/dist/esm/client/index.mjs.map +1 -0
  43. package/dist/esm/client/useLocale.mjs +18 -0
  44. package/dist/esm/client/useLocale.mjs.map +1 -0
  45. package/dist/esm/client/useTranslations.mjs +37 -0
  46. package/dist/esm/client/useTranslations.mjs.map +1 -0
  47. package/dist/esm/core/createFormatter.mjs +22 -0
  48. package/dist/esm/core/createFormatter.mjs.map +1 -0
  49. package/dist/esm/core/createTranslator.mjs +28 -0
  50. package/dist/esm/core/createTranslator.mjs.map +1 -0
  51. package/dist/esm/core/errors.mjs +39 -0
  52. package/dist/esm/core/errors.mjs.map +1 -0
  53. package/dist/esm/core/hasLocale.mjs +21 -0
  54. package/dist/esm/core/hasLocale.mjs.map +1 -0
  55. package/dist/esm/core/index.mjs +7 -0
  56. package/dist/esm/core/initializeConfig.mjs +23 -0
  57. package/dist/esm/core/initializeConfig.mjs.map +1 -0
  58. package/dist/esm/core/types.mjs +0 -0
  59. package/dist/esm/index.mjs +14 -0
  60. package/dist/esm/plugin/index.mjs +76 -0
  61. package/dist/esm/plugin/index.mjs.map +1 -0
  62. package/dist/esm/shared/intlFormatter.mjs +61 -0
  63. package/dist/esm/shared/intlFormatter.mjs.map +1 -0
  64. package/dist/esm/shared/namespaceTranslator.mjs +129 -0
  65. package/dist/esm/shared/namespaceTranslator.mjs.map +1 -0
  66. package/dist/esm/shared/translateFunctionTypes.mjs +0 -0
  67. package/dist/esm/useDictionary.mjs +35 -0
  68. package/dist/esm/useDictionary.mjs.map +1 -0
  69. package/dist/esm/useDictionaryDynamic.mjs +29 -0
  70. package/dist/esm/useDictionaryDynamic.mjs.map +1 -0
  71. package/dist/types/client/IntlProvider.d.ts +29 -0
  72. package/dist/types/client/IntlProvider.d.ts.map +1 -0
  73. package/dist/types/client/helpers.d.ts +31 -0
  74. package/dist/types/client/helpers.d.ts.map +1 -0
  75. package/dist/types/client/index.d.ts +16 -0
  76. package/dist/types/client/index.d.ts.map +1 -0
  77. package/dist/types/client/useLocale.d.ts +12 -0
  78. package/dist/types/client/useLocale.d.ts.map +1 -0
  79. package/dist/types/client/useTranslations.d.ts +44 -0
  80. package/dist/types/client/useTranslations.d.ts.map +1 -0
  81. package/dist/types/core/createFormatter.d.ts +21 -0
  82. package/dist/types/core/createFormatter.d.ts.map +1 -0
  83. package/dist/types/core/createTranslator.d.ts +56 -0
  84. package/dist/types/core/createTranslator.d.ts.map +1 -0
  85. package/dist/types/core/errors.d.ts +31 -0
  86. package/dist/types/core/errors.d.ts.map +1 -0
  87. package/dist/types/core/hasLocale.d.ts +18 -0
  88. package/dist/types/core/hasLocale.d.ts.map +1 -0
  89. package/dist/types/core/index.d.ts +7 -0
  90. package/dist/types/core/initializeConfig.d.ts +14 -0
  91. package/dist/types/core/initializeConfig.d.ts.map +1 -0
  92. package/dist/types/core/types.d.ts +2 -0
  93. package/dist/types/index.d.ts +16 -0
  94. package/dist/types/plugin/index.d.ts +22 -0
  95. package/dist/types/plugin/index.d.ts.map +1 -0
  96. package/dist/types/shared/intlFormatter.d.ts +19 -0
  97. package/dist/types/shared/intlFormatter.d.ts.map +1 -0
  98. package/dist/types/shared/namespaceTranslator.d.ts +51 -0
  99. package/dist/types/shared/namespaceTranslator.d.ts.map +1 -0
  100. package/dist/types/shared/translateFunctionTypes.d.ts +34 -0
  101. package/dist/types/shared/translateFunctionTypes.d.ts.map +1 -0
  102. package/dist/types/useDictionary.d.ts +23 -0
  103. package/dist/types/useDictionary.d.ts.map +1 -0
  104. package/dist/types/useDictionaryDynamic.d.ts +18 -0
  105. package/dist/types/useDictionaryDynamic.d.ts.map +1 -0
  106. package/package.json +127 -0
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_shared_namespaceTranslator = require('../shared/namespaceTranslator.cjs');
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_config_colors = require("@intlayer/config/colors");
6
+ let _intlayer_config_logger = require("@intlayer/config/logger");
7
+
8
+ //#region src/core/createTranslator.ts
9
+ /**
10
+ * Drop-in for use-intl's `createTranslator`.
11
+ *
12
+ * Returns a translate function (with `rich`, `markup`, `raw`, `has`) that
13
+ * resolves messages from Intlayer's compiled dictionaries for the given
14
+ * `locale`. Messages support ICU MessageFormat syntax.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const t = createTranslator({ locale: 'en', namespace: 'about' });
19
+ * t('counter.label'); // ✓ typed
20
+ * t('items', { count: 3 }); // ICU plural
21
+ * ```
22
+ */
23
+ const createTranslator = (({ locale, namespace, messages: _messages }) => {
24
+ if (process.env.NODE_ENV === "development" && _messages !== void 0) (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("createTranslator", _intlayer_config_colors.CYAN)} do not pass the messages option with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`);
25
+ return require_shared_namespaceTranslator.createNamespaceTranslator(locale, namespace);
26
+ });
27
+
28
+ //#endregion
29
+ exports.createTranslator = createTranslator;
30
+ //# sourceMappingURL=createTranslator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTranslator.cjs","names":["CYAN","createNamespaceTranslator"],"sources":["../../../src/core/createTranslator.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { createNamespaceTranslator } from '../shared/namespaceTranslator';\nimport type {\n LooseTranslateFunction,\n TranslateFunction,\n} from '../shared/translateFunctionTypes';\n\n/**\n * Configuration accepted by {@link createTranslator}.\n *\n * Mirrors use-intl's `IntlConfig`, but `messages`, `formats`, `now`,\n * `timeZone`, `onError`, and `getMessageFallback` have no effect — Intlayer\n * resolves content from its own compiled dictionaries.\n */\nexport type CreateTranslatorConfig<N extends DictionaryKeys> = {\n /** The locale dictionaries are resolved for. */\n locale: LocalesValues;\n /** A bare dictionary key, or a nested `'dictionary.scope'` namespace. */\n namespace?: N | (string & {});\n /**\n * @deprecated has no use case with intlayer. Messages are loaded\n * automatically under the hood for bundle optimization reason.\n */\n messages?: never;\n} & Record<string, unknown>;\n\n/**\n * Overload set for {@link createTranslator}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching use-intl's scoped-namespace behaviour.\n * 3. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n */\ntype CreateTranslator = {\n <N extends DictionaryKeys>(\n config: CreateTranslatorConfig<N> & { namespace: N }\n ): TranslateFunction<N>;\n (\n config: CreateTranslatorConfig<DictionaryKeys> & {\n namespace: `${string}.${string}`;\n }\n ): LooseTranslateFunction;\n (config: CreateTranslatorConfig<DictionaryKeys>): LooseTranslateFunction;\n};\n\n/**\n * Drop-in for use-intl's `createTranslator`.\n *\n * Returns a translate function (with `rich`, `markup`, `raw`, `has`) that\n * resolves messages from Intlayer's compiled dictionaries for the given\n * `locale`. Messages support ICU MessageFormat syntax.\n *\n * @example\n * ```ts\n * const t = createTranslator({ locale: 'en', namespace: 'about' });\n * t('counter.label'); // ✓ typed\n * t('items', { count: 3 }); // ICU plural\n * ```\n */\nexport const createTranslator = (({\n locale,\n namespace,\n messages: _messages,\n}: CreateTranslatorConfig<DictionaryKeys>) => {\n if (process.env.NODE_ENV === 'development' && _messages !== undefined) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('createTranslator', CYAN)} do not pass the messages option with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n return createNamespaceTranslator(locale, namespace);\n}) as CreateTranslator;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,qBAAqB,EAChC,QACA,WACA,UAAU,gBACkC;AAC5C,KAAI,QAAQ,IAAI,aAAa,iBAAiB,cAAc,OAE1D,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,oBAAoBA,6BAAK,CAAC,iIACvC;AAGH,QAAOC,6DAA0B,QAAQ,UAAU"}
@@ -0,0 +1,42 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/core/errors.ts
4
+ /**
5
+ * Drop-in for use-intl's `IntlErrorCode` enum.
6
+ *
7
+ * Re-implemented locally (rather than re-exported) because `use-intl` is
8
+ * aliased to this package at build time, so importing its runtime value would
9
+ * be circular.
10
+ */
11
+ let IntlErrorCode = /* @__PURE__ */ function(IntlErrorCode) {
12
+ IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
13
+ IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
14
+ IntlErrorCode["ENVIRONMENT_FALLBACK"] = "ENVIRONMENT_FALLBACK";
15
+ IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
16
+ IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
17
+ IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
18
+ IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
19
+ return IntlErrorCode;
20
+ }({});
21
+ /**
22
+ * Drop-in for use-intl's `IntlError`.
23
+ *
24
+ * Carries the {@link IntlErrorCode} and the original message, matching
25
+ * use-intl's error shape so consumer `onError` handlers keep working.
26
+ */
27
+ var IntlError = class extends Error {
28
+ code;
29
+ originalMessage;
30
+ constructor(code, originalMessage) {
31
+ let message = code;
32
+ if (originalMessage) message += `: ${originalMessage}`;
33
+ super(message);
34
+ this.code = code;
35
+ if (originalMessage) this.originalMessage = originalMessage;
36
+ }
37
+ };
38
+
39
+ //#endregion
40
+ exports.IntlError = IntlError;
41
+ exports.IntlErrorCode = IntlErrorCode;
42
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../../../src/core/errors.ts"],"sourcesContent":["/**\n * Drop-in for use-intl's `IntlErrorCode` enum.\n *\n * Re-implemented locally (rather than re-exported) because `use-intl` is\n * aliased to this package at build time, so importing its runtime value would\n * be circular.\n */\nexport enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n ENVIRONMENT_FALLBACK = 'ENVIRONMENT_FALLBACK',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR',\n}\n\n/**\n * Drop-in for use-intl's `IntlError`.\n *\n * Carries the {@link IntlErrorCode} and the original message, matching\n * use-intl's error shape so consumer `onError` handlers keep working.\n */\nexport class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += `: ${originalMessage}`;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAOA,IAAY,gBAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;KACD;;;;;;;AAQD,IAAa,YAAb,cAA+B,MAAM;CACnC,AAAgB;CAChB,AAAgB;CAEhB,YAAY,MAAqB,iBAA0B;EACzD,IAAI,UAAkB;AACtB,MAAI,gBACF,YAAW,KAAK;AAElB,QAAM,QAAQ;AAEd,OAAK,OAAO;AACZ,MAAI,gBACF,MAAK,kBAAkB"}
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+
5
+ //#region src/core/hasLocale.ts
6
+ /**
7
+ * Drop-in for use-intl's `hasLocale`.
8
+ *
9
+ * Narrows a locale candidate to the given locales list. When the list is
10
+ * omitted, the locales configured in intlayer are used.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * if (hasLocale(['en', 'fr'], requested)) { … }
15
+ * ```
16
+ */
17
+ const hasLocale = ((locales, candidate) => {
18
+ return (locales ?? _intlayer_config_built.internationalization?.locales?.map(String) ?? []).includes(candidate);
19
+ });
20
+
21
+ //#endregion
22
+ exports.hasLocale = hasLocale;
23
+ //# sourceMappingURL=hasLocale.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasLocale.cjs","names":["internationalization"],"sources":["../../../src/core/hasLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { hasLocale as _hasLocale } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `hasLocale`.\n *\n * Narrows a locale candidate to the given locales list. When the list is\n * omitted, the locales configured in intlayer are used.\n *\n * @example\n * ```ts\n * if (hasLocale(['en', 'fr'], requested)) { … }\n * ```\n */\nexport const hasLocale: typeof _hasLocale = ((\n locales: readonly string[],\n candidate: unknown\n): boolean => {\n const availableLocales =\n locales ?? internationalization?.locales?.map(String) ?? [];\n return availableLocales.includes(candidate as string);\n}) as typeof _hasLocale;\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,cACX,SACA,cACY;AAGZ,SADE,WAAWA,6CAAsB,SAAS,IAAI,OAAO,IAAI,EAAE,EACrC,SAAS,UAAoB"}
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_core_createFormatter = require('./createFormatter.cjs');
3
+ const require_core_createTranslator = require('./createTranslator.cjs');
4
+ const require_core_errors = require('./errors.cjs');
5
+ const require_core_hasLocale = require('./hasLocale.cjs');
6
+ const require_core_initializeConfig = require('./initializeConfig.cjs');
7
+
8
+ exports.IntlError = require_core_errors.IntlError;
9
+ exports.IntlErrorCode = require_core_errors.IntlErrorCode;
10
+ exports.createFormatter = require_core_createFormatter.createFormatter;
11
+ exports.createTranslator = require_core_createTranslator.createTranslator;
12
+ exports.hasLocale = require_core_hasLocale.hasLocale;
13
+ exports.initializeConfig = require_core_initializeConfig.initializeConfig;
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/core/initializeConfig.ts
4
+ /**
5
+ * Drop-in for use-intl's `initializeConfig`.
6
+ *
7
+ * Enhances an incoming config with defaults. With intlayer, `messages` and
8
+ * `formats` are not consumed at runtime (content comes from compiled
9
+ * dictionaries) but the shape is preserved so callers keep type-checking.
10
+ */
11
+ const initializeConfig = ({ formats, getMessageFallback, messages, onError, ...rest }) => {
12
+ const finalOnError = onError ?? ((error) => error);
13
+ const finalGetMessageFallback = getMessageFallback ?? (({ key, namespace }) => [namespace, key].filter(Boolean).join("."));
14
+ return {
15
+ ...rest,
16
+ formats: formats || void 0,
17
+ messages: messages || void 0,
18
+ onError: finalOnError,
19
+ getMessageFallback: finalGetMessageFallback
20
+ };
21
+ };
22
+
23
+ //#endregion
24
+ exports.initializeConfig = initializeConfig;
25
+ //# sourceMappingURL=initializeConfig.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializeConfig.cjs","names":[],"sources":["../../../src/core/initializeConfig.ts"],"sourcesContent":["import type { initializeConfig as _initializeConfig } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `initializeConfig`.\n *\n * Enhances an incoming config with defaults. With intlayer, `messages` and\n * `formats` are not consumed at runtime (content comes from compiled\n * dictionaries) but the shape is preserved so callers keep type-checking.\n */\nexport const initializeConfig: typeof _initializeConfig = ({\n formats,\n getMessageFallback,\n messages,\n onError,\n ...rest\n}) => {\n const finalOnError = onError ?? ((error) => error);\n const finalGetMessageFallback =\n getMessageFallback ??\n (({ key, namespace }) => [namespace, key].filter(Boolean).join('.'));\n\n return {\n ...rest,\n formats: formats || undefined,\n messages: messages || undefined,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback,\n };\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,oBAA8C,EACzD,SACA,oBACA,UACA,SACA,GAAG,WACC;CACJ,MAAM,eAAe,aAAa,UAAU;CAC5C,MAAM,0BACJ,wBACE,EAAE,KAAK,gBAAgB,CAAC,WAAW,IAAI,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;AAErE,QAAO;EACL,GAAG;EACH,SAAS,WAAW;EACpB,UAAU,YAAY;EACtB,SAAS;EACT,oBAAoB;EACrB"}
File without changes
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
3
+ const require_useDictionary = require('./useDictionary.cjs');
4
+ const require_client_helpers = require('./client/helpers.cjs');
5
+ const require_client_IntlProvider = require('./client/IntlProvider.cjs');
6
+ const require_client_useLocale = require('./client/useLocale.cjs');
7
+ const require_client_useTranslations = require('./client/useTranslations.cjs');
8
+ const require_client_index = require('./client/index.cjs');
9
+ const require_core_createFormatter = require('./core/createFormatter.cjs');
10
+ const require_core_createTranslator = require('./core/createTranslator.cjs');
11
+ const require_core_errors = require('./core/errors.cjs');
12
+ const require_core_hasLocale = require('./core/hasLocale.cjs');
13
+ const require_core_initializeConfig = require('./core/initializeConfig.cjs');
14
+
15
+ exports.IntlError = require_core_errors.IntlError;
16
+ exports.IntlErrorCode = require_core_errors.IntlErrorCode;
17
+ exports.IntlProvider = require_client_IntlProvider.IntlProvider;
18
+ exports._useExtracted = require_client_index._useExtracted;
19
+ exports.createFormatter = require_core_createFormatter.createFormatter;
20
+ exports.createTranslator = require_core_createTranslator.createTranslator;
21
+ exports.hasLocale = require_core_hasLocale.hasLocale;
22
+ exports.initializeConfig = require_core_initializeConfig.initializeConfig;
23
+ exports.useDictionary = require_useDictionary.useDictionary;
24
+ exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
25
+ exports.useFormatter = require_client_helpers.useFormatter;
26
+ exports.useLocale = require_client_useLocale.useLocale;
27
+ exports.useMessages = require_client_helpers.useMessages;
28
+ exports.useNow = require_client_helpers.useNow;
29
+ exports.useTimeZone = require_client_helpers.useTimeZone;
30
+ exports.useTranslations = require_client_useTranslations.useTranslations;
@@ -0,0 +1,80 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_config_colors = require("@intlayer/config/colors");
4
+ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
5
+ let _intlayer_config_logger = require("@intlayer/config/logger");
6
+ let node_path = require("node:path");
7
+ let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
8
+ let _intlayer_config_node = require("@intlayer/config/node");
9
+ let vite_intlayer = require("vite-intlayer");
10
+
11
+ //#region src/plugin/index.ts
12
+ /**
13
+ * Caller configurations for use-intl's translation entry points.
14
+ *
15
+ * Tells the intlayer field-usage analyser how to extract the dictionary key
16
+ * (namespace) and consumed fields from `useTranslations` / `createTranslator`
17
+ * call sites, enabling accurate dictionary pruning for projects using
18
+ * `@intlayer/use-intl`.
19
+ */
20
+ const USE_INTL_COMPAT_CALLERS = [{
21
+ callerName: "useTranslations",
22
+ importSources: [
23
+ "use-intl",
24
+ "use-intl/react",
25
+ "@intlayer/use-intl"
26
+ ],
27
+ namespace: {
28
+ from: "argument",
29
+ index: 0
30
+ },
31
+ translationFunction: "return-value"
32
+ }, {
33
+ callerName: "createTranslator",
34
+ importSources: [
35
+ "use-intl",
36
+ "use-intl/core",
37
+ "@intlayer/use-intl"
38
+ ],
39
+ namespace: {
40
+ from: "option",
41
+ argumentIndex: 0,
42
+ property: "namespace"
43
+ },
44
+ translationFunction: "return-value"
45
+ }];
46
+ /**
47
+ * A Vite plugin for use-intl compat that wraps vite-intlayer and configures
48
+ * resolve aliases so `use-intl` imports are served by `@intlayer/use-intl`.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // vite.config.ts
53
+ * import useIntlVitePlugin from '@intlayer/use-intl/plugin';
54
+ *
55
+ * export default defineConfig({
56
+ * plugins: [useIntlVitePlugin()],
57
+ * });
58
+ * ```
59
+ */
60
+ const useIntlVitePlugin = (options) => {
61
+ const intlayerConfig = (0, _intlayer_config_node.getConfiguration)();
62
+ const appLogger = (0, _intlayer_config_logger.getAppLogger)(intlayerConfig);
63
+ (0, _intlayer_chokidar_utils.runOnce)((0, node_path.join)(intlayerConfig.system.baseDir, ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
64
+ appLogger([(0, _intlayer_config_logger.colorize)("Please report any issues you met on GitHub:", _intlayer_config_colors.GREY), (0, _intlayer_config_logger.colorize)("https://github.com/aymericzip/intlayer/issues", _intlayer_config_colors.GREY_LIGHT)]);
65
+ }, { cacheTimeoutMs: 1e3 * 60 * 60 });
66
+ const basePlugins = (0, vite_intlayer.intlayer)({
67
+ ...options,
68
+ compatCallers: [...options?.compatCallers ?? [], ...USE_INTL_COMPAT_CALLERS]
69
+ });
70
+ const compatPlugin = {
71
+ name: "vite-use-intl-compat-plugin",
72
+ config: () => ({ resolve: { alias: { "use-intl": "@intlayer/use-intl" } } })
73
+ };
74
+ return [...Array.isArray(basePlugins) ? basePlugins : [basePlugins], compatPlugin];
75
+ };
76
+
77
+ //#endregion
78
+ exports.default = useIntlVitePlugin;
79
+ exports.useIntlVitePlugin = useIntlVitePlugin;
80
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ANSIColors"],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for use-intl's translation entry points.\n *\n * Tells the intlayer field-usage analyser how to extract the dictionary key\n * (namespace) and consumed fields from `useTranslations` / `createTranslator`\n * call sites, enabling accurate dictionary pruning for projects using\n * `@intlayer/use-intl`.\n */\nconst USE_INTL_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: 'useTranslations',\n importSources: ['use-intl', 'use-intl/react', '@intlayer/use-intl'],\n namespace: { from: 'argument', index: 0 },\n translationFunction: 'return-value',\n },\n {\n callerName: 'createTranslator',\n importSources: ['use-intl', 'use-intl/core', '@intlayer/use-intl'],\n namespace: { from: 'option', argumentIndex: 0, property: 'namespace' },\n translationFunction: 'return-value',\n },\n];\n\n/**\n * A Vite plugin for use-intl compat that wraps vite-intlayer and configures\n * resolve aliases so `use-intl` imports are served by `@intlayer/use-intl`.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import useIntlVitePlugin from '@intlayer/use-intl/plugin';\n *\n * export default defineConfig({\n * plugins: [useIntlVitePlugin()],\n * });\n * ```\n */\nexport const useIntlVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...USE_INTL_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-use-intl-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n 'use-intl': '@intlayer/use-intl',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default useIntlVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAM,0BAAgD,CACpD;CACE,YAAY;CACZ,eAAe;EAAC;EAAY;EAAkB;EAAqB;CACnE,WAAW;EAAE,MAAM;EAAY,OAAO;EAAG;CACzC,qBAAqB;CACtB,EACD;CACE,YAAY;CACZ,eAAe;EAAC;EAAY;EAAiB;EAAqB;CAClE,WAAW;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa;CACtE,qBAAqB;CACtB,CACF;;;;;;;;;;;;;;;AAgBD,MAAa,qBACX,YACmB;CACnB,MAAM,8DAAmC;CACzC,MAAM,sDAAyB,eAAe;AAE9C,2DAEI,eAAe,OAAO,SACtB,aACA,SACA,kCACD,QACK;AACJ,YAAU,uCAEN,+CACAA,wBAAW,KACZ,wCAEC,iDACAA,wBAAW,WACZ,CACF,CAAC;IAEJ,EACE,gBAAgB,MAAO,KAAK,IAC7B,CACF;CAED,MAAM,0CAAuB;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,EAAE,EAChC,GAAG,wBACJ;EACF,CAAC;CAEF,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO,EACL,YAAY,sBACb,EACF,EACF;EACF;AAED,QAAO,CACL,GAAI,MAAM,QAAQ,YAAY,GAAG,cAAc,CAAC,YAAY,EAC5D,aACD"}
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/shared/intlFormatter.ts
4
+ /** Time units orderable by their duration in seconds. */
5
+ const RELATIVE_TIME_UNITS = [
6
+ ["year", 31536e3],
7
+ ["month", 2628e3],
8
+ ["week", 604800],
9
+ ["day", 86400],
10
+ ["hour", 3600],
11
+ ["minute", 60],
12
+ ["second", 1]
13
+ ];
14
+ const toDate = (value) => value instanceof Date ? value : new Date(value);
15
+ /**
16
+ * Builds a use-intl compatible formatter backed by the native `Intl.*` APIs
17
+ * for the given locale.
18
+ *
19
+ * Shared by `useFormatter` (React hook) and `createFormatter` (non-React core).
20
+ *
21
+ * @param locale - The locale used by every `Intl.*` formatter instance.
22
+ * @returns A formatter exposing `dateTime`, `number`, `dateTimeRange`,
23
+ * `relativeTime`, `list`, and `displayName`.
24
+ */
25
+ const buildIntlFormatter = (locale) => ({
26
+ dateTime: (value, options) => new Intl.DateTimeFormat(locale, options).format(value),
27
+ number: (value, options) => new Intl.NumberFormat(locale, options).format(value),
28
+ /** Formats a date range with `Intl.DateTimeFormat#formatRange`. */
29
+ dateTimeRange: (start, end, options) => new Intl.DateTimeFormat(locale, options).formatRange(toDate(start), toDate(end)),
30
+ /**
31
+ * Formats a date relative to now (or a reference date), automatically
32
+ * selecting the largest fitting unit.
33
+ */
34
+ relativeTime: (date, nowOrOptions) => {
35
+ const options = nowOrOptions instanceof Date || typeof nowOrOptions === "number" ? { now: nowOrOptions } : nowOrOptions ?? {};
36
+ const nowDate = options.now !== void 0 ? toDate(options.now) : /* @__PURE__ */ new Date();
37
+ const diffInSeconds = (toDate(date).getTime() - nowDate.getTime()) / 1e3;
38
+ let unit = options.unit;
39
+ if (!unit) {
40
+ const absoluteDiff = Math.abs(diffInSeconds);
41
+ unit = RELATIVE_TIME_UNITS.find(([, unitSeconds]) => absoluteDiff >= unitSeconds)?.[0] ?? "second";
42
+ }
43
+ const unitSeconds = RELATIVE_TIME_UNITS.find(([unitName]) => unitName === unit)?.[1] ?? 1;
44
+ return new Intl.RelativeTimeFormat(locale, {
45
+ numeric: "auto",
46
+ style: options.style
47
+ }).format(Math.round(diffInSeconds / unitSeconds), unit);
48
+ },
49
+ /** Formats a list with `Intl.ListFormat`. */
50
+ list: (value, options) => new Intl.ListFormat(locale, options).format(value),
51
+ displayName: (value, optionsOrFormat, extraOptions) => {
52
+ const resolvedOptions = typeof optionsOrFormat === "string" ? extraOptions : optionsOrFormat;
53
+ try {
54
+ return new Intl.DisplayNames([locale], resolvedOptions ?? { type: "language" }).of(value) ?? value;
55
+ } catch {
56
+ return value;
57
+ }
58
+ }
59
+ });
60
+
61
+ //#endregion
62
+ exports.buildIntlFormatter = buildIntlFormatter;
63
+ //# sourceMappingURL=intlFormatter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlFormatter.cjs","names":[],"sources":["../../../src/shared/intlFormatter.ts"],"sourcesContent":["import type { createFormatter as _createFormatter } from 'use-intl';\n\n/** The formatter object shape exposed by use-intl. */\nexport type Formatter = ReturnType<typeof _createFormatter>;\n\n/** Time units orderable by their duration in seconds. */\nconst RELATIVE_TIME_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 31536000],\n ['month', 2628000],\n ['week', 604800],\n ['day', 86400],\n ['hour', 3600],\n ['minute', 60],\n ['second', 1],\n];\n\nconst toDate = (value: Date | number | string): Date =>\n value instanceof Date ? value : new Date(value);\n\n/**\n * Builds a use-intl compatible formatter backed by the native `Intl.*` APIs\n * for the given locale.\n *\n * Shared by `useFormatter` (React hook) and `createFormatter` (non-React core).\n *\n * @param locale - The locale used by every `Intl.*` formatter instance.\n * @returns A formatter exposing `dateTime`, `number`, `dateTimeRange`,\n * `relativeTime`, `list`, and `displayName`.\n */\nexport const buildIntlFormatter = (locale: string): Formatter =>\n ({\n dateTime: (value: Date | number, options?: Intl.DateTimeFormatOptions) =>\n new Intl.DateTimeFormat(locale, options).format(value),\n\n number: (value: number | bigint, options?: Intl.NumberFormatOptions) =>\n new Intl.NumberFormat(locale, options).format(value),\n\n /** Formats a date range with `Intl.DateTimeFormat#formatRange`. */\n dateTimeRange: (\n start: Date | number,\n end: Date | number,\n options?: Intl.DateTimeFormatOptions\n ) =>\n new Intl.DateTimeFormat(locale, options).formatRange(\n toDate(start),\n toDate(end)\n ),\n\n /**\n * Formats a date relative to now (or a reference date), automatically\n * selecting the largest fitting unit.\n */\n relativeTime: (\n date: Date | number | string,\n nowOrOptions?:\n | Date\n | number\n | {\n now?: Date | number;\n unit?: Intl.RelativeTimeFormatUnit;\n style?: Intl.RelativeTimeFormatStyle;\n numberingSystem?: string;\n }\n ) => {\n const options =\n nowOrOptions instanceof Date || typeof nowOrOptions === 'number'\n ? { now: nowOrOptions }\n : (nowOrOptions ?? {});\n\n const nowDate =\n options.now !== undefined ? toDate(options.now) : new Date();\n const diffInSeconds = (toDate(date).getTime() - nowDate.getTime()) / 1000;\n\n let unit = options.unit;\n if (!unit) {\n const absoluteDiff = Math.abs(diffInSeconds);\n unit =\n RELATIVE_TIME_UNITS.find(\n ([, unitSeconds]) => absoluteDiff >= unitSeconds\n )?.[0] ?? 'second';\n }\n\n const unitSeconds =\n RELATIVE_TIME_UNITS.find(([unitName]) => unitName === unit)?.[1] ?? 1;\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto',\n style: options.style,\n }).format(Math.round(diffInSeconds / unitSeconds), unit);\n },\n\n /** Formats a list with `Intl.ListFormat`. */\n list: (value: Iterable<string>, options?: Intl.ListFormatOptions): string =>\n new Intl.ListFormat(locale, options).format(value),\n\n displayName: (\n value: string,\n optionsOrFormat?: Intl.DisplayNamesOptions | string,\n extraOptions?: Intl.DisplayNamesOptions\n ): string => {\n const resolvedOptions =\n typeof optionsOrFormat === 'string' ? extraOptions : optionsOrFormat;\n try {\n return (\n new Intl.DisplayNames(\n [locale],\n resolvedOptions ?? { type: 'language' }\n ).of(value) ?? value\n );\n } catch {\n return value;\n }\n },\n }) as unknown as Formatter;\n"],"mappings":";;;;AAMA,MAAM,sBAA+D;CACnE,CAAC,QAAQ,QAAS;CAClB,CAAC,SAAS,OAAQ;CAClB,CAAC,QAAQ,OAAO;CAChB,CAAC,OAAO,MAAM;CACd,CAAC,QAAQ,KAAK;CACd,CAAC,UAAU,GAAG;CACd,CAAC,UAAU,EAAE;CACd;AAED,MAAM,UAAU,UACd,iBAAiB,OAAO,QAAQ,IAAI,KAAK,MAAM;;;;;;;;;;;AAYjD,MAAa,sBAAsB,YAChC;CACC,WAAW,OAAsB,YAC/B,IAAI,KAAK,eAAe,QAAQ,QAAQ,CAAC,OAAO,MAAM;CAExD,SAAS,OAAwB,YAC/B,IAAI,KAAK,aAAa,QAAQ,QAAQ,CAAC,OAAO,MAAM;;CAGtD,gBACE,OACA,KACA,YAEA,IAAI,KAAK,eAAe,QAAQ,QAAQ,CAAC,YACvC,OAAO,MAAM,EACb,OAAO,IAAI,CACZ;;;;;CAMH,eACE,MACA,iBASG;EACH,MAAM,UACJ,wBAAwB,QAAQ,OAAO,iBAAiB,WACpD,EAAE,KAAK,cAAc,GACpB,gBAAgB,EAAE;EAEzB,MAAM,UACJ,QAAQ,QAAQ,SAAY,OAAO,QAAQ,IAAI,mBAAG,IAAI,MAAM;EAC9D,MAAM,iBAAiB,OAAO,KAAK,CAAC,SAAS,GAAG,QAAQ,SAAS,IAAI;EAErE,IAAI,OAAO,QAAQ;AACnB,MAAI,CAAC,MAAM;GACT,MAAM,eAAe,KAAK,IAAI,cAAc;AAC5C,UACE,oBAAoB,MACjB,GAAG,iBAAiB,gBAAgB,YACtC,GAAG,MAAM;;EAGd,MAAM,cACJ,oBAAoB,MAAM,CAAC,cAAc,aAAa,KAAK,GAAG,MAAM;AAEtE,SAAO,IAAI,KAAK,mBAAmB,QAAQ;GACzC,SAAS;GACT,OAAO,QAAQ;GAChB,CAAC,CAAC,OAAO,KAAK,MAAM,gBAAgB,YAAY,EAAE,KAAK;;;CAI1D,OAAO,OAAyB,YAC9B,IAAI,KAAK,WAAW,QAAQ,QAAQ,CAAC,OAAO,MAAM;CAEpD,cACE,OACA,iBACA,iBACW;EACX,MAAM,kBACJ,OAAO,oBAAoB,WAAW,eAAe;AACvD,MAAI;AACF,UACE,IAAI,KAAK,aACP,CAAC,OAAO,EACR,mBAAmB,EAAE,MAAM,YAAY,CACxC,CAAC,GAAG,MAAM,IAAI;UAEX;AACN,UAAO;;;CAGZ"}
@@ -0,0 +1,122 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
4
+ let _intlayer_core_messageFormat = require("@intlayer/core/messageFormat");
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/shared/namespaceTranslator.tsx
9
+ /**
10
+ * Reads a dotted `path` (e.g. `counter.label`) out of a nested object value.
11
+ *
12
+ * @param objectValue - The object to read from.
13
+ * @param path - Dot-separated path. An empty path returns `objectValue`.
14
+ * @returns The value found at `path`, or `undefined` when any segment is absent.
15
+ */
16
+ const navigatePath = (objectValue, path) => {
17
+ if (!path) return objectValue;
18
+ const parts = path.split(".");
19
+ let current = objectValue;
20
+ for (const part of parts) {
21
+ if (current === null || current === void 0 || typeof current !== "object") return;
22
+ current = current[part];
23
+ }
24
+ return current;
25
+ };
26
+ /** Splits rich values into scalar interpolation values and tag renderers. */
27
+ const splitRichValues = (values = {}) => {
28
+ const scalarValues = {};
29
+ const renderers = {};
30
+ for (const [valueKey, value] of Object.entries(values)) if (typeof value === "function") renderers[valueKey] = value;
31
+ else scalarValues[valueKey] = value;
32
+ return {
33
+ scalarValues,
34
+ renderers
35
+ };
36
+ };
37
+ const renderRichTokens = (tokens, renderers) => tokens.map((token, tokenIndex) => {
38
+ if (typeof token === "string") return token;
39
+ const children = renderRichTokens(token.children, renderers);
40
+ const renderer = renderers[token.tag];
41
+ if (typeof renderer === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderer(children) }, tokenIndex);
42
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children }, tokenIndex);
43
+ });
44
+ const renderMarkupTokens = (tokens, renderers) => tokens.map((token) => {
45
+ if (typeof token === "string") return token;
46
+ const children = renderMarkupTokens(token.children, renderers);
47
+ const renderer = renderers[token.tag];
48
+ if (typeof renderer === "function") return renderer(children);
49
+ return children;
50
+ }).join("");
51
+ /**
52
+ * The untyped runtime translator shared by `useTranslations` (React hook) and
53
+ * `createTranslator` (non-React core).
54
+ *
55
+ * Behaviour matches use-intl / next-intl:
56
+ * - namespace `'about'` → keys resolved inside the `about` dictionary
57
+ * - namespace `'about.counter'` → dictionary `about`, key prefix `counter`
58
+ * - no namespace → the first segment of each key is the dictionary key
59
+ * - messages support ICU syntax (plural, select, `#`, formatted arguments)
60
+ * - `t.rich` / `t.markup` map `<tag>chunks</tag>` through the provided
61
+ * renderers; `t.raw` returns the raw value; `t.has` checks existence
62
+ *
63
+ * @param locale - The locale dictionaries are resolved for.
64
+ * @param namespace - Optional dictionary key, optionally with a nested scope.
65
+ * @returns A translate function augmented with `has`, `raw`, `rich`, `markup`.
66
+ */
67
+ const createNamespaceTranslator = (locale, namespace) => {
68
+ const [dictionaryKey, ...prefixSegments] = (namespace ?? "").split(".");
69
+ const keyPrefix = prefixSegments.join(".");
70
+ const lookup = (key) => {
71
+ let targetDictionaryKey = dictionaryKey;
72
+ let path = keyPrefix ? `${keyPrefix}.${key}` : key;
73
+ if (!targetDictionaryKey) {
74
+ const [firstSegment, ...restSegments] = key.split(".");
75
+ targetDictionaryKey = firstSegment;
76
+ path = restSegments.join(".");
77
+ }
78
+ try {
79
+ return navigatePath((0, _intlayer_core_interpreter.getIntlayer)(targetDictionaryKey, locale), path);
80
+ } catch {
81
+ return;
82
+ }
83
+ };
84
+ const resolveToString = (key, values = {}) => {
85
+ const rawValue = lookup(key);
86
+ if (rawValue === null || rawValue === void 0) return void 0;
87
+ return (0, _intlayer_core_messageFormat.resolveMessage)(rawValue, values, locale, "icu");
88
+ };
89
+ const missingKeyFallback = (key) => namespace ? `${namespace}.${key}` : key;
90
+ const translate = (key, values) => resolveToString(key, values) ?? missingKeyFallback(key);
91
+ return Object.assign(translate, {
92
+ /** Returns `true` if the given key exists in the namespace. */
93
+ has: (key) => lookup(key) !== void 0,
94
+ /** Returns the raw unprocessed content for the given key. */
95
+ raw: (key) => lookup(key),
96
+ /**
97
+ * Resolves a message containing `<tag>chunks</tag>` markup, mapping each
98
+ * tag through the matching renderer in `values`.
99
+ */
100
+ rich: (key, values) => {
101
+ const { scalarValues, renderers } = splitRichValues(values);
102
+ const message = resolveToString(key, scalarValues);
103
+ if (message === void 0) return missingKeyFallback(key);
104
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: renderRichTokens((0, _intlayer_core_messageFormat.parseTaggedMessage)(message), renderers) });
105
+ },
106
+ /**
107
+ * Resolves a message containing `<tag>chunks</tag>` markup into a string,
108
+ * mapping each tag through the matching string renderer in `values`.
109
+ */
110
+ markup: (key, values) => {
111
+ const { scalarValues, renderers } = splitRichValues(values);
112
+ const message = resolveToString(key, scalarValues);
113
+ if (message === void 0) return missingKeyFallback(key);
114
+ return renderMarkupTokens((0, _intlayer_core_messageFormat.parseTaggedMessage)(message), renderers);
115
+ }
116
+ });
117
+ };
118
+
119
+ //#endregion
120
+ exports.createNamespaceTranslator = createNamespaceTranslator;
121
+ exports.navigatePath = navigatePath;
122
+ //# sourceMappingURL=namespaceTranslator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaceTranslator.cjs","names":["Fragment"],"sources":["../../../src/shared/namespaceTranslator.tsx"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport {\n type MessageValues,\n parseTaggedMessage,\n resolveMessage,\n type TaggedMessageToken,\n} from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { Fragment, type ReactNode } from 'react';\n\n/** Chunk renderer used by `t.rich()` — maps tag children to a React node. */\nexport type RichChunkRenderer = (chunks: ReactNode) => ReactNode;\n\n/** Chunk renderer used by `t.markup()` — maps tag children to a string. */\nexport type MarkupChunkRenderer = (chunks: string) => string;\n\n/**\n * Reads a dotted `path` (e.g. `counter.label`) out of a nested object value.\n *\n * @param objectValue - The object to read from.\n * @param path - Dot-separated path. An empty path returns `objectValue`.\n * @returns The value found at `path`, or `undefined` when any segment is absent.\n */\nexport const navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n const parts = path.split('.');\n let current: unknown = objectValue;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/** Splits rich values into scalar interpolation values and tag renderers. */\nconst splitRichValues = (\n values: Record<string, unknown> = {}\n): { scalarValues: MessageValues; renderers: Record<string, unknown> } => {\n const scalarValues: MessageValues = {};\n const renderers: Record<string, unknown> = {};\n\n for (const [valueKey, value] of Object.entries(values)) {\n if (typeof value === 'function') renderers[valueKey] = value;\n else scalarValues[valueKey] = value;\n }\n\n return { scalarValues, renderers };\n};\n\nconst renderRichTokens = (\n tokens: TaggedMessageToken[],\n renderers: Record<string, unknown>\n): ReactNode[] =>\n tokens.map((token, tokenIndex) => {\n if (typeof token === 'string') return token;\n\n const children = renderRichTokens(token.children, renderers);\n const renderer = renderers[token.tag];\n\n if (typeof renderer === 'function') {\n return (\n <Fragment key={tokenIndex}>\n {(renderer as RichChunkRenderer)(children)}\n </Fragment>\n );\n }\n\n // No renderer provided for the tag — render its children unwrapped\n return <Fragment key={tokenIndex}>{children}</Fragment>;\n });\n\nconst renderMarkupTokens = (\n tokens: TaggedMessageToken[],\n renderers: Record<string, unknown>\n): string =>\n tokens\n .map((token) => {\n if (typeof token === 'string') return token;\n\n const children = renderMarkupTokens(token.children, renderers);\n const renderer = renderers[token.tag];\n\n if (typeof renderer === 'function') {\n return (renderer as MarkupChunkRenderer)(children);\n }\n\n return children;\n })\n .join('');\n\n/**\n * The untyped runtime translator shared by `useTranslations` (React hook) and\n * `createTranslator` (non-React core).\n *\n * Behaviour matches use-intl / next-intl:\n * - namespace `'about'` → keys resolved inside the `about` dictionary\n * - namespace `'about.counter'` → dictionary `about`, key prefix `counter`\n * - no namespace → the first segment of each key is the dictionary key\n * - messages support ICU syntax (plural, select, `#`, formatted arguments)\n * - `t.rich` / `t.markup` map `<tag>chunks</tag>` through the provided\n * renderers; `t.raw` returns the raw value; `t.has` checks existence\n *\n * @param locale - The locale dictionaries are resolved for.\n * @param namespace - Optional dictionary key, optionally with a nested scope.\n * @returns A translate function augmented with `has`, `raw`, `rich`, `markup`.\n */\nexport const createNamespaceTranslator = (\n locale: LocalesValues,\n namespace?: string\n) => {\n const [dictionaryKey, ...prefixSegments] = (namespace ?? '').split('.');\n const keyPrefix = prefixSegments.join('.');\n\n const lookup = (key: string): unknown => {\n let targetDictionaryKey = dictionaryKey;\n let path = keyPrefix ? `${keyPrefix}.${key}` : key;\n\n if (!targetDictionaryKey) {\n // Root scope — the first key segment designates the dictionary\n const [firstSegment, ...restSegments] = key.split('.');\n targetDictionaryKey = firstSegment;\n path = restSegments.join('.');\n }\n\n try {\n const dictionary = getIntlayer(\n targetDictionaryKey as DictionaryKeys,\n locale\n );\n return navigatePath(dictionary, path);\n } catch {\n return undefined;\n }\n };\n\n const resolveToString = (\n key: string,\n values: MessageValues = {}\n ): string | undefined => {\n const rawValue = lookup(key);\n if (rawValue === null || rawValue === undefined) return undefined;\n return resolveMessage(rawValue, values, locale, 'icu');\n };\n\n const missingKeyFallback = (key: string): string =>\n namespace ? `${namespace}.${key}` : key;\n\n const translate = (key: string, values?: MessageValues): string =>\n resolveToString(key, values) ?? missingKeyFallback(key);\n\n return Object.assign(translate, {\n /** Returns `true` if the given key exists in the namespace. */\n has: (key: string): boolean => lookup(key) !== undefined,\n\n /** Returns the raw unprocessed content for the given key. */\n raw: (key: string): unknown => lookup(key),\n\n /**\n * Resolves a message containing `<tag>chunks</tag>` markup, mapping each\n * tag through the matching renderer in `values`.\n */\n rich: (key: string, values?: Record<string, unknown>): ReactNode => {\n const { scalarValues, renderers } = splitRichValues(values);\n const message = resolveToString(key, scalarValues);\n if (message === undefined) return missingKeyFallback(key);\n return <>{renderRichTokens(parseTaggedMessage(message), renderers)}</>;\n },\n\n /**\n * Resolves a message containing `<tag>chunks</tag>` markup into a string,\n * mapping each tag through the matching string renderer in `values`.\n */\n markup: (key: string, values?: Record<string, unknown>): string => {\n const { scalarValues, renderers } = splitRichValues(values);\n const message = resolveToString(key, scalarValues);\n if (message === undefined) return missingKeyFallback(key);\n return renderMarkupTokens(parseTaggedMessage(message), renderers);\n },\n });\n};\n\nexport type CompatTranslator = ReturnType<typeof createNamespaceTranslator>;\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAa,gBAAgB,aAAsB,SAA0B;AAC3E,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,OAAO;AACxB,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;AAIT,MAAM,mBACJ,SAAkC,EAAE,KACoC;CACxE,MAAM,eAA8B,EAAE;CACtC,MAAM,YAAqC,EAAE;AAE7C,MAAK,MAAM,CAAC,UAAU,UAAU,OAAO,QAAQ,OAAO,CACpD,KAAI,OAAO,UAAU,WAAY,WAAU,YAAY;KAClD,cAAa,YAAY;AAGhC,QAAO;EAAE;EAAc;EAAW;;AAGpC,MAAM,oBACJ,QACA,cAEA,OAAO,KAAK,OAAO,eAAe;AAChC,KAAI,OAAO,UAAU,SAAU,QAAO;CAEtC,MAAM,WAAW,iBAAiB,MAAM,UAAU,UAAU;CAC5D,MAAM,WAAW,UAAU,MAAM;AAEjC,KAAI,OAAO,aAAa,WACtB,QACE,2CAACA,gBAAD,YACI,SAA+B,SAAS,EACjC,EAFI,WAEJ;AAKf,QAAO,2CAACA,gBAAD,EAA4B,UAAoB,EAAjC,WAAiC;EACvD;AAEJ,MAAM,sBACJ,QACA,cAEA,OACG,KAAK,UAAU;AACd,KAAI,OAAO,UAAU,SAAU,QAAO;CAEtC,MAAM,WAAW,mBAAmB,MAAM,UAAU,UAAU;CAC9D,MAAM,WAAW,UAAU,MAAM;AAEjC,KAAI,OAAO,aAAa,WACtB,QAAQ,SAAiC,SAAS;AAGpD,QAAO;EACP,CACD,KAAK,GAAG;;;;;;;;;;;;;;;;;AAkBb,MAAa,6BACX,QACA,cACG;CACH,MAAM,CAAC,eAAe,GAAG,mBAAmB,aAAa,IAAI,MAAM,IAAI;CACvE,MAAM,YAAY,eAAe,KAAK,IAAI;CAE1C,MAAM,UAAU,QAAyB;EACvC,IAAI,sBAAsB;EAC1B,IAAI,OAAO,YAAY,GAAG,UAAU,GAAG,QAAQ;AAE/C,MAAI,CAAC,qBAAqB;GAExB,MAAM,CAAC,cAAc,GAAG,gBAAgB,IAAI,MAAM,IAAI;AACtD,yBAAsB;AACtB,UAAO,aAAa,KAAK,IAAI;;AAG/B,MAAI;AAKF,UAAO,yDAHL,qBACA,OAE4B,EAAE,KAAK;UAC/B;AACN;;;CAIJ,MAAM,mBACJ,KACA,SAAwB,EAAE,KACH;EACvB,MAAM,WAAW,OAAO,IAAI;AAC5B,MAAI,aAAa,QAAQ,aAAa,OAAW,QAAO;AACxD,0DAAsB,UAAU,QAAQ,QAAQ,MAAM;;CAGxD,MAAM,sBAAsB,QAC1B,YAAY,GAAG,UAAU,GAAG,QAAQ;CAEtC,MAAM,aAAa,KAAa,WAC9B,gBAAgB,KAAK,OAAO,IAAI,mBAAmB,IAAI;AAEzD,QAAO,OAAO,OAAO,WAAW;;EAE9B,MAAM,QAAyB,OAAO,IAAI,KAAK;;EAG/C,MAAM,QAAyB,OAAO,IAAI;;;;;EAM1C,OAAO,KAAa,WAAgD;GAClE,MAAM,EAAE,cAAc,cAAc,gBAAgB,OAAO;GAC3D,MAAM,UAAU,gBAAgB,KAAK,aAAa;AAClD,OAAI,YAAY,OAAW,QAAO,mBAAmB,IAAI;AACzD,UAAO,mFAAG,sEAAoC,QAAQ,EAAE,UAAU,EAAI;;;;;;EAOxE,SAAS,KAAa,WAA6C;GACjE,MAAM,EAAE,cAAc,cAAc,gBAAgB,OAAO;GAC3D,MAAM,UAAU,gBAAgB,KAAK,aAAa;AAClD,OAAI,YAAY,OAAW,QAAO,mBAAmB,IAAI;AACzD,UAAO,wEAAsC,QAAQ,EAAE,UAAU;;EAEpE,CAAC"}
File without changes
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
5
+ const require_shared_namespaceTranslator = require('./shared/namespaceTranslator.cjs');
6
+ let react_intlayer = require("react-intlayer");
7
+
8
+ //#region src/useDictionary.ts
9
+ /**
10
+ * Dictionary-accepting variant of `useTranslations`.
11
+ *
12
+ * Used internally by the build-time optimization: instead of looking up the
13
+ * dictionary at runtime by key, the babel/swc plugin pre-imports the dictionary
14
+ * JSON at build time and passes it directly here. This enables tree-shaking of
15
+ * unused locale content.
16
+ *
17
+ * @example (generated by the plugin, not written manually)
18
+ * import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
19
+ * const t = useDictionary(_abc);
20
+ */
21
+ const useDictionary = (dictionary, namespacePrefix) => {
22
+ const content = (0, react_intlayer.useDictionary)(dictionary);
23
+ const resolveKey = (key) => namespacePrefix ? `${namespacePrefix}.${key}` : key;
24
+ return Object.assign((lookup, params) => {
25
+ const rawValue = require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup)));
26
+ const text = String(rawValue ?? resolveKey(String(lookup)));
27
+ if (!params) return text;
28
+ return text.replace(/\{(\w+)\}/g, (_match, key) => params[key] != null ? String(params[key]) : `{${key}}`);
29
+ }, {
30
+ has: (lookup) => require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup))) != null,
31
+ raw: (lookup) => require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup)))
32
+ });
33
+ };
34
+
35
+ //#endregion
36
+ exports.useDictionary = useDictionary;
37
+ //# sourceMappingURL=useDictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionary.cjs","names":["navigatePath"],"sources":["../../src/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useDictionary as useDictionaryBase } from 'react-intlayer';\nimport { navigatePath } from './shared/namespaceTranslator';\n\n/**\n * Dictionary-accepting variant of `useTranslations`.\n *\n * Used internally by the build-time optimization: instead of looking up the\n * dictionary at runtime by key, the babel/swc plugin pre-imports the dictionary\n * JSON at build time and passes it directly here. This enables tree-shaking of\n * unused locale content.\n *\n * @example (generated by the plugin, not written manually)\n * import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };\n * const t = useDictionary(_abc);\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n namespacePrefix?: string\n) => {\n const content = useDictionaryBase(dictionary);\n\n const resolveKey = (key: string): string =>\n namespacePrefix ? `${namespacePrefix}.${key}` : key;\n\n return Object.assign(\n <P extends ValidDotPathsFor<string>>(\n lookup: P,\n params?: Record<string, unknown>\n ): string => {\n const rawValue = navigatePath(content, resolveKey(String(lookup)));\n const text = String(rawValue ?? resolveKey(String(lookup)));\n if (!params) return text;\n return text.replace(/\\{(\\w+)\\}/g, (_match, key) =>\n params[key] != null ? String(params[key]) : `{${key}}`\n );\n },\n {\n has: <P extends ValidDotPathsFor<string>>(lookup: P): boolean =>\n navigatePath(content, resolveKey(String(lookup))) != null,\n raw: <P extends ValidDotPathsFor<string>>(lookup: P): unknown =>\n navigatePath(content, resolveKey(String(lookup))),\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,iBACX,YACA,oBACG;CACH,MAAM,4CAA4B,WAAW;CAE7C,MAAM,cAAc,QAClB,kBAAkB,GAAG,gBAAgB,GAAG,QAAQ;AAElD,QAAO,OAAO,QAEV,QACA,WACW;EACX,MAAM,WAAWA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EAClE,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,OAAO,CAAC,CAAC;AAC3D,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,KAAK,QAAQ,eAAe,QAAQ,QACzC,OAAO,QAAQ,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI,IAAI,GACrD;IAEH;EACE,MAA0C,WACxCA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC,IAAI;EACvD,MAA0C,WACxCA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EACpD,CACF"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
5
+ const require_shared_namespaceTranslator = require('./shared/namespaceTranslator.cjs');
6
+ let react_intlayer = require("react-intlayer");
7
+
8
+ //#region src/useDictionaryDynamic.ts
9
+ /**
10
+ * Dynamic dictionary-accepting variant of `useTranslations`.
11
+ *
12
+ * Counterpart to {@link useDictionary} for dictionaries imported lazily per
13
+ * locale. Used internally by the build-time optimization.
14
+ */
15
+ const useDictionaryDynamic = (dictionaryPromise, key, namespacePrefix) => {
16
+ const content = (0, react_intlayer.useDictionaryDynamic)(dictionaryPromise, key);
17
+ const resolveKey = (lookupKey) => namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;
18
+ return Object.assign((lookup, params) => {
19
+ const rawValue = require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup)));
20
+ const text = String(rawValue ?? resolveKey(String(lookup)));
21
+ if (!params) return text;
22
+ return text.replace(/\{(\w+)\}/g, (_match, key) => params[key] != null ? String(params[key]) : `{${key}}`);
23
+ }, {
24
+ has: (lookup) => require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup))) != null,
25
+ raw: (lookup) => require_shared_namespaceTranslator.navigatePath(content, resolveKey(String(lookup)))
26
+ });
27
+ };
28
+
29
+ //#endregion
30
+ exports.useDictionaryDynamic = useDictionaryDynamic;
31
+ //# sourceMappingURL=useDictionaryDynamic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["navigatePath"],"sources":["../../src/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'react-intlayer';\nimport { navigatePath } from './shared/namespaceTranslator';\n\n/**\n * Dynamic dictionary-accepting variant of `useTranslations`.\n *\n * Counterpart to {@link useDictionary} for dictionaries imported lazily per\n * locale. Used internally by the build-time optimization.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends string,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n namespacePrefix?: string\n) => {\n const content = useDictionaryDynamicBase<T, K>(dictionaryPromise, key);\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n return Object.assign(\n <P extends ValidDotPathsFor<string>>(\n lookup: P,\n params?: Record<string, unknown>\n ): string => {\n const rawValue = navigatePath(content, resolveKey(String(lookup)));\n const text = String(rawValue ?? resolveKey(String(lookup)));\n if (!params) return text;\n return text.replace(/\\{(\\w+)\\}/g, (_match, key) =>\n params[key] != null ? String(params[key]) : `{${key}}`\n );\n },\n {\n has: <P extends ValidDotPathsFor<string>>(lookup: P): boolean =>\n navigatePath(content, resolveKey(String(lookup))) != null,\n raw: <P extends ValidDotPathsFor<string>>(lookup: P): unknown =>\n navigatePath(content, resolveKey(String(lookup))),\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,wBAIX,mBACA,KACA,oBACG;CACH,MAAM,mDAAyC,mBAAmB,IAAI;CAEtE,MAAM,cAAc,cAClB,kBAAkB,GAAG,gBAAgB,GAAG,cAAc;AAExD,QAAO,OAAO,QAEV,QACA,WACW;EACX,MAAM,WAAWA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EAClE,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,OAAO,CAAC,CAAC;AAC3D,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,KAAK,QAAQ,eAAe,QAAQ,QACzC,OAAO,QAAQ,OAAO,OAAO,OAAO,KAAK,GAAG,IAAI,IAAI,GACrD;IAEH;EACE,MAA0C,WACxCA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC,IAAI;EACvD,MAA0C,WACxCA,gDAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EACpD,CACF"}
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+
3
+ import { IntlayerProvider } from "react-intlayer";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { log } from "@intlayer/config/built";
6
+ import { CYAN } from "@intlayer/config/colors";
7
+ import { colorize, getAppLogger } from "@intlayer/config/logger";
8
+
9
+ //#region src/client/IntlProvider.tsx
10
+ /**
11
+ * Drop-in for use-intl's `IntlProvider`.
12
+ *
13
+ * Wraps Intlayer's `IntlayerProvider`, seeding the client locale from the
14
+ * `locale` prop. `messages`, `formats`, `now`, `timeZone`, `onError`, and
15
+ * `getMessageFallback` are accepted for API compatibility but have no effect —
16
+ * Intlayer uses its own compiled dictionaries.
17
+ */
18
+ const IntlProvider = ({ locale, children, messages: _messages, formats: _formats, now: _now, timeZone: _timeZone, onError: _onError, getMessageFallback: _getMessageFallback }) => {
19
+ if (typeof _messages !== "undefined") getAppLogger({ log })(`${colorize("IntlProvider", CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`);
20
+ return /* @__PURE__ */ jsx(IntlayerProvider, {
21
+ locale,
22
+ children
23
+ }, String(locale));
24
+ };
25
+
26
+ //#endregion
27
+ export { IntlProvider };
28
+ //# sourceMappingURL=IntlProvider.mjs.map