gt-next 6.16.36 → 6.16.37
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 +15 -0
- package/dist/config-dir/I18NConfiguration.d.ts +2 -1
- package/dist/config-dir/I18NConfiguration.d.ts.map +1 -1
- package/dist/config-dir/I18NConfiguration.js +1 -1
- package/dist/config-dir/I18NConfiguration.js.map +1 -1
- package/dist/config-dir/props/defaultWithGTConfigProps.d.ts +1 -0
- package/dist/config-dir/props/defaultWithGTConfigProps.d.ts.map +1 -1
- package/dist/config-dir/props/defaultWithGTConfigProps.js +2 -1
- package/dist/config-dir/props/defaultWithGTConfigProps.js.map +1 -1
- package/dist/config-dir/props/withGTConfigProps.d.ts +1 -0
- package/dist/config-dir/props/withGTConfigProps.d.ts.map +1 -1
- package/dist/config-dir/props/withGTConfigProps.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/index.types.d.ts +1 -0
- package/dist/index.types.d.ts.map +1 -1
- package/dist/index.types.js +1 -0
- package/dist/index.types.js.map +1 -1
- package/dist/request/localeValidation.d.ts.map +1 -1
- package/dist/request/localeValidation.js +1 -0
- package/dist/request/localeValidation.js.map +1 -1
- package/dist/server-dir/buildtime/T.d.ts +2 -0
- package/dist/server-dir/buildtime/T.d.ts.map +1 -1
- package/dist/server-dir/buildtime/T.js +5 -1
- package/dist/server-dir/buildtime/T.js.map +1 -1
- package/dist/server-dir/buildtime/getTranslationFunction.d.ts.map +1 -1
- package/dist/server-dir/buildtime/getTranslationFunction.js +12 -5
- package/dist/server-dir/buildtime/getTranslationFunction.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# gt-next
|
|
2
2
|
|
|
3
|
+
## 6.16.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1796](https://github.com/generaltranslation/gt/pull/1796) [`9f305a9`](https://github.com/generaltranslation/gt/commit/9f305a9209acbc773015e187a7da0c5c10083a52) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Add a withGTConfig flag for disabling invalid request locale warnings.
|
|
8
|
+
|
|
9
|
+
- [#1786](https://github.com/generaltranslation/gt/pull/1786) [`6945a98`](https://github.com/generaltranslation/gt/commit/6945a9871ea260dd999dcb2246c48b21134721f6) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Add `requiresReview`
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`6945a98`](https://github.com/generaltranslation/gt/commit/6945a9871ea260dd999dcb2246c48b21134721f6)]:
|
|
12
|
+
- @generaltranslation/compiler@1.3.27
|
|
13
|
+
- generaltranslation@8.2.19
|
|
14
|
+
- gt-i18n@0.9.9
|
|
15
|
+
- gt-react@10.20.5
|
|
16
|
+
- @generaltranslation/supported-locales@2.1.5
|
|
17
|
+
|
|
3
18
|
## 6.16.36
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -26,6 +26,7 @@ type I18NConfigurationParams = {
|
|
|
26
26
|
_usingPlugin: boolean;
|
|
27
27
|
_versionId?: string;
|
|
28
28
|
customMapping?: CustomMapping | undefined;
|
|
29
|
+
disableInvalidLocaleWarning?: boolean;
|
|
29
30
|
[key: string]: unknown;
|
|
30
31
|
};
|
|
31
32
|
type RuntimeTranslationParams = {
|
|
@@ -52,7 +53,7 @@ export declare class I18NConfiguration {
|
|
|
52
53
|
private referrerLocaleCookieName;
|
|
53
54
|
private localeRoutingEnabledCookieName;
|
|
54
55
|
private resetLocaleCookieName;
|
|
55
|
-
constructor({ apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, loadTranslationsType, loadDictionaryEnabled, defaultLocale, locales, renderSettings, dictionary: _dictionary, maxConcurrentRequests, maxBatchSize, batchInterval, _usingPlugin, headersAndCookies, customMapping, ...metadata }: I18NConfigurationParams);
|
|
56
|
+
constructor({ apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, loadTranslationsType, loadDictionaryEnabled, defaultLocale, locales, renderSettings, dictionary: _dictionary, maxConcurrentRequests, maxBatchSize, batchInterval, _usingPlugin, headersAndCookies, customMapping, disableInvalidLocaleWarning: _disableInvalidLocaleWarning, ...metadata }: I18NConfigurationParams);
|
|
56
57
|
/**
|
|
57
58
|
* Get the rendering instructions
|
|
58
59
|
* @returns An object containing the current method and timeout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../src/config-dir/I18NConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,KAAK,uBAAuB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACvD,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;I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|
|
|
9
9
|
let gt_i18n_internal = require("gt-i18n/internal");
|
|
10
10
|
//#region src/config-dir/I18NConfiguration.ts
|
|
11
11
|
var I18NConfiguration = class {
|
|
12
|
-
constructor({ apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, loadTranslationsType, loadDictionaryEnabled, defaultLocale, locales, renderSettings, dictionary: _dictionary, maxConcurrentRequests, maxBatchSize, batchInterval, _usingPlugin, headersAndCookies, customMapping, ...metadata }) {
|
|
12
|
+
constructor({ apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, loadTranslationsType, loadDictionaryEnabled, defaultLocale, locales, renderSettings, dictionary: _dictionary, maxConcurrentRequests, maxBatchSize, batchInterval, _usingPlugin, headersAndCookies, customMapping, disableInvalidLocaleWarning: _disableInvalidLocaleWarning, ...metadata }) {
|
|
13
13
|
this.devApiKey = devApiKey;
|
|
14
14
|
this.projectId = projectId;
|
|
15
15
|
this.runtimeUrl = runtimeUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NConfiguration.js","names":["defaultWithGTConfigProps","I18nManager","loadTranslations","dictionaryManager","defaultLocaleCookieName"],"sources":["../../src/config-dir/I18NConfiguration.ts"],"sourcesContent":["import type { GT } from 'generaltranslation';\nimport {\n RenderMethod,\n getDefaultRenderSettings,\n defaultLocaleCookieName,\n} from 'gt-react/internal';\nimport type {\n Dictionary,\n TranslatedChildren,\n Translations,\n} from 'gt-react/internal';\nimport { defaultWithGTConfigProps } from './props/defaultWithGTConfigProps';\nimport { dictionaryManager, DictionaryManager } from './DictionaryManager';\nimport type { HeadersAndCookies } from './props/withGTConfigProps';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n defaultResetLocaleCookieName,\n} from '../utils/cookies';\nimport { defaultLocaleHeaderName } from '../utils/headers';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { I18nManager } from 'gt-i18n/internal';\nimport type { LookupOptions } from 'gt-i18n/internal/types';\nimport { loadTranslations } from './loadTranslation';\n\ntype I18NConfigurationParams = {\n apiKey?: string;\n devApiKey?: string;\n projectId?: string;\n runtimeUrl: string | undefined;\n cacheUrl: string | null;\n cacheExpiryTime?: number;\n loadTranslationsType: 'remote' | 'custom' | 'disabled';\n loadDictionaryEnabled: boolean;\n defaultLocale: string;\n locales: string[];\n renderSettings: {\n method: RenderMethod;\n timeout?: number;\n };\n maxConcurrentRequests: number;\n maxBatchSize: number;\n batchInterval: number;\n headersAndCookies: HeadersAndCookies;\n _usingPlugin: boolean;\n _versionId?: string;\n customMapping?: CustomMapping | undefined;\n [key: string]: unknown;\n};\n\ntype RuntimeTranslationParams = {\n source: TranslatedChildren;\n targetLocale: string;\n options: LookupOptions;\n};\n\nexport class I18NConfiguration {\n // Feature flags\n translationEnabled: boolean;\n developmentApiEnabled: boolean;\n productionApiEnabled: boolean;\n dictionaryEnabled: boolean;\n // Cloud integration\n projectId?: string;\n devApiKey?: string;\n runtimeUrl: string | undefined;\n // Rendering\n renderSettings: {\n method: RenderMethod;\n timeout?: number;\n };\n // Dictionaries\n private _i18nManager: I18nManager<TranslatedChildren>;\n private _dictionaryManager: DictionaryManager | undefined;\n // Headers and cookies\n private localeHeaderName: string;\n private localeCookieName: string;\n private referrerLocaleCookieName: string;\n private localeRoutingEnabledCookieName: string;\n private resetLocaleCookieName: string;\n constructor({\n // Cloud integration\n apiKey,\n devApiKey,\n projectId,\n _versionId,\n runtimeUrl,\n cacheUrl,\n cacheExpiryTime,\n loadTranslationsType,\n loadDictionaryEnabled,\n // Locale info\n defaultLocale,\n locales,\n // Render method\n renderSettings,\n // Dictionaries\n // Dictionary files are resolved by dictionaryManager; do not forward the\n // public dictionary prop as runtime translation metadata.\n dictionary: _dictionary,\n // Batching config\n maxConcurrentRequests,\n maxBatchSize,\n batchInterval,\n // Internal\n _usingPlugin,\n headersAndCookies,\n customMapping,\n // Other metadata\n ...metadata\n }: I18NConfigurationParams) {\n void _dictionary;\n\n // ----- CLOUD INTEGRATION ----- //\n\n this.devApiKey = devApiKey;\n this.projectId = projectId;\n this.runtimeUrl = runtimeUrl;\n\n // Enables locale-based translation lookups through I18nManager. Runtime API\n // availability is tracked separately by developmentApiEnabled/productionApiEnabled.\n this.translationEnabled = !!(\n (\n loadTranslationsType === 'custom' || // load local translation\n (loadTranslationsType === 'remote' &&\n this.projectId && // projectId required because it's part of the GET request\n cacheUrl) ||\n loadDictionaryEnabled\n ) // load local dictionary\n );\n\n // runtime translation enabled\n const runtimeApiEnabled = !!(this.runtimeUrl ===\n defaultWithGTConfigProps.runtimeUrl\n ? this.projectId\n : this.runtimeUrl);\n this.developmentApiEnabled = !!(\n runtimeApiEnabled &&\n this.devApiKey &&\n process.env.NODE_ENV === 'development'\n );\n this.productionApiEnabled = !!(runtimeApiEnabled && apiKey);\n\n // dictionary enabled\n this.dictionaryEnabled = _usingPlugin;\n\n // ----- SETUP ----- //\n\n // Render method\n const defaultRenderSettings = getDefaultRenderSettings(\n process.env.NODE_ENV\n );\n this.renderSettings = {\n method: renderSettings?.method || defaultRenderSettings.method,\n ...((renderSettings?.timeout !== undefined ||\n defaultRenderSettings.timeout !== undefined) && {\n timeout: renderSettings?.timeout || defaultRenderSettings.timeout,\n }),\n };\n // Translation and dictionary managers\n const shouldLoadTranslations = loadTranslationsType !== 'disabled';\n const runtimeTranslationTimeout = this.renderSettings.timeout;\n this._i18nManager = new I18nManager<TranslatedChildren>({\n apiKey,\n devApiKey,\n projectId,\n runtimeUrl,\n // Locale info\n defaultLocale,\n locales,\n // Custom mapping\n customMapping,\n enableI18n: this.translationEnabled,\n // Batching config\n batchConfig: {\n maxConcurrentRequests,\n maxBatchSize,\n batchInterval,\n },\n runtimeTranslation: {\n timeout: runtimeTranslationTimeout,\n // Other metadata\n metadata: {\n sourceLocale: defaultLocale,\n ...(runtimeTranslationTimeout && {\n timeout: runtimeTranslationTimeout,\n }),\n projectId,\n publish: true,\n fast: true,\n ...metadata,\n },\n },\n cacheUrl: shouldLoadTranslations ? cacheUrl : null,\n // Only apply cache expiry for remote translations; custom loaders manage\n // their own freshness, and historically their caches were never evicted.\n cacheExpiryTime:\n loadTranslationsType === 'remote' ? (cacheExpiryTime ?? null) : null,\n _versionId,\n environment:\n process.env.NODE_ENV === 'development' ? 'development' : 'production',\n ...(shouldLoadTranslations && {\n loadTranslations: async (locale: string) =>\n (await loadTranslations({\n targetLocale: locale,\n ...(cacheUrl && { cacheUrl }),\n ...(projectId && { projectId }),\n ...(_versionId && { _versionId }),\n })) || {},\n }),\n });\n this._dictionaryManager = dictionaryManager;\n // Headers and cookies\n this.localeHeaderName =\n headersAndCookies?.localeHeaderName || defaultLocaleHeaderName;\n this.localeCookieName =\n headersAndCookies?.localeCookieName || defaultLocaleCookieName;\n this.referrerLocaleCookieName =\n headersAndCookies?.referrerLocaleCookieName ||\n defaultReferrerLocaleCookieName;\n this.localeRoutingEnabledCookieName =\n headersAndCookies?.localeRoutingEnabledCookieName ||\n defaultLocaleRoutingEnabledCookieName;\n this.resetLocaleCookieName =\n headersAndCookies?.resetLocaleCookieName || defaultResetLocaleCookieName;\n }\n\n // ------ CONFIG ----- //\n\n /**\n * Get the rendering instructions\n * @returns An object containing the current method and timeout.\n * As of 1/22/25: method is \"skeleton\", \"replace\", \"default\".\n * Timeout is a number or null, representing no assigned timeout.\n */\n getRenderSettings(): {\n method: RenderMethod;\n timeout?: number;\n } {\n return this.renderSettings;\n }\n\n /**\n * Gets config for dynamic translation on the client side.\n */\n getClientSideConfig() {\n const {\n projectId,\n translationEnabled,\n runtimeUrl,\n devApiKey,\n developmentApiEnabled,\n dictionaryEnabled,\n renderSettings,\n localeRoutingEnabledCookieName,\n referrerLocaleCookieName,\n localeCookieName,\n resetLocaleCookieName,\n } = this;\n const customMapping = this._i18nManager.getCustomMapping();\n const _versionId = this._i18nManager.getVersionId();\n return {\n projectId,\n translationEnabled,\n runtimeUrl,\n devApiKey,\n dictionaryEnabled,\n renderSettings,\n developmentApiEnabled,\n localeRoutingEnabledCookieName,\n referrerLocaleCookieName,\n localeCookieName,\n resetLocaleCookieName,\n customMapping,\n _versionId,\n };\n }\n\n /**\n * Gets the GT class instance\n * @returns {GT} The GT class instance\n */\n getGTClass(): GT {\n return this._i18nManager.getGTClass();\n }\n\n // ----- LOCALES ----- //\n\n /**\n * Gets the application's default locale\n * @returns {string} A BCP-47 locale tag\n */\n getDefaultLocale(): string {\n return this._i18nManager.getDefaultLocale();\n }\n\n /**\n * Gets the list of approved locales for this app\n * @returns {string[]} A list of BCP-47 locale tags, or undefined if none were provided\n */\n getLocales(): string[] {\n return this._i18nManager.getLocales();\n }\n\n /**\n * Gets the version ID for the current source\n * @returns {string | undefined} The version ID, if set\n */\n getVersionId(): string | undefined {\n return this._i18nManager.getVersionId();\n }\n\n // ----- COOKIES AND HEADERS ----- //\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getLocaleHeaderName(): string {\n return this.localeHeaderName;\n }\n\n // ----- FEATURE FLAGS ----- //\n\n /**\n * @returns true if build time translation is enabled\n */\n isTranslationEnabled(): boolean {\n return this.translationEnabled;\n }\n\n /**\n * @returns true if dictionaries are enabled\n */\n isDictionaryEnabled(): boolean {\n return this.dictionaryEnabled;\n }\n\n /**\n * @returns true if development runtime translation API is enabled\n */\n isDevelopmentApiEnabled(): boolean {\n return this.developmentApiEnabled;\n }\n\n /**\n * @returns true if production runtime translation API is enabled\n */\n isProductionApiEnabled(): boolean {\n return this.productionApiEnabled;\n }\n\n // ----- UTILITY FUNCTIONS ----- //\n\n /**\n * Check if translation is required based on the user's locale\n * @param locale - The user's locale\n * @returns True if translation is required, otherwise false\n */\n requiresTranslation(locale: string): [boolean, boolean] {\n return [\n this._i18nManager.requiresTranslation(locale),\n this._i18nManager.requiresDialectTranslation(locale),\n ];\n }\n\n // ----- DICTIONARY ----- //\n // User defined translations are called dictionary\n\n /**\n * Load the user's translations for a given locale\n * @param locale - The locale set by the user\n * @returns A promise that resolves to the translations.\n */\n async getDictionaryTranslations(\n locale: string\n ): Promise<Dictionary | undefined> {\n return await this._dictionaryManager?.getDictionary(locale);\n }\n\n /**\n * Set the dictionary for a given locale\n * @param {string} locale - The locale code.\n * @param {Dictionary} dictionary - The dictionary data.\n */\n setDictionaryTranslations(locale: string, dictionary: Dictionary) {\n this._dictionaryManager?.setDictionary(locale, dictionary);\n }\n\n // ----- CACHED TRANSLATIONS ----- //\n\n /**\n * Get the translation dictionaries for this user's locale, if they exist\n * Globally shared cache or saved locally\n * @param locale - The locale set by the user\n * @returns A promise that resolves to the translations.\n */\n async getCachedTranslations(locale: string): Promise<Translations> {\n return (await this._i18nManager.loadTranslations(locale)) as Translations;\n }\n\n // ----- RUNTIME TRANSLATION ----- //\n\n lookupTranslation({\n source,\n targetLocale,\n options,\n }: RuntimeTranslationParams): TranslatedChildren | undefined {\n return this._i18nManager.lookupTranslation(targetLocale, source, options);\n }\n\n async translate({\n source,\n targetLocale,\n options,\n }: RuntimeTranslationParams): Promise<TranslatedChildren> {\n const translation = await this._i18nManager.lookupTranslationWithFallback(\n targetLocale,\n source,\n options\n );\n if (translation == null) {\n throw new Error('Translation failed.');\n }\n return translation;\n }\n}\n"],"mappings":";;;;;;;;;;AAwDA,IAAa,oBAAb,MAA+B;CAwB7B,YAAY,EAEV,QACA,WACA,WACA,YACA,YACA,UACA,iBACA,sBACA,uBAEA,eACA,SAEA,gBAIA,YAAY,aAEZ,uBACA,cACA,eAEA,cACA,mBACA,eAEA,GAAG,YACuB;AAK1B,OAAK,YAAY;AACjB,OAAK,YAAY;AACjB,OAAK,aAAa;AAIlB,OAAK,qBAAqB,CAAC,EAEvB,yBAAyB,YACxB,yBAAyB,YACxB,KAAK,aACL,YACF;EAKJ,MAAM,oBAAoB,CAAC,EAAE,KAAK,eAClCA,kDAAAA,yBAAyB,aACrB,KAAK,YACL,KAAK;AACT,OAAK,wBAAwB,CAAC,EAC5B,qBACA,KAAK,aACL,QAAQ,IAAI,aAAa;AAE3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1
|
+
{"version":3,"file":"I18NConfiguration.js","names":["defaultWithGTConfigProps","I18nManager","loadTranslations","dictionaryManager","defaultLocaleCookieName"],"sources":["../../src/config-dir/I18NConfiguration.ts"],"sourcesContent":["import type { GT } from 'generaltranslation';\nimport {\n RenderMethod,\n getDefaultRenderSettings,\n defaultLocaleCookieName,\n} from 'gt-react/internal';\nimport type {\n Dictionary,\n TranslatedChildren,\n Translations,\n} from 'gt-react/internal';\nimport { defaultWithGTConfigProps } from './props/defaultWithGTConfigProps';\nimport { dictionaryManager, DictionaryManager } from './DictionaryManager';\nimport type { HeadersAndCookies } from './props/withGTConfigProps';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n defaultResetLocaleCookieName,\n} from '../utils/cookies';\nimport { defaultLocaleHeaderName } from '../utils/headers';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport { I18nManager } from 'gt-i18n/internal';\nimport type { LookupOptions } from 'gt-i18n/internal/types';\nimport { loadTranslations } from './loadTranslation';\n\ntype I18NConfigurationParams = {\n apiKey?: string;\n devApiKey?: string;\n projectId?: string;\n runtimeUrl: string | undefined;\n cacheUrl: string | null;\n cacheExpiryTime?: number;\n loadTranslationsType: 'remote' | 'custom' | 'disabled';\n loadDictionaryEnabled: boolean;\n defaultLocale: string;\n locales: string[];\n renderSettings: {\n method: RenderMethod;\n timeout?: number;\n };\n maxConcurrentRequests: number;\n maxBatchSize: number;\n batchInterval: number;\n headersAndCookies: HeadersAndCookies;\n _usingPlugin: boolean;\n _versionId?: string;\n customMapping?: CustomMapping | undefined;\n disableInvalidLocaleWarning?: boolean;\n [key: string]: unknown;\n};\n\ntype RuntimeTranslationParams = {\n source: TranslatedChildren;\n targetLocale: string;\n options: LookupOptions;\n};\n\nexport class I18NConfiguration {\n // Feature flags\n translationEnabled: boolean;\n developmentApiEnabled: boolean;\n productionApiEnabled: boolean;\n dictionaryEnabled: boolean;\n // Cloud integration\n projectId?: string;\n devApiKey?: string;\n runtimeUrl: string | undefined;\n // Rendering\n renderSettings: {\n method: RenderMethod;\n timeout?: number;\n };\n // Dictionaries\n private _i18nManager: I18nManager<TranslatedChildren>;\n private _dictionaryManager: DictionaryManager | undefined;\n // Headers and cookies\n private localeHeaderName: string;\n private localeCookieName: string;\n private referrerLocaleCookieName: string;\n private localeRoutingEnabledCookieName: string;\n private resetLocaleCookieName: string;\n constructor({\n // Cloud integration\n apiKey,\n devApiKey,\n projectId,\n _versionId,\n runtimeUrl,\n cacheUrl,\n cacheExpiryTime,\n loadTranslationsType,\n loadDictionaryEnabled,\n // Locale info\n defaultLocale,\n locales,\n // Render method\n renderSettings,\n // Dictionaries\n // Dictionary files are resolved by dictionaryManager; do not forward the\n // public dictionary prop as runtime translation metadata.\n dictionary: _dictionary,\n // Batching config\n maxConcurrentRequests,\n maxBatchSize,\n batchInterval,\n // Internal\n _usingPlugin,\n headersAndCookies,\n customMapping,\n disableInvalidLocaleWarning: _disableInvalidLocaleWarning,\n // Other metadata\n ...metadata\n }: I18NConfigurationParams) {\n void _dictionary;\n void _disableInvalidLocaleWarning;\n\n // ----- CLOUD INTEGRATION ----- //\n\n this.devApiKey = devApiKey;\n this.projectId = projectId;\n this.runtimeUrl = runtimeUrl;\n\n // Enables locale-based translation lookups through I18nManager. Runtime API\n // availability is tracked separately by developmentApiEnabled/productionApiEnabled.\n this.translationEnabled = !!(\n (\n loadTranslationsType === 'custom' || // load local translation\n (loadTranslationsType === 'remote' &&\n this.projectId && // projectId required because it's part of the GET request\n cacheUrl) ||\n loadDictionaryEnabled\n ) // load local dictionary\n );\n\n // runtime translation enabled\n const runtimeApiEnabled = !!(this.runtimeUrl ===\n defaultWithGTConfigProps.runtimeUrl\n ? this.projectId\n : this.runtimeUrl);\n this.developmentApiEnabled = !!(\n runtimeApiEnabled &&\n this.devApiKey &&\n process.env.NODE_ENV === 'development'\n );\n this.productionApiEnabled = !!(runtimeApiEnabled && apiKey);\n\n // dictionary enabled\n this.dictionaryEnabled = _usingPlugin;\n\n // ----- SETUP ----- //\n\n // Render method\n const defaultRenderSettings = getDefaultRenderSettings(\n process.env.NODE_ENV\n );\n this.renderSettings = {\n method: renderSettings?.method || defaultRenderSettings.method,\n ...((renderSettings?.timeout !== undefined ||\n defaultRenderSettings.timeout !== undefined) && {\n timeout: renderSettings?.timeout || defaultRenderSettings.timeout,\n }),\n };\n // Translation and dictionary managers\n const shouldLoadTranslations = loadTranslationsType !== 'disabled';\n const runtimeTranslationTimeout = this.renderSettings.timeout;\n this._i18nManager = new I18nManager<TranslatedChildren>({\n apiKey,\n devApiKey,\n projectId,\n runtimeUrl,\n // Locale info\n defaultLocale,\n locales,\n // Custom mapping\n customMapping,\n enableI18n: this.translationEnabled,\n // Batching config\n batchConfig: {\n maxConcurrentRequests,\n maxBatchSize,\n batchInterval,\n },\n runtimeTranslation: {\n timeout: runtimeTranslationTimeout,\n // Other metadata\n metadata: {\n sourceLocale: defaultLocale,\n ...(runtimeTranslationTimeout && {\n timeout: runtimeTranslationTimeout,\n }),\n projectId,\n publish: true,\n fast: true,\n ...metadata,\n },\n },\n cacheUrl: shouldLoadTranslations ? cacheUrl : null,\n // Only apply cache expiry for remote translations; custom loaders manage\n // their own freshness, and historically their caches were never evicted.\n cacheExpiryTime:\n loadTranslationsType === 'remote' ? (cacheExpiryTime ?? null) : null,\n _versionId,\n environment:\n process.env.NODE_ENV === 'development' ? 'development' : 'production',\n ...(shouldLoadTranslations && {\n loadTranslations: async (locale: string) =>\n (await loadTranslations({\n targetLocale: locale,\n ...(cacheUrl && { cacheUrl }),\n ...(projectId && { projectId }),\n ...(_versionId && { _versionId }),\n })) || {},\n }),\n });\n this._dictionaryManager = dictionaryManager;\n // Headers and cookies\n this.localeHeaderName =\n headersAndCookies?.localeHeaderName || defaultLocaleHeaderName;\n this.localeCookieName =\n headersAndCookies?.localeCookieName || defaultLocaleCookieName;\n this.referrerLocaleCookieName =\n headersAndCookies?.referrerLocaleCookieName ||\n defaultReferrerLocaleCookieName;\n this.localeRoutingEnabledCookieName =\n headersAndCookies?.localeRoutingEnabledCookieName ||\n defaultLocaleRoutingEnabledCookieName;\n this.resetLocaleCookieName =\n headersAndCookies?.resetLocaleCookieName || defaultResetLocaleCookieName;\n }\n\n // ------ CONFIG ----- //\n\n /**\n * Get the rendering instructions\n * @returns An object containing the current method and timeout.\n * As of 1/22/25: method is \"skeleton\", \"replace\", \"default\".\n * Timeout is a number or null, representing no assigned timeout.\n */\n getRenderSettings(): {\n method: RenderMethod;\n timeout?: number;\n } {\n return this.renderSettings;\n }\n\n /**\n * Gets config for dynamic translation on the client side.\n */\n getClientSideConfig() {\n const {\n projectId,\n translationEnabled,\n runtimeUrl,\n devApiKey,\n developmentApiEnabled,\n dictionaryEnabled,\n renderSettings,\n localeRoutingEnabledCookieName,\n referrerLocaleCookieName,\n localeCookieName,\n resetLocaleCookieName,\n } = this;\n const customMapping = this._i18nManager.getCustomMapping();\n const _versionId = this._i18nManager.getVersionId();\n return {\n projectId,\n translationEnabled,\n runtimeUrl,\n devApiKey,\n dictionaryEnabled,\n renderSettings,\n developmentApiEnabled,\n localeRoutingEnabledCookieName,\n referrerLocaleCookieName,\n localeCookieName,\n resetLocaleCookieName,\n customMapping,\n _versionId,\n };\n }\n\n /**\n * Gets the GT class instance\n * @returns {GT} The GT class instance\n */\n getGTClass(): GT {\n return this._i18nManager.getGTClass();\n }\n\n // ----- LOCALES ----- //\n\n /**\n * Gets the application's default locale\n * @returns {string} A BCP-47 locale tag\n */\n getDefaultLocale(): string {\n return this._i18nManager.getDefaultLocale();\n }\n\n /**\n * Gets the list of approved locales for this app\n * @returns {string[]} A list of BCP-47 locale tags, or undefined if none were provided\n */\n getLocales(): string[] {\n return this._i18nManager.getLocales();\n }\n\n /**\n * Gets the version ID for the current source\n * @returns {string | undefined} The version ID, if set\n */\n getVersionId(): string | undefined {\n return this._i18nManager.getVersionId();\n }\n\n // ----- COOKIES AND HEADERS ----- //\n\n getLocaleCookieName(): string {\n return this.localeCookieName;\n }\n\n getLocaleHeaderName(): string {\n return this.localeHeaderName;\n }\n\n // ----- FEATURE FLAGS ----- //\n\n /**\n * @returns true if build time translation is enabled\n */\n isTranslationEnabled(): boolean {\n return this.translationEnabled;\n }\n\n /**\n * @returns true if dictionaries are enabled\n */\n isDictionaryEnabled(): boolean {\n return this.dictionaryEnabled;\n }\n\n /**\n * @returns true if development runtime translation API is enabled\n */\n isDevelopmentApiEnabled(): boolean {\n return this.developmentApiEnabled;\n }\n\n /**\n * @returns true if production runtime translation API is enabled\n */\n isProductionApiEnabled(): boolean {\n return this.productionApiEnabled;\n }\n\n // ----- UTILITY FUNCTIONS ----- //\n\n /**\n * Check if translation is required based on the user's locale\n * @param locale - The user's locale\n * @returns True if translation is required, otherwise false\n */\n requiresTranslation(locale: string): [boolean, boolean] {\n return [\n this._i18nManager.requiresTranslation(locale),\n this._i18nManager.requiresDialectTranslation(locale),\n ];\n }\n\n // ----- DICTIONARY ----- //\n // User defined translations are called dictionary\n\n /**\n * Load the user's translations for a given locale\n * @param locale - The locale set by the user\n * @returns A promise that resolves to the translations.\n */\n async getDictionaryTranslations(\n locale: string\n ): Promise<Dictionary | undefined> {\n return await this._dictionaryManager?.getDictionary(locale);\n }\n\n /**\n * Set the dictionary for a given locale\n * @param {string} locale - The locale code.\n * @param {Dictionary} dictionary - The dictionary data.\n */\n setDictionaryTranslations(locale: string, dictionary: Dictionary) {\n this._dictionaryManager?.setDictionary(locale, dictionary);\n }\n\n // ----- CACHED TRANSLATIONS ----- //\n\n /**\n * Get the translation dictionaries for this user's locale, if they exist\n * Globally shared cache or saved locally\n * @param locale - The locale set by the user\n * @returns A promise that resolves to the translations.\n */\n async getCachedTranslations(locale: string): Promise<Translations> {\n return (await this._i18nManager.loadTranslations(locale)) as Translations;\n }\n\n // ----- RUNTIME TRANSLATION ----- //\n\n lookupTranslation({\n source,\n targetLocale,\n options,\n }: RuntimeTranslationParams): TranslatedChildren | undefined {\n return this._i18nManager.lookupTranslation(targetLocale, source, options);\n }\n\n async translate({\n source,\n targetLocale,\n options,\n }: RuntimeTranslationParams): Promise<TranslatedChildren> {\n const translation = await this._i18nManager.lookupTranslationWithFallback(\n targetLocale,\n source,\n options\n );\n if (translation == null) {\n throw new Error('Translation failed.');\n }\n return translation;\n }\n}\n"],"mappings":";;;;;;;;;;AAyDA,IAAa,oBAAb,MAA+B;CAwB7B,YAAY,EAEV,QACA,WACA,WACA,YACA,YACA,UACA,iBACA,sBACA,uBAEA,eACA,SAEA,gBAIA,YAAY,aAEZ,uBACA,cACA,eAEA,cACA,mBACA,eACA,6BAA6B,8BAE7B,GAAG,YACuB;AAM1B,OAAK,YAAY;AACjB,OAAK,YAAY;AACjB,OAAK,aAAa;AAIlB,OAAK,qBAAqB,CAAC,EAEvB,yBAAyB,YACxB,yBAAyB,YACxB,KAAK,aACL,YACF;EAKJ,MAAM,oBAAoB,CAAC,EAAE,KAAK,eAClCA,kDAAAA,yBAAyB,aACrB,KAAK,YACL,KAAK;AACT,OAAK,wBAAwB,CAAC,EAC5B,qBACA,KAAK,aACL,QAAQ,IAAI,aAAa;AAE3B,OAAK,uBAAuB,CAAC,EAAE,qBAAqB;AAGpD,OAAK,oBAAoB;EAKzB,MAAM,yBAAA,GAAA,kBAAA,0BACJ,QAAQ,IAAI,SACb;AACD,OAAK,iBAAiB;GACpB,QAAQ,gBAAgB,UAAU,sBAAsB;GACxD,IAAK,gBAAgB,YAAY,KAAA,KAC/B,sBAAsB,YAAY,KAAA,MAAc,EAChD,SAAS,gBAAgB,WAAW,sBAAsB,SAC3D;GACF;EAED,MAAM,yBAAyB,yBAAyB;EACxD,MAAM,4BAA4B,KAAK,eAAe;AACtD,OAAK,eAAe,IAAIC,iBAAAA,YAAgC;GACtD;GACA;GACA;GACA;GAEA;GACA;GAEA;GACA,YAAY,KAAK;GAEjB,aAAa;IACX;IACA;IACA;IACD;GACD,oBAAoB;IAClB,SAAS;IAET,UAAU;KACR,cAAc;KACd,GAAI,6BAA6B,EAC/B,SAAS,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d,0BAAmC;AACjC,SAAO,KAAK;;;;;CAMd,yBAAkC;AAChC,SAAO,KAAK;;;;;;;CAUd,oBAAoB,QAAoC;AACtD,SAAO,CACL,KAAK,aAAa,oBAAoB,OAAO,EAC7C,KAAK,aAAa,2BAA2B,OAAO,CACrD;;;;;;;CAWH,MAAM,0BACJ,QACiC;AACjC,SAAO,MAAM,KAAK,oBAAoB,cAAc,OAAO;;;;;;;CAQ7D,0BAA0B,QAAgB,YAAwB;AAChE,OAAK,oBAAoB,cAAc,QAAQ,WAAW;;;;;;;;CAW5D,MAAM,sBAAsB,QAAuC;AACjE,SAAQ,MAAM,KAAK,aAAa,iBAAiB,OAAO;;CAK1D,kBAAkB,EAChB,QACA,cACA,WAC2D;AAC3D,SAAO,KAAK,aAAa,kBAAkB,cAAc,QAAQ,QAAQ;;CAG3E,MAAM,UAAU,EACd,QACA,cACA,WACwD;EACxD,MAAM,cAAc,MAAM,KAAK,aAAa,8BAC1C,cACA,QACA,QACD;AACD,MAAI,eAAe,KACjB,OAAM,IAAI,MAAM,sBAAsB;AAExC,SAAO"}
|
|
@@ -28,6 +28,7 @@ type DefaultGTConfigProps = {
|
|
|
28
28
|
experimentalEnableSSG: boolean;
|
|
29
29
|
experimentalLocaleResolution: boolean;
|
|
30
30
|
experimentalLocaleResolutionParam: string;
|
|
31
|
+
disableInvalidLocaleWarning: boolean;
|
|
31
32
|
};
|
|
32
33
|
export declare const defaultWithGTConfigProps: DefaultGTConfigProps;
|
|
33
34
|
export declare const defaultCacheExpiryTime = 60000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultWithGTConfigProps.d.ts","sourceRoot":"","sources":["../../../src/config-dir/props/defaultWithGTConfigProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,YAAY,EACb,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,iBAAiB,EAAE;QACjB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,wBAAwB,EAAE,MAAM,CAAC;QACjC,8BAA8B,EAAE,MAAM,CAAC;QACvC,qBAAqB,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,2BAA2B,EAAE,eAAe,CAAC;IAC7C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,4BAA4B,EAAE,OAAO,CAAC;IACtC,iCAAiC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultWithGTConfigProps.d.ts","sourceRoot":"","sources":["../../../src/config-dir/props/defaultWithGTConfigProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,YAAY,EACb,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,iBAAiB,EAAE;QACjB,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,wBAAwB,EAAE,MAAM,CAAC;QACjC,8BAA8B,EAAE,MAAM,CAAC;QACvC,qBAAqB,EAAE,MAAM,CAAC;KAC/B,CAAC;IACF,2BAA2B,EAAE,eAAe,CAAC;IAC7C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,4BAA4B,EAAE,OAAO,CAAC;IACtC,iCAAiC,EAAE,MAAM,CAAC;IAC1C,2BAA2B,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,oBA+B7B,CAAC;AAGX,eAAO,MAAM,sBAAsB,QAAQ,CAAC"}
|
|
@@ -35,7 +35,8 @@ const defaultWithGTConfigProps = {
|
|
|
35
35
|
disableSSGWarnings: false,
|
|
36
36
|
experimentalEnableSSG: false,
|
|
37
37
|
experimentalLocaleResolution: false,
|
|
38
|
-
experimentalLocaleResolutionParam: require_utils_constants.defaultExperimentalLocaleResolutionParam
|
|
38
|
+
experimentalLocaleResolutionParam: require_utils_constants.defaultExperimentalLocaleResolutionParam,
|
|
39
|
+
disableInvalidLocaleWarning: false
|
|
39
40
|
};
|
|
40
41
|
const defaultCacheExpiryTime = 6e4;
|
|
41
42
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultWithGTConfigProps.js","names":["defaultRuntimeApiUrl","defaultCacheUrl","libraryDefaultLocale","defaultLocaleHeaderName","defaultLocaleCookieName","defaultReferrerLocaleCookieName","defaultLocaleRoutingEnabledCookieName","defaultResetLocaleCookieName","defaultExperimentalLocaleResolutionParam"],"sources":["../../../src/config-dir/props/defaultWithGTConfigProps.ts"],"sourcesContent":["import {\n libraryDefaultLocale,\n defaultCacheUrl,\n defaultRuntimeApiUrl,\n} from 'generaltranslation/internal';\nimport {\n defaultLocaleCookieName,\n getDefaultRenderSettings,\n RenderMethod,\n} from 'gt-react/internal';\nimport { defaultLocaleHeaderName } from '../../utils/headers';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n defaultResetLocaleCookieName,\n} from '../../utils/cookies';\nimport { CompilerOptions } from './withGTConfigProps';\nimport { defaultExperimentalLocaleResolutionParam } from '../../utils/constants';\n\ntype DefaultGTConfigProps = {\n config: string;\n runtimeUrl: string;\n cacheUrl: string;\n defaultLocale: string;\n getLocale: () => Promise<string>;\n locales: string[];\n maxConcurrentRequests: number;\n maxBatchSize: number;\n batchInterval: number;\n renderSettings: {\n method: RenderMethod;\n timeout: number;\n };\n _usingPlugin: boolean;\n ignoreBrowserLocales: boolean;\n headersAndCookies: {\n localeHeaderName: string;\n localeCookieName: string;\n referrerLocaleCookieName: string;\n localeRoutingEnabledCookieName: string;\n resetLocaleCookieName: string;\n };\n experimentalCompilerOptions: CompilerOptions;\n disableSSGWarnings: boolean;\n experimentalEnableSSG: boolean;\n experimentalLocaleResolution: boolean;\n experimentalLocaleResolutionParam: string;\n};\n\nexport const defaultWithGTConfigProps: DefaultGTConfigProps = {\n config: './gt.config.json',\n runtimeUrl: defaultRuntimeApiUrl,\n cacheUrl: defaultCacheUrl,\n defaultLocale: libraryDefaultLocale,\n getLocale: async () => libraryDefaultLocale,\n locales: [] as string[],\n maxConcurrentRequests: 100,\n maxBatchSize: 25,\n batchInterval: 50,\n renderSettings: getDefaultRenderSettings(process.env.NODE_ENV),\n _usingPlugin: false,\n ignoreBrowserLocales: false,\n headersAndCookies: {\n localeHeaderName: defaultLocaleHeaderName,\n localeCookieName: defaultLocaleCookieName,\n referrerLocaleCookieName: defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName: defaultLocaleRoutingEnabledCookieName,\n resetLocaleCookieName: defaultResetLocaleCookieName,\n },\n experimentalCompilerOptions: {\n type: 'none',\n logLevel: 'warn',\n compileTimeHash: true,\n disableBuildChecks: false,\n },\n disableSSGWarnings: false,\n experimentalEnableSSG: false,\n experimentalLocaleResolution: false,\n experimentalLocaleResolutionParam: defaultExperimentalLocaleResolutionParam,\n} as const;\n\n// exported separately because it's only used in production\nexport const defaultCacheExpiryTime = 60000;\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"defaultWithGTConfigProps.js","names":["defaultRuntimeApiUrl","defaultCacheUrl","libraryDefaultLocale","defaultLocaleHeaderName","defaultLocaleCookieName","defaultReferrerLocaleCookieName","defaultLocaleRoutingEnabledCookieName","defaultResetLocaleCookieName","defaultExperimentalLocaleResolutionParam"],"sources":["../../../src/config-dir/props/defaultWithGTConfigProps.ts"],"sourcesContent":["import {\n libraryDefaultLocale,\n defaultCacheUrl,\n defaultRuntimeApiUrl,\n} from 'generaltranslation/internal';\nimport {\n defaultLocaleCookieName,\n getDefaultRenderSettings,\n RenderMethod,\n} from 'gt-react/internal';\nimport { defaultLocaleHeaderName } from '../../utils/headers';\nimport {\n defaultLocaleRoutingEnabledCookieName,\n defaultReferrerLocaleCookieName,\n defaultResetLocaleCookieName,\n} from '../../utils/cookies';\nimport { CompilerOptions } from './withGTConfigProps';\nimport { defaultExperimentalLocaleResolutionParam } from '../../utils/constants';\n\ntype DefaultGTConfigProps = {\n config: string;\n runtimeUrl: string;\n cacheUrl: string;\n defaultLocale: string;\n getLocale: () => Promise<string>;\n locales: string[];\n maxConcurrentRequests: number;\n maxBatchSize: number;\n batchInterval: number;\n renderSettings: {\n method: RenderMethod;\n timeout: number;\n };\n _usingPlugin: boolean;\n ignoreBrowserLocales: boolean;\n headersAndCookies: {\n localeHeaderName: string;\n localeCookieName: string;\n referrerLocaleCookieName: string;\n localeRoutingEnabledCookieName: string;\n resetLocaleCookieName: string;\n };\n experimentalCompilerOptions: CompilerOptions;\n disableSSGWarnings: boolean;\n experimentalEnableSSG: boolean;\n experimentalLocaleResolution: boolean;\n experimentalLocaleResolutionParam: string;\n disableInvalidLocaleWarning: boolean;\n};\n\nexport const defaultWithGTConfigProps: DefaultGTConfigProps = {\n config: './gt.config.json',\n runtimeUrl: defaultRuntimeApiUrl,\n cacheUrl: defaultCacheUrl,\n defaultLocale: libraryDefaultLocale,\n getLocale: async () => libraryDefaultLocale,\n locales: [] as string[],\n maxConcurrentRequests: 100,\n maxBatchSize: 25,\n batchInterval: 50,\n renderSettings: getDefaultRenderSettings(process.env.NODE_ENV),\n _usingPlugin: false,\n ignoreBrowserLocales: false,\n headersAndCookies: {\n localeHeaderName: defaultLocaleHeaderName,\n localeCookieName: defaultLocaleCookieName,\n referrerLocaleCookieName: defaultReferrerLocaleCookieName,\n localeRoutingEnabledCookieName: defaultLocaleRoutingEnabledCookieName,\n resetLocaleCookieName: defaultResetLocaleCookieName,\n },\n experimentalCompilerOptions: {\n type: 'none',\n logLevel: 'warn',\n compileTimeHash: true,\n disableBuildChecks: false,\n },\n disableSSGWarnings: false,\n experimentalEnableSSG: false,\n experimentalLocaleResolution: false,\n experimentalLocaleResolutionParam: defaultExperimentalLocaleResolutionParam,\n disableInvalidLocaleWarning: false,\n} as const;\n\n// exported separately because it's only used in production\nexport const defaultCacheExpiryTime = 60000;\n"],"mappings":";;;;;;;;AAkDA,MAAa,2BAAiD;CAC5D,QAAQ;CACR,YAAYA,4BAAAA;CACZ,UAAUC,4BAAAA;CACV,eAAeC,4BAAAA;CACf,WAAW,YAAYA,4BAAAA;CACvB,SAAS,EAAE;CACX,uBAAuB;CACvB,cAAc;CACd,eAAe;CACf,iBAAA,GAAA,kBAAA,0BAAyC,QAAQ,IAAI,SAAS;CAC9D,cAAc;CACd,sBAAsB;CACtB,mBAAmB;EACjB,kBAAkBC,sBAAAA;EAClB,kBAAkBC,kBAAAA;EAClB,0BAA0BC,sBAAAA;EAC1B,gCAAgCC,sBAAAA;EAChC,uBAAuBC,sBAAAA;EACxB;CACD,6BAA6B;EAC3B,MAAM;EACN,UAAU;EACV,iBAAiB;EACjB,oBAAoB;EACrB;CACD,oBAAoB;CACpB,uBAAuB;CACvB,8BAA8B;CAC9B,mCAAmCC,wBAAAA;CACnC,6BAA6B;CAC9B;AAGD,MAAa,yBAAyB"}
|
|
@@ -56,6 +56,7 @@ export type withGTConfigProps = {
|
|
|
56
56
|
locales?: string[];
|
|
57
57
|
defaultLocale?: string;
|
|
58
58
|
ignoreBrowserLocales?: boolean;
|
|
59
|
+
disableInvalidLocaleWarning?: boolean;
|
|
59
60
|
/**@deprecated Use customMapping in gt.config.json instead */
|
|
60
61
|
customMapping?: CustomMapping;
|
|
61
62
|
renderSettings?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withGTConfigProps.d.ts","sourceRoot":"","sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM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M,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,4BAA4B,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC7D,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAC9C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withGTConfigProps.js","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport { RenderMethod } from 'gt-react/internal';\n\nexport type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'babel'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport const DEPRECATED_REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getStaticLocale: 'getStaticLocalePath',\n getStaticRegion: 'getStaticRegionPath',\n getStaticDomain: 'getStaticDomainPath',\n} as const;\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n getDomain: 'getDomainPath',\n ...DEPRECATED_REQUEST_FUNCTION_TO_CONFIG_KEY,\n} as const;\n\nexport type withGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration\n apiKey?: string;\n projectId?: string;\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n // Custom mapping\n /**@deprecated Use customMapping in gt.config.json instead */\n customMapping?: CustomMapping;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n /**\n * @deprecated use experimentalCompilerOptions instead\n */\n experimentalSwcPluginOptions?: Omit<CompilerOptions, 'type'>;\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // SSG\n experimentalEnableSSG?: boolean;\n /**\n * @deprecated This option relies on unsupported Next.js internals. For\n * cacheComponents support, define custom getLocale.ts and getRegion.ts files\n * or configure getLocalePath and getRegionPath.\n */\n experimentalLocaleResolution?: boolean;\n /**\n * @deprecated Only used by deprecated experimentalLocaleResolution.\n */\n experimentalLocaleResolutionParam?: string;\n /** @deprecated */\n disableSSGWarnings?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n getDomainPath?: string;\n /** @deprecated use getLocalePath instead */\n getStaticLocalePath?: string;\n /** @deprecated use getRegionPath instead */\n getStaticRegionPath?: string;\n /** @deprecated use getDomainPath instead */\n getStaticDomainPath?: string;\n};\n"],"mappings":";;AAkCA,MAAa,4CAA4C;CACvD,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAClB;AAED,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACX,WAAW;CACX,GAAG;CACJ"}
|
|
1
|
+
{"version":3,"file":"withGTConfigProps.js","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport { RenderMethod } from 'gt-react/internal';\n\nexport type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'babel'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport const DEPRECATED_REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getStaticLocale: 'getStaticLocalePath',\n getStaticRegion: 'getStaticRegionPath',\n getStaticDomain: 'getStaticDomainPath',\n} as const;\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n getDomain: 'getDomainPath',\n ...DEPRECATED_REQUEST_FUNCTION_TO_CONFIG_KEY,\n} as const;\n\nexport type withGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration\n apiKey?: string;\n projectId?: string;\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n disableInvalidLocaleWarning?: boolean;\n // Custom mapping\n /**@deprecated Use customMapping in gt.config.json instead */\n customMapping?: CustomMapping;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n /**\n * @deprecated use experimentalCompilerOptions instead\n */\n experimentalSwcPluginOptions?: Omit<CompilerOptions, 'type'>;\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // SSG\n experimentalEnableSSG?: boolean;\n /**\n * @deprecated This option relies on unsupported Next.js internals. For\n * cacheComponents support, define custom getLocale.ts and getRegion.ts files\n * or configure getLocalePath and getRegionPath.\n */\n experimentalLocaleResolution?: boolean;\n /**\n * @deprecated Only used by deprecated experimentalLocaleResolution.\n */\n experimentalLocaleResolutionParam?: string;\n /** @deprecated */\n disableSSGWarnings?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n getDomainPath?: string;\n /** @deprecated use getLocalePath instead */\n getStaticLocalePath?: string;\n /** @deprecated use getRegionPath instead */\n getStaticRegionPath?: string;\n /** @deprecated use getDomainPath instead */\n getStaticDomainPath?: string;\n};\n"],"mappings":";;AAkCA,MAAa,4CAA4C;CACvD,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CAClB;AAED,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACX,WAAW;CACX,GAAG;CACJ"}
|
package/dist/config.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ type WithGTConfigResult<TNextConfig extends object> = TNextConfig & NextConfig;
|
|
|
40
40
|
* @param {number} [maxBatchSize=defaultInitGTProps.maxBatchSize] - Maximum translation requests in the same batch.
|
|
41
41
|
* @param {number} [batchInterval=defaultInitGTProps.batchInterval] - The interval in milliseconds between batched translation requests.
|
|
42
42
|
* @param {boolean} [ignoreBrowserLocales=defaultWithGTConfigProps.ignoreBrowserLocales] - Whether to ignore browser's preferred locales.
|
|
43
|
+
* @param {boolean} [disableInvalidLocaleWarning=defaultWithGTConfigProps.disableInvalidLocaleWarning] - Whether to disable invalid request locale warnings.
|
|
43
44
|
* @param {object} headersAndCookies - Additional headers and cookies that can be passed for extended configuration.
|
|
44
45
|
* @param {boolean} [experimentalEnableSSG=false] - Whether to enable SSG.
|
|
45
46
|
* @param {boolean} [disableSSGWarnings=defaultWithGTConfigProps.disableSSGWarnings] - Whether to disable SSG warnings. (deprecated)
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAuD9E,KAAK,kBAAkB,CAAC,WAAW,SAAS,MAAM,IAAI,WAAW,GAAG,UAAU,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAuD9E,KAAK,kBAAkB,CAAC,WAAW,SAAS,MAAM,IAAI,WAAW,GAAG,UAAU,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,YAAY,CAAC,WAAW,SAAS,MAAM,GAAG,UAAU,EAClE,UAAU,CAAC,EAAE,WAAW,EACxB,KAAK,GAAE,iBAAsB,GAC5B,kBAAkB,CAAC,WAAW,CAAC,CAwnBjC;AAGD,eAAO,MAAM,MAAM,GAChB,OAAO,iBAAiB,MACxB,WAAW,SAAS,MAAM,GAAG,UAAU,EAAE,aAAa,WAAW,oCACjC,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -53,6 +53,7 @@ let _generaltranslation_format = require("@generaltranslation/format");
|
|
|
53
53
|
* @param {number} [maxBatchSize=defaultInitGTProps.maxBatchSize] - Maximum translation requests in the same batch.
|
|
54
54
|
* @param {number} [batchInterval=defaultInitGTProps.batchInterval] - The interval in milliseconds between batched translation requests.
|
|
55
55
|
* @param {boolean} [ignoreBrowserLocales=defaultWithGTConfigProps.ignoreBrowserLocales] - Whether to ignore browser's preferred locales.
|
|
56
|
+
* @param {boolean} [disableInvalidLocaleWarning=defaultWithGTConfigProps.disableInvalidLocaleWarning] - Whether to disable invalid request locale warnings.
|
|
56
57
|
* @param {object} headersAndCookies - Additional headers and cookies that can be passed for extended configuration.
|
|
57
58
|
* @param {boolean} [experimentalEnableSSG=false] - Whether to enable SSG.
|
|
58
59
|
* @param {boolean} [disableSSGWarnings=defaultWithGTConfigProps.disableSSGWarnings] - Whether to disable SSG warnings. (deprecated)
|
|
@@ -281,7 +282,8 @@ function withGTConfig(nextConfig, props = {}) {
|
|
|
281
282
|
_GENERALTRANSLATION_DISABLE_SSG_WARNINGS: mergedConfig.disableSSGWarnings?.toString() || "false",
|
|
282
283
|
_GENERALTRANSLATION_ENABLE_SSG: mergedConfig.experimentalEnableSSG?.toString() || "false",
|
|
283
284
|
_GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION: mergedConfig.experimentalLocaleResolution?.toString() || "false",
|
|
284
|
-
_GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION_PARAM: mergedConfig.experimentalLocaleResolutionParam
|
|
285
|
+
_GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION_PARAM: mergedConfig.experimentalLocaleResolutionParam,
|
|
286
|
+
_GENERALTRANSLATION_DISABLE_INVALID_LOCALE_WARNING: mergedConfig.disableInvalidLocaleWarning?.toString() || "false"
|
|
285
287
|
},
|
|
286
288
|
...turboPackEnabled && !experimentalTurbopack && { turbopack: {
|
|
287
289
|
...internalNextConfig.turbopack,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["defaultWithGTConfigProps","conflictingConfigurationBuildError","createGTCompilerUnresolvedWarning","resolveConfigFilepath","resolveRequestFunctionPaths","createBadFilepathWarning","unresolvedLoadDictionaryBuildError","unresolvedLoadTranslationsBuildError","defaultCacheExpiryTime","deprecatedLocaleMappingWarning","invalidLocalesError","invalidCanonicalLocalesError","projectIdMissingWarn","devApiKeyIncludedInProductionError","APIKeyMissingWarn","standardizedLocalesWarning","standardizedCanonicalLocalesWarning","path","REQUEST_FUNCTION_ALIASES","turboConfigStable","rootParamStability"],"sources":["../src/config.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport type { NextConfig } from 'next';\nimport {\n defaultWithGTConfigProps,\n defaultCacheExpiryTime,\n} from './config-dir/props/defaultWithGTConfigProps';\nimport { type withGTConfigProps } from './config-dir/props/withGTConfigProps';\nimport {\n APIKeyMissingWarn,\n conflictingConfigurationBuildError,\n createBadFilepathWarning,\n createGTCompilerUnresolvedWarning,\n deprecatedLocaleMappingWarning,\n devApiKeyIncludedInProductionError,\n invalidCanonicalLocalesError,\n invalidLocalesError,\n projectIdMissingWarn,\n standardizedCanonicalLocalesWarning,\n standardizedLocalesWarning,\n unresolvedLoadDictionaryBuildError,\n unresolvedLoadTranslationsBuildError,\n} from './errors/createErrors';\nimport {\n getLocaleProperties,\n isValidLocale,\n standardizeLocale,\n} from '@generaltranslation/format';\nimport {\n rootParamStability,\n turboConfigStable,\n} from './plugin/getStableNextVersionInfo';\nimport { validateCompiler } from './config-dir/utils/validateCompiler';\nimport {\n REQUEST_FUNCTION_ALIASES,\n resolveRequestFunctionPaths,\n} from './config-dir/utils/resolveRequestFunctionPaths';\nimport { resolveConfigFilepath } from './config-dir/utils/resolveConfigFilepath';\nimport { ssgChecks } from './plugin/checks/ssgChecks';\nimport { cacheComponentsChecks } from './plugin/checks/cacheComponentsChecks';\n\ntype AutoderiveConfig = boolean | { jsx?: boolean; strings?: boolean };\n\ntype ConfigFileShape = {\n files?: {\n gt?: {\n parsingFlags?: {\n autoderive?: AutoderiveConfig;\n autoDerive?: AutoderiveConfig;\n };\n };\n };\n};\n\ntype InternalGTConfigProps = withGTConfigProps &\n ConfigFileShape & {\n devApiKey?: string;\n loadDictionaryEnabled?: boolean;\n loadTranslationsType?: 'remote' | 'custom' | 'disabled';\n _dictionaryFileType?: string;\n };\n\ntype WithGTConfigResult<TNextConfig extends object> = TNextConfig & NextConfig;\n\n/**\n * Initializes General Translation settings for a Next.js application.\n *\n * Use it in `next.config.js` to enable GT translation functionality as a plugin.\n *\n * @example\n * // In next.config.ts\n * import { withGTConfig } from 'gt-next/config';\n * import type { NextConfig } from 'next';\n *\n * const nextConfig = {\n * reactStrictMode: true,\n * } satisfies NextConfig;\n *\n * export default withGTConfig(nextConfig, {\n * projectId: 'abc-123',\n * locales: ['en', 'es', 'fr'],\n * defaultLocale: 'en'\n * })\n *\n * @param {string|undefined} config - Optional config filepath (defaults to './gt.config.json'). If a file is found, it will be parsed for GT config variables.\n * @param {string|undefined} dictionary - Optional dictionary configuration file path. If a string is provided, it will be used as a path.\n * @param {string} [apiKey=defaultInitGTProps.apiKey] - API key for the GeneralTranslation service. Required if using the default GT base URL.\n * @param {string} [devApiKey=defaultInitGTProps.devApiKey] - API key for dev environment only.\n * @param {string} [projectId=defaultInitGTProps.projectId] - Project ID for the GeneralTranslation service. Required for most functionality.\n * @param {string|null} [runtimeUrl=defaultInitGTProps.runtimeUrl] - The base URL for the GT API. Set to an empty string to disable automatic translations. Set to null to disable.\n * @param {string|null} [cacheUrl=defaultInitGTProps.cacheUrl] - The URL for cached translations. Set to null to disable.\n * @param {string[]|undefined} - Whether to use local translations.\n * @param {string[]} [locales=defaultInitGTProps.locales] - List of supported locales for the application.\n * @param {string} [defaultLocale=defaultInitGTProps.defaultLocale] - The default locale to use if none is specified.\n * @param {string|undefined} [getLocalePath=\"getLocale\"] - The path to the custom getLocale function.\n * @param {string|undefined} [getRegionPath=\"getRegion\"] - The path to the custom getRegion function.\n * @param {string|undefined} [getDomainPath=\"getDomain\"] - The path to the custom getDomain function.\n * @param {object} [renderSettings=defaultInitGTProps.renderSettings] - Render settings for how translations should be handled.\n * @param {number} [cacheExpiryTime] - The time in milliseconds for how long translations should be cached.\n * @param {number} [maxConcurrentRequests=defaultInitGTProps.maxConcurrentRequests] - Maximum number of concurrent requests allowed.\n * @param {number} [maxBatchSize=defaultInitGTProps.maxBatchSize] - Maximum translation requests in the same batch.\n * @param {number} [batchInterval=defaultInitGTProps.batchInterval] - The interval in milliseconds between batched translation requests.\n * @param {boolean} [ignoreBrowserLocales=defaultWithGTConfigProps.ignoreBrowserLocales] - Whether to ignore browser's preferred locales.\n * @param {object} headersAndCookies - Additional headers and cookies that can be passed for extended configuration.\n * @param {boolean} [experimentalEnableSSG=false] - Whether to enable SSG.\n * @param {boolean} [disableSSGWarnings=defaultWithGTConfigProps.disableSSGWarnings] - Whether to disable SSG warnings. (deprecated)\n * @param {string|undefined} [getStaticLocalePath=\"getStaticLocale\"] - The path to the static getLocale function. (deprecated)\n * @param {string|undefined} [getStaticRegionPath=\"getStaticRegion\"] - The path to the static getRegion function. (deprecated)\n * @param {string|undefined} [getStaticDomainPath=\"getStaticDomain\"] - The path to the static getDomain function. (deprecated)\n * @param {boolean} [experimentalLocaleResolution=defaultWithGTConfigProps.experimentalLocaleResolution] - Deprecated. Uses unsupported Next.js internals to infer locale from root params.\n * @param {string|undefined} [experimentalLocaleResolutionParam=defaultWithGTConfigProps.experimentalLocaleResolutionParam] - Deprecated. Only used by experimentalLocaleResolution.\n * @param {object} metadata - Additional metadata that can be passed for extended configuration.\n *\n * @param {object} nextConfig - The Next.js configuration object to extend\n * @param {withGTConfigProps} props - General Translation configuration properties\n * @returns {NextConfig} - An updated Next.js config with GT settings applied\n *\n * @throws {Error} If the project ID is missing and default URLs are used, or if the API key is required and missing.\n */\nexport function withGTConfig<TNextConfig extends object = NextConfig>(\n nextConfig?: TNextConfig,\n props: withGTConfigProps = {}\n): WithGTConfigResult<TNextConfig> {\n const internalNextConfig = (nextConfig ?? {}) as unknown as NextConfig;\n\n // ---------- LOAD GT CONFIG FILE ---------- //\n\n let loadedConfig: Partial<InternalGTConfigProps> = {};\n try {\n let configPath: string | undefined;\n if (props.config) {\n configPath = props.config;\n } else if (fs.existsSync(defaultWithGTConfigProps.config)) {\n configPath = defaultWithGTConfigProps.config;\n } else if (fs.existsSync('./.gt/gt.config.json')) {\n // Support config under .gt for parity with .locadex\n configPath = './.gt/gt.config.json';\n } else if (fs.existsSync('./.locadex/gt.config.json')) {\n // Backward compatibility: support legacy .locadex directory\n configPath = './.locadex/gt.config.json';\n }\n if (typeof configPath === 'string' && fs.existsSync(configPath)) {\n const fileContent = fs.readFileSync(configPath, 'utf-8');\n loadedConfig = JSON.parse(fileContent);\n }\n } catch (error) {\n console.error('Error reading GT config file:', error);\n }\n\n // ---------- LOAD ENVIRONMENT VARIABLES ---------- //\n\n // resolve project ID\n const projectId: string | undefined = process.env.GT_PROJECT_ID;\n\n // resolve API keys\n const envApiKey: string | undefined =\n process.env.NODE_ENV === 'production'\n ? process.env.GT_API_KEY\n : process.env.GT_DEV_API_KEY || process.env.GT_API_KEY;\n let apiKey, devApiKey;\n if (envApiKey) {\n const apiKeyType = envApiKey?.split('-')?.[1];\n if (apiKeyType === 'api') {\n apiKey = envApiKey;\n } else if (apiKeyType === 'dev') {\n devApiKey = envApiKey;\n }\n }\n\n // conditionally add environment variables to config\n const envConfig: Partial<InternalGTConfigProps> = {\n ...(projectId ? { projectId } : {}),\n ...(apiKey ? { apiKey } : {}),\n ...(devApiKey ? { devApiKey } : {}),\n };\n\n // ---------- CHECK FOR CONFIG CONFLICTS ---------- //\n\n // Check for conflicts between config and params\n const propsRecord = props as Record<string, unknown>;\n const conflicts = Object.entries(loadedConfig)\n .filter(([key, value]) => {\n // Skip if key doesn't exist in props\n if (!(key in props)) return false;\n\n const propValue = propsRecord[key];\n\n // Handle null/undefined values\n if (value == null || propValue == null) {\n return value !== propValue;\n }\n\n // Handle primitive types (string, number, boolean)\n if (typeof value !== 'object') {\n return value !== propValue;\n }\n\n // Handle arrays (no need for deep equality check)\n if (Array.isArray(value)) {\n if (!Array.isArray(propValue)) return true;\n if (value.length !== propValue.length) return true;\n return value.some((v, i) => v !== propValue[i]);\n }\n\n // Handle objects\n if (typeof value === 'object' && typeof propValue === 'object') {\n const valueRecord = value as Record<string, unknown>;\n const propRecord = propValue as Record<string, unknown>;\n const valueKeys = Object.keys(valueRecord);\n const propKeys = Object.keys(propRecord);\n const keys = new Set([...valueKeys, ...propKeys]);\n\n // Objects must match exactly (no need to go deeper)\n if (valueKeys.length !== propKeys.length) return true;\n return !Array.from(keys).every((k) => valueRecord[k] === propRecord[k]);\n }\n\n return false;\n })\n .map(\n ([key, value]) =>\n `- Key: ${key} Next Config: ${JSON.stringify(propsRecord[key])} does not match GT Config: ${JSON.stringify(value)}`\n );\n\n if (conflicts.length) {\n throw new Error(conflictingConfigurationBuildError(conflicts));\n }\n\n // ---------- MERGE CONFIGS ---------- //\n\n // Merge cookie and header names\n const mergedHeadersAndCookies = {\n ...defaultWithGTConfigProps.headersAndCookies,\n ...props.headersAndCookies,\n };\n\n // Merge experimentalSwcPluginOptions\n const mergedExperimentalCompilerOptions = {\n ...defaultWithGTConfigProps.experimentalCompilerOptions,\n ...props.experimentalSwcPluginOptions,\n ...props.experimentalCompilerOptions,\n };\n\n // precedence: input > env > config file > defaults\n const mergedConfig: InternalGTConfigProps = {\n ...defaultWithGTConfigProps,\n ...loadedConfig,\n ...envConfig,\n ...props,\n headersAndCookies: mergedHeadersAndCookies,\n experimentalCompilerOptions: mergedExperimentalCompilerOptions,\n _usingPlugin: true, // flag to indicate plugin usage\n };\n\n // clear up any issues with the compiler options\n validateCompiler(mergedConfig);\n\n // ----------- RESOLVE ANY EXTERNAL FILES ----------- //\n\n // Resolve wasm filepath\n const turboPackEnabled = !!process.env.TURBOPACK;\n let resolvedWasmFilePath = '';\n if (mergedConfig.experimentalCompilerOptions?.type === 'swc') {\n try {\n if (turboPackEnabled) {\n const absolutePath = path.resolve(__dirname, './gt_swc_plugin.wasm');\n resolvedWasmFilePath =\n './' + path.relative(process.cwd(), absolutePath).replace(/\\\\/g, '/');\n } else {\n resolvedWasmFilePath = path.resolve(__dirname, './gt_swc_plugin.wasm');\n }\n } catch (error) {\n console.error(\n createGTCompilerUnresolvedWarning('swc'),\n 'Error message:',\n error\n );\n resolvedWasmFilePath = '';\n mergedConfig.experimentalCompilerOptions.type = 'none';\n }\n }\n\n // Resolve dictionary filepath\n let resolvedDictionaryFilePath =\n typeof mergedConfig.dictionary === 'string'\n ? mergedConfig.dictionary\n : resolveConfigFilepath('dictionary', ['.ts', '.js', '.json']); // fallback to dictionary\n\n // Check [defaultLocale].json file\n if (!resolvedDictionaryFilePath && mergedConfig.defaultLocale) {\n resolvedDictionaryFilePath = resolveConfigFilepath(\n mergedConfig.defaultLocale,\n ['.json']\n );\n\n // Check [defaultLanguageCode].json file\n if (!resolvedDictionaryFilePath) {\n const defaultLanguage = getLocaleProperties(\n mergedConfig.defaultLocale\n )?.languageCode;\n\n if (defaultLanguage && defaultLanguage !== mergedConfig.defaultLocale) {\n resolvedDictionaryFilePath = resolveConfigFilepath(defaultLanguage, [\n '.json',\n ]);\n }\n }\n }\n\n // Get the type of dictionary file\n const resolvedDictionaryFilePathType = resolvedDictionaryFilePath\n ? path.extname(resolvedDictionaryFilePath)\n : undefined;\n if (resolvedDictionaryFilePathType) {\n mergedConfig._dictionaryFileType = resolvedDictionaryFilePathType;\n }\n\n // Resolve custom dictionary loader path\n const customLoadDictionaryPath =\n typeof mergedConfig.loadDictionaryPath === 'string'\n ? mergedConfig.loadDictionaryPath\n : resolveConfigFilepath('loadDictionary');\n\n // Resolve custom translation loader path\n const customLoadTranslationsPath =\n typeof mergedConfig.loadTranslationsPath === 'string'\n ? mergedConfig.loadTranslationsPath\n : resolveConfigFilepath('loadTranslations');\n\n // Resolve request function paths\n const requestFunctionPaths = resolveRequestFunctionPaths(mergedConfig);\n\n // Warn if found in /app directory\n if (\n !resolvedDictionaryFilePath &&\n resolveConfigFilepath('dictionary', ['.ts', '.js', '.json'], undefined, [\n './app',\n './src/app',\n ])\n ) {\n console.warn(\n createBadFilepathWarning('dictionary', ['./app', './src/app'])\n );\n }\n\n if (\n !customLoadDictionaryPath &&\n resolveConfigFilepath(\n 'loadDictionary',\n ['.ts', '.js', '.json'],\n undefined,\n ['./app', './src/app']\n )\n ) {\n console.warn(\n createBadFilepathWarning('loadDictionary', ['./app', './src/app'])\n );\n }\n\n if (\n !customLoadTranslationsPath &&\n resolveConfigFilepath(\n 'loadTranslations',\n ['.ts', '.js', '.json'],\n undefined,\n ['./app', './src/app']\n )\n ) {\n console.warn(\n createBadFilepathWarning('loadTranslations', ['./app', './src/app'])\n );\n }\n\n // ----------- LOCALE STANDARDIZATION ----------- //\n\n // Check if using Services\n const gtRuntimeTranslationEnabled = !!(\n mergedConfig.runtimeUrl === defaultWithGTConfigProps.runtimeUrl &&\n ((process.env.NODE_ENV === 'production' && mergedConfig.apiKey) ||\n (process.env.NODE_ENV === 'development' && mergedConfig.devApiKey))\n );\n const gtRemoteCacheEnabled = !!(\n mergedConfig.cacheUrl === defaultWithGTConfigProps.cacheUrl &&\n mergedConfig.loadTranslationsType === 'remote'\n );\n const gtServicesEnabled = !!(\n (gtRuntimeTranslationEnabled || gtRemoteCacheEnabled) &&\n mergedConfig.projectId\n );\n\n // Standardize locales\n if (mergedConfig.locales && mergedConfig.defaultLocale) {\n mergedConfig.locales.unshift(mergedConfig.defaultLocale);\n }\n const updatedLocales: string[] = [];\n mergedConfig.locales = Array.from(new Set(mergedConfig.locales)).map(\n (locale) => {\n const updatedLocale = gtServicesEnabled\n ? standardizeLocale(locale)\n : locale;\n if (updatedLocale !== locale) {\n updatedLocales.push(`${locale} -> ${updatedLocale}`);\n }\n return updatedLocale;\n }\n );\n\n // Standardize canonical locales\n const updatedCanonicalLocales: string[] = [];\n if (mergedConfig.customMapping) {\n mergedConfig.customMapping = Object.fromEntries(\n Object.entries(mergedConfig.customMapping).map(([key, value]) => {\n if (typeof value !== 'object' || !('code' in value)) {\n return [key, value];\n }\n const updatedLocale = gtServicesEnabled\n ? standardizeLocale((value as { code: string }).code)\n : (value as { code: string }).code;\n if (updatedLocale !== (value as { code: string }).code) {\n updatedCanonicalLocales.push(`${key} -> ${updatedLocale}`);\n }\n return [\n key,\n {\n ...value,\n code: updatedLocale,\n },\n ];\n })\n );\n }\n\n // Run SSG checks\n ssgChecks(mergedConfig, requestFunctionPaths);\n\n // Run cache component checks\n cacheComponentsChecks({\n mergedConfig,\n nextConfig: internalNextConfig,\n requestFunctionPaths,\n localTranslationsEnabled: !!customLoadTranslationsPath,\n localDictionaryEnabled: !!customLoadDictionaryPath,\n });\n\n // ---------- DERIVED CONFIG ATTRIBUTES ---------- //\n\n // Local dictionary flag\n if (customLoadDictionaryPath) {\n // Check: file exists if provided\n if (!fs.existsSync(path.resolve(customLoadDictionaryPath))) {\n throw new Error(\n unresolvedLoadDictionaryBuildError(customLoadDictionaryPath)\n );\n } else {\n mergedConfig.loadDictionaryEnabled = true;\n }\n } else {\n mergedConfig.loadDictionaryEnabled = false;\n }\n\n // Local translations flag\n if (customLoadTranslationsPath) {\n // Check: file exists if provided\n if (!fs.existsSync(path.resolve(customLoadTranslationsPath))) {\n throw new Error(\n unresolvedLoadTranslationsBuildError(customLoadTranslationsPath)\n );\n } else {\n mergedConfig.loadTranslationsType = 'custom';\n }\n } else {\n mergedConfig.loadTranslationsType = 'remote';\n }\n\n // Set default cache expiry if and only if no dev key\n if (\n mergedConfig.loadTranslationsType == 'remote' &&\n !mergedConfig.devApiKey &&\n typeof mergedConfig.cacheExpiryTime === 'undefined'\n ) {\n mergedConfig.cacheExpiryTime = defaultCacheExpiryTime;\n }\n\n // ---------- ERROR CHECKS ---------- //\n\n // Check: using deprecated localeMapping\n if (props.customMapping) {\n console.warn(deprecatedLocaleMappingWarning);\n }\n\n // Check: invalid locale\n if (!mergedConfig.customMapping && gtServicesEnabled) {\n const invalidLocales: string[] = [];\n mergedConfig.locales.forEach((locale) => {\n if (!isValidLocale(locale)) {\n invalidLocales.push(locale);\n }\n });\n if (invalidLocales.length) {\n throw new Error(invalidLocalesError(invalidLocales));\n }\n }\n\n // Check: invalid canonical locale\n if (mergedConfig.customMapping && gtServicesEnabled) {\n const invalidCanonicalLocales: string[] = [];\n mergedConfig.locales.forEach((locale) => {\n if (!isValidLocale(locale, mergedConfig.customMapping)) {\n invalidCanonicalLocales.push(locale);\n }\n });\n if (invalidCanonicalLocales.length) {\n throw new Error(invalidCanonicalLocalesError(invalidCanonicalLocales));\n }\n }\n\n // Check: projectId is not required for remote infrastructure, but warn if missing for dev, nothing for prod\n if (\n (mergedConfig.cacheUrl || mergedConfig.runtimeUrl) &&\n !mergedConfig.projectId &&\n process.env.NODE_ENV === 'development' &&\n mergedConfig.loadTranslationsType === 'remote' &&\n !mergedConfig.loadDictionaryEnabled // skip warn if using local dictionary\n ) {\n console.warn(projectIdMissingWarn);\n }\n\n // Check: dev API key should not be included in production\n if (process.env.NODE_ENV === 'production' && mergedConfig.devApiKey) {\n throw new Error(devApiKeyIncludedInProductionError);\n }\n\n // Check: An API key is required for runtime translation\n if (\n mergedConfig.projectId && // must have projectId for this check to matter anyways\n mergedConfig.runtimeUrl &&\n !(mergedConfig.apiKey || mergedConfig.devApiKey) &&\n process.env.NODE_ENV === 'development'\n ) {\n console.warn(APIKeyMissingWarn);\n }\n\n // Check: if using GT infrastructure, warn about unsupported locales\n if (gtServicesEnabled) {\n // Warn about standardized locales\n if (updatedLocales.length) {\n console.warn(standardizedLocalesWarning(updatedLocales));\n }\n\n // Warn about standardized canonical locales\n if (updatedCanonicalLocales.length) {\n console.warn(\n standardizedCanonicalLocalesWarning(updatedCanonicalLocales)\n );\n }\n }\n\n // ---------- STORE CONFIGURATIONS ---------- //\n const I18NConfigParams = JSON.stringify(mergedConfig);\n\n const { type: _type, ...compilerOptions } =\n mergedConfig.experimentalCompilerOptions || {};\n\n // Read autoderive from parsingFlags (single source of truth shared with CLI)\n const rawAutoderive: boolean | { jsx?: boolean; strings?: boolean } =\n loadedConfig?.files?.gt?.parsingFlags?.autoderive ??\n loadedConfig?.files?.gt?.parsingFlags?.autoDerive ??\n false;\n const autoderiveJsx =\n typeof rawAutoderive === 'boolean'\n ? rawAutoderive\n : (rawAutoderive.jsx ?? false);\n const autoderiveStrings =\n typeof rawAutoderive === 'boolean'\n ? rawAutoderive\n : (rawAutoderive.strings ?? false);\n\n const swcPluginOptions: Record<string, unknown> = {\n ...compilerOptions,\n autoderiveJsx,\n autoderiveStrings,\n };\n\n const swcPluginEntry: [string, Record<string, unknown>] | null =\n mergedConfig.experimentalCompilerOptions?.type === 'swc'\n ? [resolvedWasmFilePath, swcPluginOptions]\n : null;\n\n const turboAliases = {\n 'gt-next/_dictionary': resolvedDictionaryFilePath || '',\n 'gt-next/_load-translations': customLoadTranslationsPath || '',\n 'gt-next/_load-dictionary': customLoadDictionaryPath || '',\n ...Object.fromEntries(\n Object.entries(requestFunctionPaths).map(([functionName, path]) => {\n return [\n REQUEST_FUNCTION_ALIASES[\n functionName as keyof typeof REQUEST_FUNCTION_ALIASES\n ],\n path,\n ];\n })\n ),\n };\n\n // experimental.turbo is deprecated in next@15.3.0.\n // Check for experimental.turbo. If we write to turbopack field, experimental fields will be ignored.\n // Yet, if there are other resolveAlias fields, we don't want to be ignored either.\n const experimentalTurbopack = !(\n turboConfigStable &&\n (!internalNextConfig.experimental?.turbo ||\n internalNextConfig.turbopack?.resolveAlias)\n );\n\n const config: NextConfig = {\n ...internalNextConfig,\n env: {\n ...internalNextConfig.env,\n _GENERALTRANSLATION_I18N_CONFIG_PARAMS: I18NConfigParams,\n ...(resolvedDictionaryFilePathType && {\n _GENERALTRANSLATION_DICTIONARY_FILE_TYPE:\n resolvedDictionaryFilePathType,\n }),\n _GENERALTRANSLATION_LOCAL_DICTIONARY_ENABLED:\n mergedConfig.loadDictionaryEnabled.toString(),\n _GENERALTRANSLATION_LOCAL_TRANSLATION_ENABLED: (\n mergedConfig.loadTranslationsType === 'custom'\n ).toString(),\n _GENERALTRANSLATION_DEFAULT_LOCALE: (\n mergedConfig.defaultLocale ||\n defaultWithGTConfigProps.defaultLocale ||\n ''\n ).toString(),\n _GENERALTRANSLATION_GT_SERVICES_ENABLED: gtServicesEnabled.toString(),\n _GENERALTRANSLATION_IGNORE_BROWSER_LOCALES:\n mergedConfig.ignoreBrowserLocales?.toString() ||\n defaultWithGTConfigProps.ignoreBrowserLocales?.toString() ||\n 'false',\n _GENERALTRANSLATION_CUSTOM_GET_LOCALE_ENABLED:\n requestFunctionPaths.getLocale ? 'true' : 'false',\n _GENERALTRANSLATION_CUSTOM_GET_REGION_ENABLED:\n requestFunctionPaths.getRegion ? 'true' : 'false',\n _GENERALTRANSLATION_CUSTOM_GET_DOMAIN_ENABLED:\n requestFunctionPaths.getDomain ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_LOCALE_ENABLED:\n requestFunctionPaths.getStaticLocale ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_REGION_ENABLED:\n requestFunctionPaths.getStaticRegion ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_DOMAIN_ENABLED:\n requestFunctionPaths.getStaticDomain ? 'true' : 'false',\n _GENERALTRANSLATION_DISABLE_SSG_WARNINGS:\n mergedConfig.disableSSGWarnings?.toString() || 'false',\n _GENERALTRANSLATION_ENABLE_SSG:\n mergedConfig.experimentalEnableSSG?.toString() || 'false',\n _GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION:\n mergedConfig.experimentalLocaleResolution?.toString() || 'false',\n _GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION_PARAM:\n mergedConfig.experimentalLocaleResolutionParam,\n },\n ...(turboPackEnabled &&\n !experimentalTurbopack && {\n turbopack: {\n ...internalNextConfig.turbopack,\n resolveAlias: {\n ...internalNextConfig.turbopack?.resolveAlias,\n ...turboAliases,\n },\n },\n }),\n experimental: {\n ...internalNextConfig.experimental,\n ...(rootParamStability === 'experimental' && {\n rootParams: true,\n }),\n swcPlugins: [\n ...(internalNextConfig.experimental?.swcPlugins || []),\n ...(swcPluginEntry ? [swcPluginEntry] : []),\n ],\n ...(turboPackEnabled &&\n experimentalTurbopack && {\n turbo: {\n ...internalNextConfig.experimental?.turbo,\n resolveAlias: {\n ...internalNextConfig.experimental?.turbo?.resolveAlias,\n ...turboAliases,\n },\n },\n }),\n },\n webpack: function webpack(\n ...[webpackConfig, options]: Parameters<\n NonNullable<NextConfig['webpack']>\n >\n ) {\n // Only apply webpack aliases if we're using webpack (not Turbopack)\n if (!turboPackEnabled) {\n // Try to load GT compiler if available\n if (mergedConfig.experimentalCompilerOptions?.type === 'babel') {\n try {\n const {\n webpack: gtUnplugin,\n } = require('@generaltranslation/compiler');\n webpackConfig.plugins.unshift(\n gtUnplugin(mergedConfig.experimentalCompilerOptions || {})\n );\n } catch (e) {\n mergedConfig.experimentalCompilerOptions.type = 'none';\n console.warn(\n createGTCompilerUnresolvedWarning('babel'),\n 'Error message:',\n e\n );\n }\n }\n\n // Disable cache in dev bc people might move around loadTranslations() and loadDictionary() files\n if (process.env.NODE_ENV === 'development') {\n webpackConfig.cache = false;\n }\n if (resolvedDictionaryFilePath) {\n webpackConfig.resolve.alias['gt-next/_dictionary'] = path.resolve(\n webpackConfig.context,\n resolvedDictionaryFilePath\n );\n }\n if (customLoadTranslationsPath) {\n webpackConfig.resolve.alias[`gt-next/_load-translations`] =\n path.resolve(webpackConfig.context, customLoadTranslationsPath);\n }\n if (customLoadDictionaryPath) {\n webpackConfig.resolve.alias[`gt-next/_load-dictionary`] =\n path.resolve(webpackConfig.context, customLoadDictionaryPath);\n }\n for (const [functionName, pathString] of Object.entries(\n requestFunctionPaths\n )) {\n const key =\n REQUEST_FUNCTION_ALIASES[\n functionName as keyof typeof REQUEST_FUNCTION_ALIASES\n ];\n webpackConfig.resolve.alias[key] = path.resolve(\n webpackConfig.context,\n pathString\n );\n }\n }\n if (typeof internalNextConfig?.webpack === 'function') {\n return internalNextConfig.webpack(webpackConfig, options);\n }\n return webpackConfig;\n },\n };\n return config as WithGTConfigResult<TNextConfig>;\n}\n\n// Keep initGT for backward compatibility\nexport const initGT =\n (props: withGTConfigProps) =>\n <TNextConfig extends object = NextConfig>(nextConfig?: TNextConfig) =>\n withGTConfig(nextConfig, props);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuHA,SAAgB,aACd,YACA,QAA2B,EAAE,EACI;CACjC,MAAM,qBAAsB,cAAc,EAAE;CAI5C,IAAI,eAA+C,EAAE;AACr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aAAa,+BAA+B,EAAE,CAAC,CAC3D;aACM,GAAG;AACV,kBAAa,4BAA4B,OAAO;AAChD,aAAQ,KACNlB,4BAAAA,kCAAkC,QAAQ,EAC1C,kBACA,EACD;;AAKL,QAAI,QAAQ,IAAI,aAAa,cAC3B,eAAc,QAAQ;AAExB,QAAI,2BACF,eAAc,QAAQ,MAAM,yBAAyB,KAAA,QAAK,QACxD,cAAc,SACd,2BACD;AAEH,QAAI,2BACF,eAAc,QAAQ,MAAM,gCAC1B,KAAA,QAAK,QAAQ,cAAc,SAAS,2BAA2B;AAEnE,QAAI,yBACF,eAAc,QAAQ,MAAM,8BAC1B,KAAA,QAAK,QAAQ,cAAc,SAAS,yBAAyB;AAEjE,SAAK,MAAM,CAAC,cAAc,eAAe,OAAO,QAC9C,qBACD,EAAE;KACD,MAAM,MACJgB,qDAAAA,yBACE;AAEJ,mBAAc,QAAQ,MAAM,OAAO,KAAA,QAAK,QACtC,cAAc,SACd,WACD;;;AAGL,OAAI,OAAO,oBAAoB,YAAY,WACzC,QAAO,mBAAmB,QAAQ,eAAe,QAAQ;AAE3D,UAAO;;EAGE;;AAIf,MAAa,UACV,WACyC,eACxC,aAAa,YAAY,MAAM"}
|
|
1
|
+
{"version":3,"file":"config.js","names":["defaultWithGTConfigProps","conflictingConfigurationBuildError","createGTCompilerUnresolvedWarning","resolveConfigFilepath","resolveRequestFunctionPaths","createBadFilepathWarning","unresolvedLoadDictionaryBuildError","unresolvedLoadTranslationsBuildError","defaultCacheExpiryTime","deprecatedLocaleMappingWarning","invalidLocalesError","invalidCanonicalLocalesError","projectIdMissingWarn","devApiKeyIncludedInProductionError","APIKeyMissingWarn","standardizedLocalesWarning","standardizedCanonicalLocalesWarning","path","REQUEST_FUNCTION_ALIASES","turboConfigStable","rootParamStability"],"sources":["../src/config.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs';\nimport type { NextConfig } from 'next';\nimport {\n defaultWithGTConfigProps,\n defaultCacheExpiryTime,\n} from './config-dir/props/defaultWithGTConfigProps';\nimport { type withGTConfigProps } from './config-dir/props/withGTConfigProps';\nimport {\n APIKeyMissingWarn,\n conflictingConfigurationBuildError,\n createBadFilepathWarning,\n createGTCompilerUnresolvedWarning,\n deprecatedLocaleMappingWarning,\n devApiKeyIncludedInProductionError,\n invalidCanonicalLocalesError,\n invalidLocalesError,\n projectIdMissingWarn,\n standardizedCanonicalLocalesWarning,\n standardizedLocalesWarning,\n unresolvedLoadDictionaryBuildError,\n unresolvedLoadTranslationsBuildError,\n} from './errors/createErrors';\nimport {\n getLocaleProperties,\n isValidLocale,\n standardizeLocale,\n} from '@generaltranslation/format';\nimport {\n rootParamStability,\n turboConfigStable,\n} from './plugin/getStableNextVersionInfo';\nimport { validateCompiler } from './config-dir/utils/validateCompiler';\nimport {\n REQUEST_FUNCTION_ALIASES,\n resolveRequestFunctionPaths,\n} from './config-dir/utils/resolveRequestFunctionPaths';\nimport { resolveConfigFilepath } from './config-dir/utils/resolveConfigFilepath';\nimport { ssgChecks } from './plugin/checks/ssgChecks';\nimport { cacheComponentsChecks } from './plugin/checks/cacheComponentsChecks';\n\ntype AutoderiveConfig = boolean | { jsx?: boolean; strings?: boolean };\n\ntype ConfigFileShape = {\n files?: {\n gt?: {\n parsingFlags?: {\n autoderive?: AutoderiveConfig;\n autoDerive?: AutoderiveConfig;\n };\n };\n };\n};\n\ntype InternalGTConfigProps = withGTConfigProps &\n ConfigFileShape & {\n devApiKey?: string;\n loadDictionaryEnabled?: boolean;\n loadTranslationsType?: 'remote' | 'custom' | 'disabled';\n _dictionaryFileType?: string;\n };\n\ntype WithGTConfigResult<TNextConfig extends object> = TNextConfig & NextConfig;\n\n/**\n * Initializes General Translation settings for a Next.js application.\n *\n * Use it in `next.config.js` to enable GT translation functionality as a plugin.\n *\n * @example\n * // In next.config.ts\n * import { withGTConfig } from 'gt-next/config';\n * import type { NextConfig } from 'next';\n *\n * const nextConfig = {\n * reactStrictMode: true,\n * } satisfies NextConfig;\n *\n * export default withGTConfig(nextConfig, {\n * projectId: 'abc-123',\n * locales: ['en', 'es', 'fr'],\n * defaultLocale: 'en'\n * })\n *\n * @param {string|undefined} config - Optional config filepath (defaults to './gt.config.json'). If a file is found, it will be parsed for GT config variables.\n * @param {string|undefined} dictionary - Optional dictionary configuration file path. If a string is provided, it will be used as a path.\n * @param {string} [apiKey=defaultInitGTProps.apiKey] - API key for the GeneralTranslation service. Required if using the default GT base URL.\n * @param {string} [devApiKey=defaultInitGTProps.devApiKey] - API key for dev environment only.\n * @param {string} [projectId=defaultInitGTProps.projectId] - Project ID for the GeneralTranslation service. Required for most functionality.\n * @param {string|null} [runtimeUrl=defaultInitGTProps.runtimeUrl] - The base URL for the GT API. Set to an empty string to disable automatic translations. Set to null to disable.\n * @param {string|null} [cacheUrl=defaultInitGTProps.cacheUrl] - The URL for cached translations. Set to null to disable.\n * @param {string[]|undefined} - Whether to use local translations.\n * @param {string[]} [locales=defaultInitGTProps.locales] - List of supported locales for the application.\n * @param {string} [defaultLocale=defaultInitGTProps.defaultLocale] - The default locale to use if none is specified.\n * @param {string|undefined} [getLocalePath=\"getLocale\"] - The path to the custom getLocale function.\n * @param {string|undefined} [getRegionPath=\"getRegion\"] - The path to the custom getRegion function.\n * @param {string|undefined} [getDomainPath=\"getDomain\"] - The path to the custom getDomain function.\n * @param {object} [renderSettings=defaultInitGTProps.renderSettings] - Render settings for how translations should be handled.\n * @param {number} [cacheExpiryTime] - The time in milliseconds for how long translations should be cached.\n * @param {number} [maxConcurrentRequests=defaultInitGTProps.maxConcurrentRequests] - Maximum number of concurrent requests allowed.\n * @param {number} [maxBatchSize=defaultInitGTProps.maxBatchSize] - Maximum translation requests in the same batch.\n * @param {number} [batchInterval=defaultInitGTProps.batchInterval] - The interval in milliseconds between batched translation requests.\n * @param {boolean} [ignoreBrowserLocales=defaultWithGTConfigProps.ignoreBrowserLocales] - Whether to ignore browser's preferred locales.\n * @param {boolean} [disableInvalidLocaleWarning=defaultWithGTConfigProps.disableInvalidLocaleWarning] - Whether to disable invalid request locale warnings.\n * @param {object} headersAndCookies - Additional headers and cookies that can be passed for extended configuration.\n * @param {boolean} [experimentalEnableSSG=false] - Whether to enable SSG.\n * @param {boolean} [disableSSGWarnings=defaultWithGTConfigProps.disableSSGWarnings] - Whether to disable SSG warnings. (deprecated)\n * @param {string|undefined} [getStaticLocalePath=\"getStaticLocale\"] - The path to the static getLocale function. (deprecated)\n * @param {string|undefined} [getStaticRegionPath=\"getStaticRegion\"] - The path to the static getRegion function. (deprecated)\n * @param {string|undefined} [getStaticDomainPath=\"getStaticDomain\"] - The path to the static getDomain function. (deprecated)\n * @param {boolean} [experimentalLocaleResolution=defaultWithGTConfigProps.experimentalLocaleResolution] - Deprecated. Uses unsupported Next.js internals to infer locale from root params.\n * @param {string|undefined} [experimentalLocaleResolutionParam=defaultWithGTConfigProps.experimentalLocaleResolutionParam] - Deprecated. Only used by experimentalLocaleResolution.\n * @param {object} metadata - Additional metadata that can be passed for extended configuration.\n *\n * @param {object} nextConfig - The Next.js configuration object to extend\n * @param {withGTConfigProps} props - General Translation configuration properties\n * @returns {NextConfig} - An updated Next.js config with GT settings applied\n *\n * @throws {Error} If the project ID is missing and default URLs are used, or if the API key is required and missing.\n */\nexport function withGTConfig<TNextConfig extends object = NextConfig>(\n nextConfig?: TNextConfig,\n props: withGTConfigProps = {}\n): WithGTConfigResult<TNextConfig> {\n const internalNextConfig = (nextConfig ?? {}) as unknown as NextConfig;\n\n // ---------- LOAD GT CONFIG FILE ---------- //\n\n let loadedConfig: Partial<InternalGTConfigProps> = {};\n try {\n let configPath: string | undefined;\n if (props.config) {\n configPath = props.config;\n } else if (fs.existsSync(defaultWithGTConfigProps.config)) {\n configPath = defaultWithGTConfigProps.config;\n } else if (fs.existsSync('./.gt/gt.config.json')) {\n // Support config under .gt for parity with .locadex\n configPath = './.gt/gt.config.json';\n } else if (fs.existsSync('./.locadex/gt.config.json')) {\n // Backward compatibility: support legacy .locadex directory\n configPath = './.locadex/gt.config.json';\n }\n if (typeof configPath === 'string' && fs.existsSync(configPath)) {\n const fileContent = fs.readFileSync(configPath, 'utf-8');\n loadedConfig = JSON.parse(fileContent);\n }\n } catch (error) {\n console.error('Error reading GT config file:', error);\n }\n\n // ---------- LOAD ENVIRONMENT VARIABLES ---------- //\n\n // resolve project ID\n const projectId: string | undefined = process.env.GT_PROJECT_ID;\n\n // resolve API keys\n const envApiKey: string | undefined =\n process.env.NODE_ENV === 'production'\n ? process.env.GT_API_KEY\n : process.env.GT_DEV_API_KEY || process.env.GT_API_KEY;\n let apiKey, devApiKey;\n if (envApiKey) {\n const apiKeyType = envApiKey?.split('-')?.[1];\n if (apiKeyType === 'api') {\n apiKey = envApiKey;\n } else if (apiKeyType === 'dev') {\n devApiKey = envApiKey;\n }\n }\n\n // conditionally add environment variables to config\n const envConfig: Partial<InternalGTConfigProps> = {\n ...(projectId ? { projectId } : {}),\n ...(apiKey ? { apiKey } : {}),\n ...(devApiKey ? { devApiKey } : {}),\n };\n\n // ---------- CHECK FOR CONFIG CONFLICTS ---------- //\n\n // Check for conflicts between config and params\n const propsRecord = props as Record<string, unknown>;\n const conflicts = Object.entries(loadedConfig)\n .filter(([key, value]) => {\n // Skip if key doesn't exist in props\n if (!(key in props)) return false;\n\n const propValue = propsRecord[key];\n\n // Handle null/undefined values\n if (value == null || propValue == null) {\n return value !== propValue;\n }\n\n // Handle primitive types (string, number, boolean)\n if (typeof value !== 'object') {\n return value !== propValue;\n }\n\n // Handle arrays (no need for deep equality check)\n if (Array.isArray(value)) {\n if (!Array.isArray(propValue)) return true;\n if (value.length !== propValue.length) return true;\n return value.some((v, i) => v !== propValue[i]);\n }\n\n // Handle objects\n if (typeof value === 'object' && typeof propValue === 'object') {\n const valueRecord = value as Record<string, unknown>;\n const propRecord = propValue as Record<string, unknown>;\n const valueKeys = Object.keys(valueRecord);\n const propKeys = Object.keys(propRecord);\n const keys = new Set([...valueKeys, ...propKeys]);\n\n // Objects must match exactly (no need to go deeper)\n if (valueKeys.length !== propKeys.length) return true;\n return !Array.from(keys).every((k) => valueRecord[k] === propRecord[k]);\n }\n\n return false;\n })\n .map(\n ([key, value]) =>\n `- Key: ${key} Next Config: ${JSON.stringify(propsRecord[key])} does not match GT Config: ${JSON.stringify(value)}`\n );\n\n if (conflicts.length) {\n throw new Error(conflictingConfigurationBuildError(conflicts));\n }\n\n // ---------- MERGE CONFIGS ---------- //\n\n // Merge cookie and header names\n const mergedHeadersAndCookies = {\n ...defaultWithGTConfigProps.headersAndCookies,\n ...props.headersAndCookies,\n };\n\n // Merge experimentalSwcPluginOptions\n const mergedExperimentalCompilerOptions = {\n ...defaultWithGTConfigProps.experimentalCompilerOptions,\n ...props.experimentalSwcPluginOptions,\n ...props.experimentalCompilerOptions,\n };\n\n // precedence: input > env > config file > defaults\n const mergedConfig: InternalGTConfigProps = {\n ...defaultWithGTConfigProps,\n ...loadedConfig,\n ...envConfig,\n ...props,\n headersAndCookies: mergedHeadersAndCookies,\n experimentalCompilerOptions: mergedExperimentalCompilerOptions,\n _usingPlugin: true, // flag to indicate plugin usage\n };\n\n // clear up any issues with the compiler options\n validateCompiler(mergedConfig);\n\n // ----------- RESOLVE ANY EXTERNAL FILES ----------- //\n\n // Resolve wasm filepath\n const turboPackEnabled = !!process.env.TURBOPACK;\n let resolvedWasmFilePath = '';\n if (mergedConfig.experimentalCompilerOptions?.type === 'swc') {\n try {\n if (turboPackEnabled) {\n const absolutePath = path.resolve(__dirname, './gt_swc_plugin.wasm');\n resolvedWasmFilePath =\n './' + path.relative(process.cwd(), absolutePath).replace(/\\\\/g, '/');\n } else {\n resolvedWasmFilePath = path.resolve(__dirname, './gt_swc_plugin.wasm');\n }\n } catch (error) {\n console.error(\n createGTCompilerUnresolvedWarning('swc'),\n 'Error message:',\n error\n );\n resolvedWasmFilePath = '';\n mergedConfig.experimentalCompilerOptions.type = 'none';\n }\n }\n\n // Resolve dictionary filepath\n let resolvedDictionaryFilePath =\n typeof mergedConfig.dictionary === 'string'\n ? mergedConfig.dictionary\n : resolveConfigFilepath('dictionary', ['.ts', '.js', '.json']); // fallback to dictionary\n\n // Check [defaultLocale].json file\n if (!resolvedDictionaryFilePath && mergedConfig.defaultLocale) {\n resolvedDictionaryFilePath = resolveConfigFilepath(\n mergedConfig.defaultLocale,\n ['.json']\n );\n\n // Check [defaultLanguageCode].json file\n if (!resolvedDictionaryFilePath) {\n const defaultLanguage = getLocaleProperties(\n mergedConfig.defaultLocale\n )?.languageCode;\n\n if (defaultLanguage && defaultLanguage !== mergedConfig.defaultLocale) {\n resolvedDictionaryFilePath = resolveConfigFilepath(defaultLanguage, [\n '.json',\n ]);\n }\n }\n }\n\n // Get the type of dictionary file\n const resolvedDictionaryFilePathType = resolvedDictionaryFilePath\n ? path.extname(resolvedDictionaryFilePath)\n : undefined;\n if (resolvedDictionaryFilePathType) {\n mergedConfig._dictionaryFileType = resolvedDictionaryFilePathType;\n }\n\n // Resolve custom dictionary loader path\n const customLoadDictionaryPath =\n typeof mergedConfig.loadDictionaryPath === 'string'\n ? mergedConfig.loadDictionaryPath\n : resolveConfigFilepath('loadDictionary');\n\n // Resolve custom translation loader path\n const customLoadTranslationsPath =\n typeof mergedConfig.loadTranslationsPath === 'string'\n ? mergedConfig.loadTranslationsPath\n : resolveConfigFilepath('loadTranslations');\n\n // Resolve request function paths\n const requestFunctionPaths = resolveRequestFunctionPaths(mergedConfig);\n\n // Warn if found in /app directory\n if (\n !resolvedDictionaryFilePath &&\n resolveConfigFilepath('dictionary', ['.ts', '.js', '.json'], undefined, [\n './app',\n './src/app',\n ])\n ) {\n console.warn(\n createBadFilepathWarning('dictionary', ['./app', './src/app'])\n );\n }\n\n if (\n !customLoadDictionaryPath &&\n resolveConfigFilepath(\n 'loadDictionary',\n ['.ts', '.js', '.json'],\n undefined,\n ['./app', './src/app']\n )\n ) {\n console.warn(\n createBadFilepathWarning('loadDictionary', ['./app', './src/app'])\n );\n }\n\n if (\n !customLoadTranslationsPath &&\n resolveConfigFilepath(\n 'loadTranslations',\n ['.ts', '.js', '.json'],\n undefined,\n ['./app', './src/app']\n )\n ) {\n console.warn(\n createBadFilepathWarning('loadTranslations', ['./app', './src/app'])\n );\n }\n\n // ----------- LOCALE STANDARDIZATION ----------- //\n\n // Check if using Services\n const gtRuntimeTranslationEnabled = !!(\n mergedConfig.runtimeUrl === defaultWithGTConfigProps.runtimeUrl &&\n ((process.env.NODE_ENV === 'production' && mergedConfig.apiKey) ||\n (process.env.NODE_ENV === 'development' && mergedConfig.devApiKey))\n );\n const gtRemoteCacheEnabled = !!(\n mergedConfig.cacheUrl === defaultWithGTConfigProps.cacheUrl &&\n mergedConfig.loadTranslationsType === 'remote'\n );\n const gtServicesEnabled = !!(\n (gtRuntimeTranslationEnabled || gtRemoteCacheEnabled) &&\n mergedConfig.projectId\n );\n\n // Standardize locales\n if (mergedConfig.locales && mergedConfig.defaultLocale) {\n mergedConfig.locales.unshift(mergedConfig.defaultLocale);\n }\n const updatedLocales: string[] = [];\n mergedConfig.locales = Array.from(new Set(mergedConfig.locales)).map(\n (locale) => {\n const updatedLocale = gtServicesEnabled\n ? standardizeLocale(locale)\n : locale;\n if (updatedLocale !== locale) {\n updatedLocales.push(`${locale} -> ${updatedLocale}`);\n }\n return updatedLocale;\n }\n );\n\n // Standardize canonical locales\n const updatedCanonicalLocales: string[] = [];\n if (mergedConfig.customMapping) {\n mergedConfig.customMapping = Object.fromEntries(\n Object.entries(mergedConfig.customMapping).map(([key, value]) => {\n if (typeof value !== 'object' || !('code' in value)) {\n return [key, value];\n }\n const updatedLocale = gtServicesEnabled\n ? standardizeLocale((value as { code: string }).code)\n : (value as { code: string }).code;\n if (updatedLocale !== (value as { code: string }).code) {\n updatedCanonicalLocales.push(`${key} -> ${updatedLocale}`);\n }\n return [\n key,\n {\n ...value,\n code: updatedLocale,\n },\n ];\n })\n );\n }\n\n // Run SSG checks\n ssgChecks(mergedConfig, requestFunctionPaths);\n\n // Run cache component checks\n cacheComponentsChecks({\n mergedConfig,\n nextConfig: internalNextConfig,\n requestFunctionPaths,\n localTranslationsEnabled: !!customLoadTranslationsPath,\n localDictionaryEnabled: !!customLoadDictionaryPath,\n });\n\n // ---------- DERIVED CONFIG ATTRIBUTES ---------- //\n\n // Local dictionary flag\n if (customLoadDictionaryPath) {\n // Check: file exists if provided\n if (!fs.existsSync(path.resolve(customLoadDictionaryPath))) {\n throw new Error(\n unresolvedLoadDictionaryBuildError(customLoadDictionaryPath)\n );\n } else {\n mergedConfig.loadDictionaryEnabled = true;\n }\n } else {\n mergedConfig.loadDictionaryEnabled = false;\n }\n\n // Local translations flag\n if (customLoadTranslationsPath) {\n // Check: file exists if provided\n if (!fs.existsSync(path.resolve(customLoadTranslationsPath))) {\n throw new Error(\n unresolvedLoadTranslationsBuildError(customLoadTranslationsPath)\n );\n } else {\n mergedConfig.loadTranslationsType = 'custom';\n }\n } else {\n mergedConfig.loadTranslationsType = 'remote';\n }\n\n // Set default cache expiry if and only if no dev key\n if (\n mergedConfig.loadTranslationsType == 'remote' &&\n !mergedConfig.devApiKey &&\n typeof mergedConfig.cacheExpiryTime === 'undefined'\n ) {\n mergedConfig.cacheExpiryTime = defaultCacheExpiryTime;\n }\n\n // ---------- ERROR CHECKS ---------- //\n\n // Check: using deprecated localeMapping\n if (props.customMapping) {\n console.warn(deprecatedLocaleMappingWarning);\n }\n\n // Check: invalid locale\n if (!mergedConfig.customMapping && gtServicesEnabled) {\n const invalidLocales: string[] = [];\n mergedConfig.locales.forEach((locale) => {\n if (!isValidLocale(locale)) {\n invalidLocales.push(locale);\n }\n });\n if (invalidLocales.length) {\n throw new Error(invalidLocalesError(invalidLocales));\n }\n }\n\n // Check: invalid canonical locale\n if (mergedConfig.customMapping && gtServicesEnabled) {\n const invalidCanonicalLocales: string[] = [];\n mergedConfig.locales.forEach((locale) => {\n if (!isValidLocale(locale, mergedConfig.customMapping)) {\n invalidCanonicalLocales.push(locale);\n }\n });\n if (invalidCanonicalLocales.length) {\n throw new Error(invalidCanonicalLocalesError(invalidCanonicalLocales));\n }\n }\n\n // Check: projectId is not required for remote infrastructure, but warn if missing for dev, nothing for prod\n if (\n (mergedConfig.cacheUrl || mergedConfig.runtimeUrl) &&\n !mergedConfig.projectId &&\n process.env.NODE_ENV === 'development' &&\n mergedConfig.loadTranslationsType === 'remote' &&\n !mergedConfig.loadDictionaryEnabled // skip warn if using local dictionary\n ) {\n console.warn(projectIdMissingWarn);\n }\n\n // Check: dev API key should not be included in production\n if (process.env.NODE_ENV === 'production' && mergedConfig.devApiKey) {\n throw new Error(devApiKeyIncludedInProductionError);\n }\n\n // Check: An API key is required for runtime translation\n if (\n mergedConfig.projectId && // must have projectId for this check to matter anyways\n mergedConfig.runtimeUrl &&\n !(mergedConfig.apiKey || mergedConfig.devApiKey) &&\n process.env.NODE_ENV === 'development'\n ) {\n console.warn(APIKeyMissingWarn);\n }\n\n // Check: if using GT infrastructure, warn about unsupported locales\n if (gtServicesEnabled) {\n // Warn about standardized locales\n if (updatedLocales.length) {\n console.warn(standardizedLocalesWarning(updatedLocales));\n }\n\n // Warn about standardized canonical locales\n if (updatedCanonicalLocales.length) {\n console.warn(\n standardizedCanonicalLocalesWarning(updatedCanonicalLocales)\n );\n }\n }\n\n // ---------- STORE CONFIGURATIONS ---------- //\n const I18NConfigParams = JSON.stringify(mergedConfig);\n\n const { type: _type, ...compilerOptions } =\n mergedConfig.experimentalCompilerOptions || {};\n\n // Read autoderive from parsingFlags (single source of truth shared with CLI)\n const rawAutoderive: boolean | { jsx?: boolean; strings?: boolean } =\n loadedConfig?.files?.gt?.parsingFlags?.autoderive ??\n loadedConfig?.files?.gt?.parsingFlags?.autoDerive ??\n false;\n const autoderiveJsx =\n typeof rawAutoderive === 'boolean'\n ? rawAutoderive\n : (rawAutoderive.jsx ?? false);\n const autoderiveStrings =\n typeof rawAutoderive === 'boolean'\n ? rawAutoderive\n : (rawAutoderive.strings ?? false);\n\n const swcPluginOptions: Record<string, unknown> = {\n ...compilerOptions,\n autoderiveJsx,\n autoderiveStrings,\n };\n\n const swcPluginEntry: [string, Record<string, unknown>] | null =\n mergedConfig.experimentalCompilerOptions?.type === 'swc'\n ? [resolvedWasmFilePath, swcPluginOptions]\n : null;\n\n const turboAliases = {\n 'gt-next/_dictionary': resolvedDictionaryFilePath || '',\n 'gt-next/_load-translations': customLoadTranslationsPath || '',\n 'gt-next/_load-dictionary': customLoadDictionaryPath || '',\n ...Object.fromEntries(\n Object.entries(requestFunctionPaths).map(([functionName, path]) => {\n return [\n REQUEST_FUNCTION_ALIASES[\n functionName as keyof typeof REQUEST_FUNCTION_ALIASES\n ],\n path,\n ];\n })\n ),\n };\n\n // experimental.turbo is deprecated in next@15.3.0.\n // Check for experimental.turbo. If we write to turbopack field, experimental fields will be ignored.\n // Yet, if there are other resolveAlias fields, we don't want to be ignored either.\n const experimentalTurbopack = !(\n turboConfigStable &&\n (!internalNextConfig.experimental?.turbo ||\n internalNextConfig.turbopack?.resolveAlias)\n );\n\n const config: NextConfig = {\n ...internalNextConfig,\n env: {\n ...internalNextConfig.env,\n _GENERALTRANSLATION_I18N_CONFIG_PARAMS: I18NConfigParams,\n ...(resolvedDictionaryFilePathType && {\n _GENERALTRANSLATION_DICTIONARY_FILE_TYPE:\n resolvedDictionaryFilePathType,\n }),\n _GENERALTRANSLATION_LOCAL_DICTIONARY_ENABLED:\n mergedConfig.loadDictionaryEnabled.toString(),\n _GENERALTRANSLATION_LOCAL_TRANSLATION_ENABLED: (\n mergedConfig.loadTranslationsType === 'custom'\n ).toString(),\n _GENERALTRANSLATION_DEFAULT_LOCALE: (\n mergedConfig.defaultLocale ||\n defaultWithGTConfigProps.defaultLocale ||\n ''\n ).toString(),\n _GENERALTRANSLATION_GT_SERVICES_ENABLED: gtServicesEnabled.toString(),\n _GENERALTRANSLATION_IGNORE_BROWSER_LOCALES:\n mergedConfig.ignoreBrowserLocales?.toString() ||\n defaultWithGTConfigProps.ignoreBrowserLocales?.toString() ||\n 'false',\n _GENERALTRANSLATION_CUSTOM_GET_LOCALE_ENABLED:\n requestFunctionPaths.getLocale ? 'true' : 'false',\n _GENERALTRANSLATION_CUSTOM_GET_REGION_ENABLED:\n requestFunctionPaths.getRegion ? 'true' : 'false',\n _GENERALTRANSLATION_CUSTOM_GET_DOMAIN_ENABLED:\n requestFunctionPaths.getDomain ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_LOCALE_ENABLED:\n requestFunctionPaths.getStaticLocale ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_REGION_ENABLED:\n requestFunctionPaths.getStaticRegion ? 'true' : 'false',\n _GENERALTRANSLATION_STATIC_GET_DOMAIN_ENABLED:\n requestFunctionPaths.getStaticDomain ? 'true' : 'false',\n _GENERALTRANSLATION_DISABLE_SSG_WARNINGS:\n mergedConfig.disableSSGWarnings?.toString() || 'false',\n _GENERALTRANSLATION_ENABLE_SSG:\n mergedConfig.experimentalEnableSSG?.toString() || 'false',\n _GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION:\n mergedConfig.experimentalLocaleResolution?.toString() || 'false',\n _GENERALTRANSLATION_EXPERIMENTAL_LOCALE_RESOLUTION_PARAM:\n mergedConfig.experimentalLocaleResolutionParam,\n _GENERALTRANSLATION_DISABLE_INVALID_LOCALE_WARNING:\n mergedConfig.disableInvalidLocaleWarning?.toString() || 'false',\n },\n ...(turboPackEnabled &&\n !experimentalTurbopack && {\n turbopack: {\n ...internalNextConfig.turbopack,\n resolveAlias: {\n ...internalNextConfig.turbopack?.resolveAlias,\n ...turboAliases,\n },\n },\n }),\n experimental: {\n ...internalNextConfig.experimental,\n ...(rootParamStability === 'experimental' && {\n rootParams: true,\n }),\n swcPlugins: [\n ...(internalNextConfig.experimental?.swcPlugins || []),\n ...(swcPluginEntry ? [swcPluginEntry] : []),\n ],\n ...(turboPackEnabled &&\n experimentalTurbopack && {\n turbo: {\n ...internalNextConfig.experimental?.turbo,\n resolveAlias: {\n ...internalNextConfig.experimental?.turbo?.resolveAlias,\n ...turboAliases,\n },\n },\n }),\n },\n webpack: function webpack(\n ...[webpackConfig, options]: Parameters<\n NonNullable<NextConfig['webpack']>\n >\n ) {\n // Only apply webpack aliases if we're using webpack (not Turbopack)\n if (!turboPackEnabled) {\n // Try to load GT compiler if available\n if (mergedConfig.experimentalCompilerOptions?.type === 'babel') {\n try {\n const {\n webpack: gtUnplugin,\n } = require('@generaltranslation/compiler');\n webpackConfig.plugins.unshift(\n gtUnplugin(mergedConfig.experimentalCompilerOptions || {})\n );\n } catch (e) {\n mergedConfig.experimentalCompilerOptions.type = 'none';\n console.warn(\n createGTCompilerUnresolvedWarning('babel'),\n 'Error message:',\n e\n );\n }\n }\n\n // Disable cache in dev bc people might move around loadTranslations() and loadDictionary() files\n if (process.env.NODE_ENV === 'development') {\n webpackConfig.cache = false;\n }\n if (resolvedDictionaryFilePath) {\n webpackConfig.resolve.alias['gt-next/_dictionary'] = path.resolve(\n webpackConfig.context,\n resolvedDictionaryFilePath\n );\n }\n if (customLoadTranslationsPath) {\n webpackConfig.resolve.alias[`gt-next/_load-translations`] =\n path.resolve(webpackConfig.context, customLoadTranslationsPath);\n }\n if (customLoadDictionaryPath) {\n webpackConfig.resolve.alias[`gt-next/_load-dictionary`] =\n path.resolve(webpackConfig.context, customLoadDictionaryPath);\n }\n for (const [functionName, pathString] of Object.entries(\n requestFunctionPaths\n )) {\n const key =\n REQUEST_FUNCTION_ALIASES[\n functionName as keyof typeof REQUEST_FUNCTION_ALIASES\n ];\n webpackConfig.resolve.alias[key] = path.resolve(\n webpackConfig.context,\n pathString\n );\n }\n }\n if (typeof internalNextConfig?.webpack === 'function') {\n return internalNextConfig.webpack(webpackConfig, options);\n }\n return webpackConfig;\n },\n };\n return config as WithGTConfigResult<TNextConfig>;\n}\n\n// Keep initGT for backward compatibility\nexport const initGT =\n (props: withGTConfigProps) =>\n <TNextConfig extends object = NextConfig>(nextConfig?: TNextConfig) =>\n withGTConfig(nextConfig, props);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;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F;GACJ;EACD,SAAS,SAAS,QAChB,GAAG,CAAC,eAAe,UAGnB;AAEA,OAAI,CAAC,kBAAkB;AAErB,QAAI,aAAa,6BAA6B,SAAS,QACrD,KAAI;KACF,MAAM,EACJ,SAAS,eACP,QAAQ,+BAA+B;AAC3C,mBAAc,QAAQ,QACpB,WAAW,aAAa,+BAA+B,EAAE,CAAC,CAC3D;aACM,GAAG;AACV,kBAAa,4BAA4B,OAAO;AAChD,aAAQ,KACNlB,4BAAAA,kCAAkC,QAAQ,EAC1C,kBACA,EACD;;AAKL,QAAI,QAAQ,IAAI,aAAa,cAC3B,eAAc,QAAQ;AAExB,QAAI,2BACF,eAAc,QAAQ,MAAM,yBAAyB,KAAA,QAAK,QACxD,cAAc,SACd,2BACD;AAEH,QAAI,2BACF,eAAc,QAAQ,MAAM,gCAC1B,KAAA,QAAK,QAAQ,cAAc,SAAS,2BAA2B;AAEnE,QAAI,yBACF,eAAc,QAAQ,MAAM,8BAC1B,KAAA,QAAK,QAAQ,cAAc,SAAS,yBAAyB;AAEjE,SAAK,MAAM,CAAC,cAAc,eAAe,OAAO,QAC9C,qBACD,EAAE;KACD,MAAM,MACJgB,qDAAAA,yBACE;AAEJ,mBAAc,QAAQ,MAAM,OAAO,KAAA,QAAK,QACtC,cAAc,SACd,WACD;;;AAGL,OAAI,OAAO,oBAAoB,YAAY,WACzC,QAAO,mBAAmB,QAAQ,eAAe,QAAQ;AAE3D,UAAO;;EAGE;;AAIf,MAAa,UACV,WACyC,eACxC,aAAa,YAAY,MAAM"}
|
package/dist/index.types.d.ts
CHANGED
|
@@ -257,6 +257,7 @@ export declare const LocaleSelector: typeof _LocaleSelector;
|
|
|
257
257
|
* @param {string} [options.$context] - Additional context for the translation.
|
|
258
258
|
* @param {string} [options.$id] - Optional identifier for the translation string.
|
|
259
259
|
* @param {number} [options.$maxChars] - Maximum number of characters for the translated message.
|
|
260
|
+
* @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.
|
|
260
261
|
* @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.
|
|
261
262
|
*
|
|
262
263
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../src/index.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EACL,eAAe,IAAI,gBAAgB,EACnC,SAAS,IAAI,UAAU,EACvB,UAAU,IAAI,WAAW,EACzB,gBAAgB,IAAI,iBAAiB,EACrC,UAAU,IAAI,WAAW,EACzB,mBAAmB,IAAI,oBAAoB,EAC3C,QAAQ,IAAI,SAAS,EACrB,QAAQ,IAAI,SAAS,EACrB,YAAY,IAAI,aAAa,EAC7B,GAAG,IAAI,IAAI,EACX,GAAG,IAAI,IAAI,EACX,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,cAAc,IAAI,eAAe,EACjC,cAAc,IAAI,eAAe,EACjC,kBAAkB,IAAI,mBAAmB,EACzC,YAAY,IAAI,aAAa,EAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,GAAG,EACH,SAAS,EACT,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,SAAS,EACT,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,WAE/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;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AAO,eAEnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,WAAW,EAAE,CACxB,SAAS,CAAC,EAAE,SAAS,KAClB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,UAAU,EAAE,CAAC,EACb,OAAO,CAAC,EAAE,wBAAwB,KAC/B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAEhC,CAAC;AAEF,YAAY,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,OAAO,EACL,GAAG,EACH,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,MAAM,EACN,UAAU,EACV,UAAU,GACX,CAAC;AAEF,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/index.types.js
CHANGED
|
@@ -300,6 +300,7 @@ const LocaleSelector = () => {
|
|
|
300
300
|
* @param {string} [options.$context] - Additional context for the translation.
|
|
301
301
|
* @param {string} [options.$id] - Optional identifier for the translation string.
|
|
302
302
|
* @param {number} [options.$maxChars] - Maximum number of characters for the translated message.
|
|
303
|
+
* @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.
|
|
303
304
|
* @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.
|
|
304
305
|
*
|
|
305
306
|
* @example
|
package/dist/index.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.js","names":["typesFileError"],"sources":["../src/index.types.ts"],"sourcesContent":["import { typesFileError } from './errors/createErrors';\nimport { GTProvider as _GTProvider } from './provider/GTProvider';\nimport { T as _T } from './server-dir/buildtime/T';\nimport {\n useTranslations as _useTranslations,\n useLocale as _useLocale,\n useLocales as _useLocales,\n useDefaultLocale as _useDefaultLocale,\n useGTClass as _useGTClass,\n useLocaleProperties as _useLocaleProperties,\n Currency as _Currency,\n DateTime as _DateTime,\n RelativeTime as _RelativeTime,\n Num as _Num,\n Var as _Var,\n Branch as _Branch,\n Plural as _Plural,\n LocaleSelector as _LocaleSelector,\n RegionSelector as _RegionSelector,\n useLocaleDirection as _useLocaleDirection,\n useVersionId as _useVersionId,\n} from 'gt-react/client';\nimport type {\n DictionaryTranslationOptions,\n InlineTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-react';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport {\n msg,\n decodeMsg,\n decodeOptions,\n declareStatic,\n derive,\n declareVar,\n decodeVars,\n _Messages,\n Static as _Static,\n Derive as _Derive,\n mFallback,\n gtFallback,\n} from 'gt-react/internal';\n\n/**\n * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.\n *\n * @param {React.ReactNode} children - The children components that will use the translation context.\n * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.\n * @param {string} locale - The locale to use for the translation context.\n *\n * @returns {JSX.Element} The provider component for General Translation context.\n */\nexport const GTProvider: typeof _GTProvider = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport const T: typeof _T = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate';\n\n/**\n * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.\n *\n * @example\n * ```jsx\n * <Currency\n * currency=\"USD\"\n * >\n * 1000\n * </Currency>\n * ```\n *\n * @param {any} [children] - Optional content to render inside the currency component.\n * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).\n * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.\n * @returns {React.JSX.Element} The formatted currency component.\n */\nexport const Currency: typeof _Currency = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nCurrency._gtt = 'variable-currency';\n\n/**\n * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.\n * It utilizes the current locale and optional format settings to display the date.\n *\n * @example\n * ```jsx\n * <DateTime>\n * {new Date()}\n * </DateTime>\n * ```\n *\n * @param {any} [children] - Optional content (typically a date) to render inside the component.\n * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.\n * @returns {Promise<React.JSX.Element>} The formatted date or time component.\n */\nexport const DateTime: typeof _DateTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDateTime._gtt = 'variable-datetime';\n\n/**\n * The `<RelativeTime>` component renders a localized relative time string\n * (e.g., \"2 hours ago\", \"in 3 days\") using `Intl.RelativeTimeFormat`.\n *\n * @example\n * ```jsx\n * <RelativeTime date={someDate} />\n * ```\n *\n * @param {Date} [date] - A date to compute relative time from now.\n * @param {number} [value] - Explicit numeric value. Requires `unit`.\n * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.\n * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.\n * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.\n * @returns {Promise<React.JSX.Element>} The formatted relative time component.\n */\nexport const RelativeTime: typeof _RelativeTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nRelativeTime._gtt = 'variable-relative-time';\n\n/**\n * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.\n * It formats the number according to the current locale and optionally passed formatting options.\n *\n * @example\n * ```jsx\n * <Num\n * options={{ style: \"decimal\", maximumFractionDigits: 2 }}\n * >\n * 1000\n * </Num>\n * ```\n *\n * @param {any} [children] - Optional content (typically a number) to render inside the component.\n * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.\n * @returns {React.JSX.Element} The formatted number component.\n */\nexport const Num: typeof _Num = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nNum._gtt = 'variable-number';\n\n/**\n * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.\n * If `children` is provided, it will be used; otherwise, the `value` is rendered.\n *\n * @example\n * ```jsx\n * <Var>\n * John\n * </Var>\n * ```\n *\n * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.\n * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.\n */\nexport const Var: typeof _Var = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nVar._gtt = 'variable-variable';\n\n/**\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` inside translated JSX when child content is computed from\n * source code, but should still be discovered during extraction instead of\n * treated as a runtime interpolation variable. The CLI attempts to resolve the\n * derivable children into every possible static value and includes those values\n * in the source content that gets translated.\n *\n * `<Derive>` renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `<Derive>` usage to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Derive>\n * {getSubject()}\n * </Derive>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Derive: typeof _Derive = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDerive._gtt = 'derive';\n\n/**\n * @deprecated Use `<Derive>` instead.\n *\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` instead of `<Static>` for new code. This alias is kept for\n * backwards compatibility and renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing derived JSX content to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Static>\n * {getSubject()}\n * </Static>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Static: typeof _Static = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nStatic._gtt = 'derive';\n\n/**\n * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.\n * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).\n * If the specified `branch` is present in the `branches` object, it renders the content of that branch.\n * If the `branch` is not found, it renders the provided `children` as fallback content.\n *\n * @example\n * ```jsx\n * <Branch\n * branch=\"summary\"\n * summary={<p>This is a summary</p>}\n * details={<p>Details here</p>}\n * >\n * <p>Fallback content</p>\n * </Branch>\n * ```\n * If the `branch` prop is set to `\"summary\"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.\n *\n * @param {any} [children] - Fallback content to render if no matching branch is found.\n * @param {string} [name=\"branch\"] - Optional name for the component, used for metadata or tracking purposes.\n * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.\n * @returns {React.JSX.Element} The rendered branch or fallback content.\n */\nexport const Branch: typeof _Branch = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nBranch._gtt = 'branch';\n\n/**\n * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).\n * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,\n * based on the current locale or a default locale. If no matching plural branch is found, the component renders\n * the fallback `children` content.\n *\n * @example\n * ```jsx\n * <Plural\n * n={1}\n * one=\"There is 1 item\"\n * other=\"There are {n} items\"\n * />\n * ```\n * In this example, if `n` is 1, it renders `\"There is 1 item\"`. If `n` is a different number, it renders\n * `\"There are {n} items\"`.\n *\n * @param {any} [children] - Fallback content to render if no matching plural branch is found.\n * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.\n * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular\n * and `other` for plural forms, but it may vary depending on the locale.\n * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.\n * @throws {Error} If `n` is not provided or not a valid number.\n */\nexport const Plural: typeof _Plural = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nPlural._gtt = 'plural';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} locales - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} customNames - An optional object to map locales to custom names.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport const LocaleSelector: typeof _LocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the string translation function `t`.\n *\n * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.\n * @param {InlineTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.\n * @param {string} [options.$context] - Additional context for the translation.\n * @param {string} [options.$id] - Optional identifier for the translation string.\n * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.\n * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n *\n * @example\n * const t = useGT();\n * console.log(t('To be or not to be...'));\n *\n * const t = useGT();\n * return (<>\n * {\n * t('My name is {customName}', { customName: \"Brian\" } )\n * }\n * </>);\n *\n */\nexport const useGT: (\n _messages?: _Messages\n) => (message: string, options?: InlineTranslationOptions) => string = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the dictionary access function `t`.\n *\n * @param {string} [id] - Optional prefix to prepend to the translation keys.\n * @returns {Function} A translation function that accepts a key string and returns the translated value.\n * The returned function accepts `DictionaryTranslationOptions` which includes:\n * - `$format` - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n * - `$maxChars` - Maximum number of characters for the translated message.\n *\n * @example\n * const t = useTranslations('user');\n * console.log(t('name')); // Translates item 'user.name'\n *\n * const t = useTranslations();\n * console.log(t('hello')); // Translates item 'hello'\n */\nexport const useTranslations: typeof _useTranslations = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current locale.\n *\n * @returns {string} BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useLocale: typeof _useLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's list of supported locales.\n *\n * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].\n *\n * @example\n * const locales = useLocales();\n * console.log(locale); // ['en-US', 'fr', 'jp]\n */\nexport const useLocales: typeof _useLocales = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the application's default locale.\n *\n * If no default locale is provided, it defaults to 'en'.\n *\n * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useDefaultLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useDefaultLocale: typeof _useDefaultLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the configured GT class instance.\n *\n * @returns {GT} The configured GT class instance.\n *\n * @example\n * const gt = useGTClass();\n * console.log(gt.getLocaleProperties('en-US'));\n */\nexport const useGTClass: typeof _useGTClass = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the locale properties for the given locale.\n *\n * @param {string} locale - The locale to get the properties for.\n * @returns {LocaleProperties} The locale properties for the given locale.\n *\n * @example\n * const localeProperties = useLocaleProperties('en-US');\n * console.log(localeProperties);\n */\nexport const useLocaleProperties: typeof _useLocaleProperties = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.\n *\n * If no locale is provided, the direction for the current user's locale is returned.\n *\n * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.\n * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.\n *\n * @example\n * const dir = useLocaleDirection(); // e.g., 'ltr'\n * const arabicDir = useLocaleDirection('ar'); // 'rtl'\n */\nexport const useLocaleDirection: typeof _useLocaleDirection = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the version ID for the current source, if set.\n *\n * @returns {string | undefined} The version ID.\n *\n * @example\n * const versionId = useVersionId();\n * console.log(versionId); // 'abc123'\n */\nexport const useVersionId: typeof _useVersionId = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * A dropdown component that allows users to select a region.\n *\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales. The value can be a string (display name) or an object with `name`, `emoji`, and/or `locale` properties.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @param {object} [props] - Additional props to pass to the underlying `<select>` element.\n * @returns {React.JSX.Element | null} The rendered region dropdown component or null if no regions are available.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"🇺🇸\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport const RegionSelector: typeof _RegionSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Registers a message to be translated. Returns the message unchanged if no options are provided.\n * @param {string | string[]} message The message to encode.\n * @param {InlineTranslationOptions} [options] The options to encode.\n * @returns The message or array of messages.\n *\n * @note - This function registers the message before the build process. The actual translation does not\n * occur until the m() function is invoked.\n *\n * @note - Message format\n * A message is broken into two parts separated by colons:\n * - interpolated content - the content with interpolated variables\n * - hash + options - a unique identifier for the source content and options for the translation\n *\n * @example - Basic usage\n *\n * const message1 = msg('Hello, World!');\n * console.log(message1); // \"Hello, World!\"\n *\n * const message2 = msg('Hello, {name}!', { name: 'Brian' });\n * console.log(message2); // \"Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9\"\n *\n * @example - Array usage\n *\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);\n * console.log(messages); // [\"Hello, Alice!\", \"Hello, Bob!\"]\n *\n * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });\n * // \"Hello, Alice!\" id: \"greetings.0\"\n * // \"Hello, Bob!\" id: \"greetings.1\"\n */\nexport const useMessages: (\n _messages?: _Messages\n) => <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n) => T extends string ? string : T = () => {\n throw new Error(typesFileError);\n};\n\nexport type {\n DictionaryTranslationOptions,\n InlineTranslationOptions,\n RuntimeTranslationOptions,\n};\n\nexport type { StringFormat };\n\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n mFallback,\n gtFallback,\n derive,\n declareVar,\n decodeVars,\n};\n\n/** @deprecated Use derive() instead. */\nexport { declareStatic };\n"],"mappings":";;;;;;;;;;;;;;AAoDA,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCjC,MAAa,UAAqB;AAChC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,EAAE,OAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;AAiBhB,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;;AAkBhB,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,aAAa,OAAO;;;;;;;;;;;;;;;;;;AAmBpB,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;AAgBX,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCX,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;AAQd,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;AAyBjC,MAAa,cAEgE;AAC3E,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;AAmBjC,MAAa,wBAAiD;AAC5D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,kBAAqC;AAChD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;AAcjC,MAAa,yBAAmD;AAC9D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;AAajC,MAAa,4BAAyD;AACpE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;AAejC,MAAa,2BAAuD;AAClE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;AAwBjC,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCjC,MAAa,oBAK8B;AACzC,OAAM,IAAI,MAAMA,4BAAAA,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.types.js","names":["typesFileError"],"sources":["../src/index.types.ts"],"sourcesContent":["import { typesFileError } from './errors/createErrors';\nimport { GTProvider as _GTProvider } from './provider/GTProvider';\nimport { T as _T } from './server-dir/buildtime/T';\nimport {\n useTranslations as _useTranslations,\n useLocale as _useLocale,\n useLocales as _useLocales,\n useDefaultLocale as _useDefaultLocale,\n useGTClass as _useGTClass,\n useLocaleProperties as _useLocaleProperties,\n Currency as _Currency,\n DateTime as _DateTime,\n RelativeTime as _RelativeTime,\n Num as _Num,\n Var as _Var,\n Branch as _Branch,\n Plural as _Plural,\n LocaleSelector as _LocaleSelector,\n RegionSelector as _RegionSelector,\n useLocaleDirection as _useLocaleDirection,\n useVersionId as _useVersionId,\n} from 'gt-react/client';\nimport type {\n DictionaryTranslationOptions,\n InlineTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-react';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport {\n msg,\n decodeMsg,\n decodeOptions,\n declareStatic,\n derive,\n declareVar,\n decodeVars,\n _Messages,\n Static as _Static,\n Derive as _Derive,\n mFallback,\n gtFallback,\n} from 'gt-react/internal';\n\n/**\n * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.\n *\n * @param {React.ReactNode} children - The children components that will use the translation context.\n * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.\n * @param {string} locale - The locale to use for the translation context.\n *\n * @returns {JSX.Element} The provider component for General Translation context.\n */\nexport const GTProvider: typeof _GTProvider = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport const T: typeof _T = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate';\n\n/**\n * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.\n *\n * @example\n * ```jsx\n * <Currency\n * currency=\"USD\"\n * >\n * 1000\n * </Currency>\n * ```\n *\n * @param {any} [children] - Optional content to render inside the currency component.\n * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).\n * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.\n * @returns {React.JSX.Element} The formatted currency component.\n */\nexport const Currency: typeof _Currency = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nCurrency._gtt = 'variable-currency';\n\n/**\n * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.\n * It utilizes the current locale and optional format settings to display the date.\n *\n * @example\n * ```jsx\n * <DateTime>\n * {new Date()}\n * </DateTime>\n * ```\n *\n * @param {any} [children] - Optional content (typically a date) to render inside the component.\n * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.\n * @returns {Promise<React.JSX.Element>} The formatted date or time component.\n */\nexport const DateTime: typeof _DateTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDateTime._gtt = 'variable-datetime';\n\n/**\n * The `<RelativeTime>` component renders a localized relative time string\n * (e.g., \"2 hours ago\", \"in 3 days\") using `Intl.RelativeTimeFormat`.\n *\n * @example\n * ```jsx\n * <RelativeTime date={someDate} />\n * ```\n *\n * @param {Date} [date] - A date to compute relative time from now.\n * @param {number} [value] - Explicit numeric value. Requires `unit`.\n * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.\n * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.\n * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.\n * @returns {Promise<React.JSX.Element>} The formatted relative time component.\n */\nexport const RelativeTime: typeof _RelativeTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nRelativeTime._gtt = 'variable-relative-time';\n\n/**\n * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.\n * It formats the number according to the current locale and optionally passed formatting options.\n *\n * @example\n * ```jsx\n * <Num\n * options={{ style: \"decimal\", maximumFractionDigits: 2 }}\n * >\n * 1000\n * </Num>\n * ```\n *\n * @param {any} [children] - Optional content (typically a number) to render inside the component.\n * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.\n * @returns {React.JSX.Element} The formatted number component.\n */\nexport const Num: typeof _Num = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nNum._gtt = 'variable-number';\n\n/**\n * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.\n * If `children` is provided, it will be used; otherwise, the `value` is rendered.\n *\n * @example\n * ```jsx\n * <Var>\n * John\n * </Var>\n * ```\n *\n * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.\n * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.\n */\nexport const Var: typeof _Var = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nVar._gtt = 'variable-variable';\n\n/**\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` inside translated JSX when child content is computed from\n * source code, but should still be discovered during extraction instead of\n * treated as a runtime interpolation variable. The CLI attempts to resolve the\n * derivable children into every possible static value and includes those values\n * in the source content that gets translated.\n *\n * `<Derive>` renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `<Derive>` usage to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Derive>\n * {getSubject()}\n * </Derive>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Derive: typeof _Derive = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDerive._gtt = 'derive';\n\n/**\n * @deprecated Use `<Derive>` instead.\n *\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` instead of `<Static>` for new code. This alias is kept for\n * backwards compatibility and renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing derived JSX content to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Static>\n * {getSubject()}\n * </Static>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Static: typeof _Static = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nStatic._gtt = 'derive';\n\n/**\n * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.\n * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).\n * If the specified `branch` is present in the `branches` object, it renders the content of that branch.\n * If the `branch` is not found, it renders the provided `children` as fallback content.\n *\n * @example\n * ```jsx\n * <Branch\n * branch=\"summary\"\n * summary={<p>This is a summary</p>}\n * details={<p>Details here</p>}\n * >\n * <p>Fallback content</p>\n * </Branch>\n * ```\n * If the `branch` prop is set to `\"summary\"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.\n *\n * @param {any} [children] - Fallback content to render if no matching branch is found.\n * @param {string} [name=\"branch\"] - Optional name for the component, used for metadata or tracking purposes.\n * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.\n * @returns {React.JSX.Element} The rendered branch or fallback content.\n */\nexport const Branch: typeof _Branch = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nBranch._gtt = 'branch';\n\n/**\n * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).\n * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,\n * based on the current locale or a default locale. If no matching plural branch is found, the component renders\n * the fallback `children` content.\n *\n * @example\n * ```jsx\n * <Plural\n * n={1}\n * one=\"There is 1 item\"\n * other=\"There are {n} items\"\n * />\n * ```\n * In this example, if `n` is 1, it renders `\"There is 1 item\"`. If `n` is a different number, it renders\n * `\"There are {n} items\"`.\n *\n * @param {any} [children] - Fallback content to render if no matching plural branch is found.\n * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.\n * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular\n * and `other` for plural forms, but it may vary depending on the locale.\n * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.\n * @throws {Error} If `n` is not provided or not a valid number.\n */\nexport const Plural: typeof _Plural = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nPlural._gtt = 'plural';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} locales - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} customNames - An optional object to map locales to custom names.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport const LocaleSelector: typeof _LocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the string translation function `t`.\n *\n * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.\n * @param {InlineTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.\n * @param {string} [options.$context] - Additional context for the translation.\n * @param {string} [options.$id] - Optional identifier for the translation string.\n * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.\n * @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.\n * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n *\n * @example\n * const t = useGT();\n * console.log(t('To be or not to be...'));\n *\n * const t = useGT();\n * return (<>\n * {\n * t('My name is {customName}', { customName: \"Brian\" } )\n * }\n * </>);\n *\n */\nexport const useGT: (\n _messages?: _Messages\n) => (message: string, options?: InlineTranslationOptions) => string = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the dictionary access function `t`.\n *\n * @param {string} [id] - Optional prefix to prepend to the translation keys.\n * @returns {Function} A translation function that accepts a key string and returns the translated value.\n * The returned function accepts `DictionaryTranslationOptions` which includes:\n * - `$format` - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n * - `$maxChars` - Maximum number of characters for the translated message.\n *\n * @example\n * const t = useTranslations('user');\n * console.log(t('name')); // Translates item 'user.name'\n *\n * const t = useTranslations();\n * console.log(t('hello')); // Translates item 'hello'\n */\nexport const useTranslations: typeof _useTranslations = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current locale.\n *\n * @returns {string} BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useLocale: typeof _useLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's list of supported locales.\n *\n * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].\n *\n * @example\n * const locales = useLocales();\n * console.log(locale); // ['en-US', 'fr', 'jp]\n */\nexport const useLocales: typeof _useLocales = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the application's default locale.\n *\n * If no default locale is provided, it defaults to 'en'.\n *\n * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useDefaultLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useDefaultLocale: typeof _useDefaultLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the configured GT class instance.\n *\n * @returns {GT} The configured GT class instance.\n *\n * @example\n * const gt = useGTClass();\n * console.log(gt.getLocaleProperties('en-US'));\n */\nexport const useGTClass: typeof _useGTClass = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the locale properties for the given locale.\n *\n * @param {string} locale - The locale to get the properties for.\n * @returns {LocaleProperties} The locale properties for the given locale.\n *\n * @example\n * const localeProperties = useLocaleProperties('en-US');\n * console.log(localeProperties);\n */\nexport const useLocaleProperties: typeof _useLocaleProperties = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.\n *\n * If no locale is provided, the direction for the current user's locale is returned.\n *\n * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.\n * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.\n *\n * @example\n * const dir = useLocaleDirection(); // e.g., 'ltr'\n * const arabicDir = useLocaleDirection('ar'); // 'rtl'\n */\nexport const useLocaleDirection: typeof _useLocaleDirection = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the version ID for the current source, if set.\n *\n * @returns {string | undefined} The version ID.\n *\n * @example\n * const versionId = useVersionId();\n * console.log(versionId); // 'abc123'\n */\nexport const useVersionId: typeof _useVersionId = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * A dropdown component that allows users to select a region.\n *\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales. The value can be a string (display name) or an object with `name`, `emoji`, and/or `locale` properties.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @param {object} [props] - Additional props to pass to the underlying `<select>` element.\n * @returns {React.JSX.Element | null} The rendered region dropdown component or null if no regions are available.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"🇺🇸\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport const RegionSelector: typeof _RegionSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Registers a message to be translated. Returns the message unchanged if no options are provided.\n * @param {string | string[]} message The message to encode.\n * @param {InlineTranslationOptions} [options] The options to encode.\n * @returns The message or array of messages.\n *\n * @note - This function registers the message before the build process. The actual translation does not\n * occur until the m() function is invoked.\n *\n * @note - Message format\n * A message is broken into two parts separated by colons:\n * - interpolated content - the content with interpolated variables\n * - hash + options - a unique identifier for the source content and options for the translation\n *\n * @example - Basic usage\n *\n * const message1 = msg('Hello, World!');\n * console.log(message1); // \"Hello, World!\"\n *\n * const message2 = msg('Hello, {name}!', { name: 'Brian' });\n * console.log(message2); // \"Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9\"\n *\n * @example - Array usage\n *\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);\n * console.log(messages); // [\"Hello, Alice!\", \"Hello, Bob!\"]\n *\n * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });\n * // \"Hello, Alice!\" id: \"greetings.0\"\n * // \"Hello, Bob!\" id: \"greetings.1\"\n */\nexport const useMessages: (\n _messages?: _Messages\n) => <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n) => T extends string ? string : T = () => {\n throw new Error(typesFileError);\n};\n\nexport type {\n DictionaryTranslationOptions,\n InlineTranslationOptions,\n RuntimeTranslationOptions,\n};\n\nexport type { StringFormat };\n\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n mFallback,\n gtFallback,\n derive,\n declareVar,\n decodeVars,\n};\n\n/** @deprecated Use derive() instead. */\nexport { declareStatic };\n"],"mappings":";;;;;;;;;;;;;;AAoDA,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCjC,MAAa,UAAqB;AAChC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,EAAE,OAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;AAiBhB,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;;AAkBhB,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,aAAa,OAAO;;;;;;;;;;;;;;;;;;AAmBpB,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;AAgBX,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCX,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;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","sources":["../../src/request/localeValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"localeValidation.d.ts","sourceRoot":"","sources":["../../src/request/localeValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAsBzE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,iBAAiB,EAC7B,EAAE,EAAE,EAAE,GACL,MAAM,CAWR;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAKnE"}
|
|
@@ -7,6 +7,7 @@ function determineSupportedLocale(locale, I18NConfig, gt) {
|
|
|
7
7
|
return gt.determineLocale([locale], I18NConfig.getLocales());
|
|
8
8
|
}
|
|
9
9
|
function warnInvalidLocale(locale, defaultLocale) {
|
|
10
|
+
if (process.env._GENERALTRANSLATION_DISABLE_INVALID_LOCALE_WARNING === "true") return;
|
|
10
11
|
console.warn(require_errors_createErrors.createInvalidRequestLocaleWarning(locale, defaultLocale));
|
|
11
12
|
}
|
|
12
13
|
function resolveLocaleOrDefault(locale, I18NConfig, gt) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeValidation.js","names":["createInvalidRequestLocaleWarning","getI18NConfig"],"sources":["../../src/request/localeValidation.ts"],"sourcesContent":["import type { GT } from 'generaltranslation';\nimport { getI18NConfig } from '../config-dir/getI18NConfig';\nimport type { I18NConfiguration } from '../config-dir/I18NConfiguration';\nimport { createInvalidRequestLocaleWarning } from '../errors/createErrors';\n\nfunction determineSupportedLocale(\n locale: unknown,\n I18NConfig: I18NConfiguration,\n gt: GT\n): string | undefined {\n if (typeof locale !== 'string' || locale.length === 0) return undefined;\n return gt.determineLocale([locale], I18NConfig.getLocales());\n}\n\nfunction warnInvalidLocale(locale: string, defaultLocale: string) {\n console.warn(createInvalidRequestLocaleWarning(locale, defaultLocale));\n}\n\nexport function resolveLocaleOrDefault(\n locale: unknown,\n I18NConfig: I18NConfiguration,\n gt: GT\n): string {\n const defaultLocale = I18NConfig.getDefaultLocale();\n const supportedLocale = determineSupportedLocale(locale, I18NConfig, gt);\n\n if (supportedLocale) return gt.resolveAliasLocale(supportedLocale);\n\n if (typeof locale === 'string' && locale.length > 0) {\n warnInvalidLocale(locale, defaultLocale);\n }\n\n return gt.resolveAliasLocale(defaultLocale);\n}\n\n/**\n * Checks whether a locale is valid and supported by the current gt-next config.\n *\n * Use this when route params or other request inputs should be rejected instead\n * of falling back to the default locale.\n *\n * @param locale - The locale candidate to validate.\n * @returns True when the locale resolves to one of the configured locales.\n */\nexport function isLocaleSupported(locale: unknown): locale is string {\n const I18NConfig = getI18NConfig();\n const gt = I18NConfig.getGTClass();\n\n return determineSupportedLocale(locale, I18NConfig, gt) !== undefined;\n}\n"],"mappings":";;;;AAKA,SAAS,yBACP,QACA,YACA,IACoB;AACpB,KAAI,OAAO,WAAW,YAAY,OAAO,WAAW,EAAG,QAAO,KAAA;AAC9D,QAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,WAAW,YAAY,CAAC;;AAG9D,SAAS,kBAAkB,QAAgB,eAAuB;AAChE,SAAQ,KAAKA,4BAAAA,kCAAkC,QAAQ,cAAc,CAAC;;AAGxE,SAAgB,uBACd,QACA,YACA,IACQ;CACR,MAAM,gBAAgB,WAAW,kBAAkB;CACnD,MAAM,kBAAkB,yBAAyB,QAAQ,YAAY,GAAG;AAExE,KAAI,gBAAiB,QAAO,GAAG,mBAAmB,gBAAgB;AAElE,KAAI,OAAO,WAAW,YAAY,OAAO,SAAS,EAChD,mBAAkB,QAAQ,cAAc;AAG1C,QAAO,GAAG,mBAAmB,cAAc;;;;;;;;;;;AAY7C,SAAgB,kBAAkB,QAAmC;CACnE,MAAM,aAAaC,iCAAAA,eAAe;AAGlC,QAAO,yBAAyB,QAAQ,YAF7B,WAAW,YAEgC,CAAC,KAAK,KAAA"}
|
|
1
|
+
{"version":3,"file":"localeValidation.js","names":["createInvalidRequestLocaleWarning","getI18NConfig"],"sources":["../../src/request/localeValidation.ts"],"sourcesContent":["import type { GT } from 'generaltranslation';\nimport { getI18NConfig } from '../config-dir/getI18NConfig';\nimport type { I18NConfiguration } from '../config-dir/I18NConfiguration';\nimport { createInvalidRequestLocaleWarning } from '../errors/createErrors';\n\nfunction determineSupportedLocale(\n locale: unknown,\n I18NConfig: I18NConfiguration,\n gt: GT\n): string | undefined {\n if (typeof locale !== 'string' || locale.length === 0) return undefined;\n return gt.determineLocale([locale], I18NConfig.getLocales());\n}\n\nfunction warnInvalidLocale(locale: string, defaultLocale: string) {\n if (\n process.env._GENERALTRANSLATION_DISABLE_INVALID_LOCALE_WARNING === 'true'\n ) {\n return;\n }\n\n console.warn(createInvalidRequestLocaleWarning(locale, defaultLocale));\n}\n\nexport function resolveLocaleOrDefault(\n locale: unknown,\n I18NConfig: I18NConfiguration,\n gt: GT\n): string {\n const defaultLocale = I18NConfig.getDefaultLocale();\n const supportedLocale = determineSupportedLocale(locale, I18NConfig, gt);\n\n if (supportedLocale) return gt.resolveAliasLocale(supportedLocale);\n\n if (typeof locale === 'string' && locale.length > 0) {\n warnInvalidLocale(locale, defaultLocale);\n }\n\n return gt.resolveAliasLocale(defaultLocale);\n}\n\n/**\n * Checks whether a locale is valid and supported by the current gt-next config.\n *\n * Use this when route params or other request inputs should be rejected instead\n * of falling back to the default locale.\n *\n * @param locale - The locale candidate to validate.\n * @returns True when the locale resolves to one of the configured locales.\n */\nexport function isLocaleSupported(locale: unknown): locale is string {\n const I18NConfig = getI18NConfig();\n const gt = I18NConfig.getGTClass();\n\n return determineSupportedLocale(locale, I18NConfig, gt) !== undefined;\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;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,CAAC,CAAC,EACtB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,KAAK,EACL,GAAG,OAAO,EACX,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/T.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAYjD,KAAK,MAAM,GAAG;IACZ,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,CAAC,CAAC,EACtB,QAAQ,EACR,EAAE,EACF,OAAO,EACP,KAAK,EACL,GAAG,OAAO,EACX,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAsK7B;yBA5KqB,CAAC"}
|
|
@@ -45,6 +45,7 @@ async function T({ children, id, context, _hash, ...options }) {
|
|
|
45
45
|
id = id ?? options?.$id;
|
|
46
46
|
context = context ?? options?.$context;
|
|
47
47
|
const maxChars = options?.$maxChars;
|
|
48
|
+
const requiresReview = typeof options?.$requiresReview === "boolean" ? options.$requiresReview : typeof options?.requiresReview === "boolean" ? options.requiresReview : void 0;
|
|
48
49
|
const taggedChildren = (0, gt_react_internal.addGTIdentifier)(children);
|
|
49
50
|
const renderDefault = () => {
|
|
50
51
|
return (0, gt_react_internal.renderDefaultChildren)({
|
|
@@ -65,6 +66,7 @@ async function T({ children, id, context, _hash, ...options }) {
|
|
|
65
66
|
source: childrenAsObjects,
|
|
66
67
|
...context && { context },
|
|
67
68
|
...maxChars != null && { maxChars: Math.abs(maxChars) },
|
|
69
|
+
...requiresReview === true && { requiresReview: true },
|
|
68
70
|
...id && { id },
|
|
69
71
|
dataFormat: "JSX"
|
|
70
72
|
});
|
|
@@ -91,6 +93,7 @@ async function T({ children, id, context, _hash, ...options }) {
|
|
|
91
93
|
source: childrenAsObjects,
|
|
92
94
|
...context && { context },
|
|
93
95
|
...maxChars != null && { maxChars: Math.abs(maxChars) },
|
|
96
|
+
...requiresReview === true && { requiresReview: true },
|
|
94
97
|
...id && { id },
|
|
95
98
|
dataFormat: "JSX"
|
|
96
99
|
});
|
|
@@ -102,7 +105,8 @@ async function T({ children, id, context, _hash, ...options }) {
|
|
|
102
105
|
$_hash: hash,
|
|
103
106
|
$format: "JSX",
|
|
104
107
|
...context && { $context: context },
|
|
105
|
-
...maxChars != null && { $maxChars: maxChars }
|
|
108
|
+
...maxChars != null && { $maxChars: maxChars },
|
|
109
|
+
...requiresReview === true && { $requiresReview: true }
|
|
106
110
|
}
|
|
107
111
|
}));
|
|
108
112
|
} catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"T.js","names":["getI18NConfig","getLocale","Suspense"],"sources":["../../../src/server-dir/buildtime/T.tsx"],"sourcesContent":["import { getI18NConfig } from '../../config-dir/getI18NConfig';\nimport { getLocale } from '../../request/getLocale';\nimport { Suspense, type ReactNode } from 'react';\nimport {\n addGTIdentifier,\n renderDefaultChildren,\n renderSkeleton,\n renderTranslatedChildren,\n TranslatedChildren,\n writeChildrenAsObjects,\n} from 'gt-react/internal';\nimport { renderVariable } from '../variables/renderVariable';\nimport { hashSource } from 'generaltranslation/id';\n\ntype TProps = {\n children: ReactNode;\n id?: string;\n context?: string;\n _hash?: string;\n $id?: string;\n $context?: string;\n $maxChars?: number;\n [key: string]: ReactNode;\n};\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport async function T({\n children,\n id,\n context,\n _hash,\n ...options\n}: TProps): Promise<ReactNode> {\n // ----- SET UP ----- //\n\n const I18NConfig = getI18NConfig();\n const locale = await getLocale();\n const defaultLocale = I18NConfig.getDefaultLocale();\n const [translationRequired, dialectTranslationRequired] =\n I18NConfig.requiresTranslation(locale);\n\n // Compatibility with different options\n id = id ?? options?.$id;\n context = context ?? options?.$context;\n const maxChars = options?.$maxChars;\n\n // ----- TAG CHILDREN ----- //\n\n const taggedChildren = addGTIdentifier(children);\n\n // ----- RENDERING FUNCTION #1: CONTENT IN DEFAULT LOCALE ----- //\n\n // render in default language\n const renderDefault = () => {\n return renderDefaultChildren({\n children: taggedChildren,\n defaultLocale,\n renderVariable,\n });\n };\n\n // ----- CHECK TRANSLATIONS REQUIRED ----- //\n\n // If no translation is required, render the default children\n // The dictionary wraps text in this <T> component\n // Thus, we need to also handle variables\n if (!translationRequired) {\n return renderDefault();\n }\n\n // ----- CHECK CACHED TRANSLATIONS ----- //\n\n // Begin by sending check to cache for translations\n const translationsPromise = I18NConfig.getCachedTranslations(locale);\n\n // Get the translation entry object\n const translations = await translationsPromise;\n\n let translationEntry = translations?.[id || ''];\n\n let hash;\n if (_hash && typeof translationEntry === 'undefined') {\n translationEntry = translations?.[_hash];\n }\n\n let childrenAsObjects;\n\n if (!translationEntry) {\n // Turns tagged children into objects\n // The hash is used to identify the translation\n childrenAsObjects = writeChildrenAsObjects(taggedChildren);\n hash = hashSource({\n source: childrenAsObjects,\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(id && { id }),\n dataFormat: 'JSX',\n });\n translationEntry = translations?.[hash];\n }\n\n // ----- RENDERING FUNCTION #2: RENDER TRANSLATED CONTENT ----- //\n\n const renderTranslation = (target: TranslatedChildren) => {\n return renderTranslatedChildren({\n source: taggedChildren,\n target,\n locales: [locale, defaultLocale],\n renderVariable,\n });\n };\n\n // ----- RENDER CACHED TRANSLATIONS ----- //\n\n // if we have a cached translation, render it\n if (translationEntry) {\n return (\n <Suspense fallback={renderTranslation(translationEntry)}>\n {renderTranslation(translationEntry)}\n </Suspense>\n );\n }\n\n if (\n // translationEntry === null || // If there was an error\n !I18NConfig.isDevelopmentApiEnabled() // Development translation disabled\n ) {\n return renderDefault();\n }\n\n // ----- TRANSLATE ON DEMAND ----- //\n // Since this is the buildtime translation component <T>, everything below is dev-only\n\n // Get render settings\n const renderSettings = I18NConfig.getRenderSettings();\n\n // Send on-demand translation request\n // (no entry has been found, this means that the translation is either (1) loading or (2) missing)\n const translationPromise = (async () => {\n try {\n childrenAsObjects ||= writeChildrenAsObjects(taggedChildren);\n hash ||=\n _hash ||\n hashSource({\n source: childrenAsObjects,\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(id && { id }),\n dataFormat: 'JSX',\n });\n const target = await I18NConfig.translate({\n // do on demand translation\n source: childrenAsObjects,\n targetLocale: locale,\n options: {\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'JSX',\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n },\n });\n return renderTranslation(target);\n } catch {\n return renderDefault();\n }\n })();\n\n // ----- DEFINE LOADING BEHAVIOR ----- //\n\n let loadingFallback;\n if (renderSettings.method === 'replace') {\n loadingFallback = renderDefault();\n } else if (renderSettings.method === 'skeleton') {\n loadingFallback = renderSkeleton();\n } else {\n loadingFallback = dialectTranslationRequired\n ? renderDefault()\n : renderSkeleton();\n }\n\n return (\n <Suspense key={locale} fallback={loadingFallback}>\n {translationPromise}\n </Suspense>\n );\n}\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-server';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"T.js","names":["getI18NConfig","getLocale","Suspense"],"sources":["../../../src/server-dir/buildtime/T.tsx"],"sourcesContent":["import { getI18NConfig } from '../../config-dir/getI18NConfig';\nimport { getLocale } from '../../request/getLocale';\nimport { Suspense, type ReactNode } from 'react';\nimport {\n addGTIdentifier,\n renderDefaultChildren,\n renderSkeleton,\n renderTranslatedChildren,\n TranslatedChildren,\n writeChildrenAsObjects,\n} from 'gt-react/internal';\nimport { renderVariable } from '../variables/renderVariable';\nimport { hashSource } from 'generaltranslation/id';\n\ntype TProps = {\n children: ReactNode;\n id?: string;\n context?: string;\n _hash?: string;\n $id?: string;\n $context?: string;\n $maxChars?: number;\n requiresReview?: boolean;\n $requiresReview?: boolean;\n [key: string]: ReactNode;\n};\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport async function T({\n children,\n id,\n context,\n _hash,\n ...options\n}: TProps): Promise<ReactNode> {\n // ----- SET UP ----- //\n\n const I18NConfig = getI18NConfig();\n const locale = await getLocale();\n const defaultLocale = I18NConfig.getDefaultLocale();\n const [translationRequired, dialectTranslationRequired] =\n I18NConfig.requiresTranslation(locale);\n\n // Compatibility with different options\n id = id ?? options?.$id;\n context = context ?? options?.$context;\n const maxChars = options?.$maxChars;\n const requiresReview =\n typeof options?.$requiresReview === 'boolean'\n ? options.$requiresReview\n : typeof options?.requiresReview === 'boolean'\n ? options.requiresReview\n : undefined;\n\n // ----- TAG CHILDREN ----- //\n\n const taggedChildren = addGTIdentifier(children);\n\n // ----- RENDERING FUNCTION #1: CONTENT IN DEFAULT LOCALE ----- //\n\n // render in default language\n const renderDefault = () => {\n return renderDefaultChildren({\n children: taggedChildren,\n defaultLocale,\n renderVariable,\n });\n };\n\n // ----- CHECK TRANSLATIONS REQUIRED ----- //\n\n // If no translation is required, render the default children\n // The dictionary wraps text in this <T> component\n // Thus, we need to also handle variables\n if (!translationRequired) {\n return renderDefault();\n }\n\n // ----- CHECK CACHED TRANSLATIONS ----- //\n\n // Begin by sending check to cache for translations\n const translationsPromise = I18NConfig.getCachedTranslations(locale);\n\n // Get the translation entry object\n const translations = await translationsPromise;\n\n let translationEntry = translations?.[id || ''];\n\n let hash;\n if (_hash && typeof translationEntry === 'undefined') {\n translationEntry = translations?.[_hash];\n }\n\n let childrenAsObjects;\n\n if (!translationEntry) {\n // Turns tagged children into objects\n // The hash is used to identify the translation\n childrenAsObjects = writeChildrenAsObjects(taggedChildren);\n hash = hashSource({\n source: childrenAsObjects,\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(requiresReview === true && { requiresReview: true }),\n ...(id && { id }),\n dataFormat: 'JSX',\n });\n translationEntry = translations?.[hash];\n }\n\n // ----- RENDERING FUNCTION #2: RENDER TRANSLATED CONTENT ----- //\n\n const renderTranslation = (target: TranslatedChildren) => {\n return renderTranslatedChildren({\n source: taggedChildren,\n target,\n locales: [locale, defaultLocale],\n renderVariable,\n });\n };\n\n // ----- RENDER CACHED TRANSLATIONS ----- //\n\n // if we have a cached translation, render it\n if (translationEntry) {\n return (\n <Suspense fallback={renderTranslation(translationEntry)}>\n {renderTranslation(translationEntry)}\n </Suspense>\n );\n }\n\n if (\n // translationEntry === null || // If there was an error\n !I18NConfig.isDevelopmentApiEnabled() // Development translation disabled\n ) {\n return renderDefault();\n }\n\n // ----- TRANSLATE ON DEMAND ----- //\n // Since this is the buildtime translation component <T>, everything below is dev-only\n\n // Get render settings\n const renderSettings = I18NConfig.getRenderSettings();\n\n // Send on-demand translation request\n // (no entry has been found, this means that the translation is either (1) loading or (2) missing)\n const translationPromise = (async () => {\n try {\n childrenAsObjects ||= writeChildrenAsObjects(taggedChildren);\n hash ||=\n _hash ||\n hashSource({\n source: childrenAsObjects,\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(requiresReview === true && { requiresReview: true }),\n ...(id && { id }),\n dataFormat: 'JSX',\n });\n // Dev-mode runtime translation is intentionally NOT review-gated (it's\n // a live preview; review gates production serving) — the flag rides\n // along so the platform records review intent on anything it persists\n const target = await I18NConfig.translate({\n // do on demand translation\n source: childrenAsObjects,\n targetLocale: locale,\n options: {\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'JSX',\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n ...(requiresReview === true && { $requiresReview: true }),\n },\n });\n return renderTranslation(target);\n } catch {\n return renderDefault();\n }\n })();\n\n // ----- DEFINE LOADING BEHAVIOR ----- //\n\n let loadingFallback;\n if (renderSettings.method === 'replace') {\n loadingFallback = renderDefault();\n } else if (renderSettings.method === 'skeleton') {\n loadingFallback = renderSkeleton();\n } else {\n loadingFallback = dialectTranslationRequired\n ? renderDefault()\n : renderSkeleton();\n }\n\n return (\n <Suspense key={locale} fallback={loadingFallback}>\n {translationPromise}\n </Suspense>\n );\n}\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate-server';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,eAAsB,EAAE,EACtB,UACA,IACA,SACA,OACA,GAAG,WAC0B;CAG7B,MAAM,aAAaA,iCAAAA,eAAe;CAClC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,gBAAgB,WAAW,kBAAkB;CACnD,MAAM,CAAC,qBAAqB,8BAC1B,WAAW,oBAAoB,OAAO;AAGxC,MAAK,MAAM,SAAS;AACpB,WAAU,WAAW,SAAS;CAC9B,MAAM,WAAW,SAAS;CAC1B,MAAM,iBACJ,OAAO,SAAS,oBAAoB,YAChC,QAAQ,kBACR,OAAO,SAAS,mBAAmB,YACjC,QAAQ,iBACR,KAAA;CAIR,MAAM,kBAAA,GAAA,kBAAA,iBAAiC,SAAS;CAKhD,MAAM,sBAAsB;AAC1B,UAAA,GAAA,kBAAA,uBAA6B;GAC3B,UAAU;GACV;GACA,gBAAA,4CAAA;GACD,CAAC;;AAQJ,KAAI,CAAC,oBACH,QAAO,eAAe;CASxB,MAAM,eAAe,MAHO,WAAW,sBAAsB,OAGf;CAE9C,IAAI,mBAAmB,eAAe,MAAM;CAE5C,IAAI;AACJ,KAAI,SAAS,OAAO,qBAAqB,YACvC,oBAAmB,eAAe;CAGpC,IAAI;AAEJ,KAAI,CAAC,kBAAkB;AAGrB,uBAAA,GAAA,kBAAA,wBAA2C,eAAe;AAC1D,UAAA,GAAA,sBAAA,YAAkB;GAChB,QAAQ;GACR,GAAI,WAAW,EAAE,SAAS;GAC1B,GAAI,YAAY,QAAQ,EAAE,UAAU,KAAK,IAAI,SAAS,EAAE;GACxD,GAAI,mBAAmB,QAAQ,EAAE,gBAAgB,MAAM;GACvD,GAAI,MAAM,EAAE,IAAI;GAChB,YAAY;GACb,CAA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UAAD;EAAuB,UAAU;YAC9B;EACQ,EAFI,OAEJ;;;AAIf,EAAE,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslationFunction.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,wBAAwB,EAExB,SAAS,EACV,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getTranslationFunction.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,wBAAwB,EAExB,SAAS,EACV,MAAM,mBAAmB,CAAC;AA0d3B;;;;;;;;;;;;;GAaG;AACH,wBAAsB,KAAK,CACzB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAC,CAG1E;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,aARtB,MAAM,YAAY,wBAAwB,KAAK,MAAM,CAUzE;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,EACR,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,UAAU,EAAE,CAAC,EACb,OAAO,CAAC,EAAE,wBAAwB,KAC/B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAAC,EACnC,CAGA;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,CAAC,EAAE,SAAS,GACpB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,UAAU,EAAE,CAAC,EACb,OAAO,CAAC,EAAE,wBAAwB,KAC/B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAAC,CAEjC"}
|
|
@@ -60,7 +60,7 @@ async function createTranslator(_messages) {
|
|
|
60
60
|
}
|
|
61
61
|
function initializeGT(message, options = {}) {
|
|
62
62
|
if (!message || typeof message !== "string") return null;
|
|
63
|
-
const { $id: id, $context: context, $maxChars: maxChars, $_hash: _hash, $format: format, ...variables } = options;
|
|
63
|
+
const { $id: id, $context: context, $maxChars: maxChars, $_hash: _hash, $format: format, $requiresReview: requiresReview, ...variables } = options;
|
|
64
64
|
const formatVariables = variables;
|
|
65
65
|
const renderMessage = (msg, locales, fallback) => {
|
|
66
66
|
return renderMessageHelper({
|
|
@@ -77,6 +77,7 @@ async function createTranslator(_messages) {
|
|
|
77
77
|
source: (0, generaltranslation_internal.indexVars)(message),
|
|
78
78
|
...context && { context },
|
|
79
79
|
...maxChars != null && { maxChars: Math.abs(maxChars) },
|
|
80
|
+
...requiresReview === true && { requiresReview: true },
|
|
80
81
|
...id && { id },
|
|
81
82
|
dataFormat: format || "ICU"
|
|
82
83
|
});
|
|
@@ -84,6 +85,7 @@ async function createTranslator(_messages) {
|
|
|
84
85
|
id,
|
|
85
86
|
context,
|
|
86
87
|
maxChars,
|
|
88
|
+
requiresReview,
|
|
87
89
|
_hash,
|
|
88
90
|
variables: formatVariables,
|
|
89
91
|
calculateHash,
|
|
@@ -108,7 +110,7 @@ async function createTranslator(_messages) {
|
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
112
|
function scheduleTranslateOnDemand(args) {
|
|
111
|
-
const { source, context, maxChars, id, hash, renderMessage } = args;
|
|
113
|
+
const { source, context, maxChars, requiresReview, id, hash, renderMessage } = args;
|
|
112
114
|
try {
|
|
113
115
|
I18NConfig.translate({
|
|
114
116
|
source: (0, generaltranslation_internal.indexVars)(source),
|
|
@@ -116,6 +118,7 @@ async function createTranslator(_messages) {
|
|
|
116
118
|
options: {
|
|
117
119
|
...context && { $context: context },
|
|
118
120
|
...maxChars != null && { $maxChars: maxChars },
|
|
121
|
+
...requiresReview === true && { $requiresReview: true },
|
|
119
122
|
...id && { $id: id },
|
|
120
123
|
$_hash: hash,
|
|
121
124
|
$format: "ICU"
|
|
@@ -138,7 +141,7 @@ async function createTranslator(_messages) {
|
|
|
138
141
|
if (!message) return;
|
|
139
142
|
const init = initializeGT(message, options);
|
|
140
143
|
if (!init) return;
|
|
141
|
-
const { id, context, maxChars, _hash, calculateHash } = init;
|
|
144
|
+
const { id, context, maxChars, requiresReview, _hash, calculateHash } = init;
|
|
142
145
|
const { translationEntry, hash } = getTranslationData(calculateHash, id, _hash);
|
|
143
146
|
if (translationEntry) return;
|
|
144
147
|
try {
|
|
@@ -148,6 +151,7 @@ async function createTranslator(_messages) {
|
|
|
148
151
|
options: {
|
|
149
152
|
...context && { $context: context },
|
|
150
153
|
...maxChars != null && { $maxChars: maxChars },
|
|
154
|
+
...requiresReview === true && { $requiresReview: true },
|
|
151
155
|
...id && { $id: id },
|
|
152
156
|
$_hash: hash,
|
|
153
157
|
$format: "ICU"
|
|
@@ -162,7 +166,7 @@ async function createTranslator(_messages) {
|
|
|
162
166
|
const gt = (message, options = {}) => {
|
|
163
167
|
const init = initializeGT(message, options);
|
|
164
168
|
if (!init) return "";
|
|
165
|
-
const { id, context, maxChars, _hash, calculateHash, renderMessage } = init;
|
|
169
|
+
const { id, context, maxChars, requiresReview, _hash, calculateHash, renderMessage } = init;
|
|
166
170
|
if (!translationRequired) return renderMessage(message, [defaultLocale]);
|
|
167
171
|
const { translationEntry, hash } = getTranslationData(calculateHash, id, _hash);
|
|
168
172
|
if (translationEntry) return renderMessage(translationEntry, [locale, defaultLocale], message);
|
|
@@ -175,6 +179,7 @@ async function createTranslator(_messages) {
|
|
|
175
179
|
source: message,
|
|
176
180
|
context,
|
|
177
181
|
maxChars,
|
|
182
|
+
requiresReview,
|
|
178
183
|
id,
|
|
179
184
|
hash,
|
|
180
185
|
renderMessage
|
|
@@ -185,11 +190,12 @@ async function createTranslator(_messages) {
|
|
|
185
190
|
if (!encodedMsg) return encodedMsg;
|
|
186
191
|
const decodedOptions = (0, gt_react_internal.decodeOptions)(encodedMsg);
|
|
187
192
|
if (!decodedOptions || typeof decodedOptions.$_hash !== "string" || typeof decodedOptions.$_source !== "string") return gt(encodedMsg, options);
|
|
188
|
-
const { $_hash, $_source, $context, $id, $maxChars, $format, ...decodedVariables } = decodedOptions;
|
|
193
|
+
const { $_hash, $_source, $context, $id, $maxChars, $format, $requiresReview, ...decodedVariables } = decodedOptions;
|
|
189
194
|
const context = typeof $context === "string" ? $context : void 0;
|
|
190
195
|
const id = typeof $id === "string" ? $id : void 0;
|
|
191
196
|
const maxChars = typeof $maxChars === "number" ? $maxChars : void 0;
|
|
192
197
|
const format = typeof $format === "string" ? $format : void 0;
|
|
198
|
+
const requiresReview = typeof $requiresReview === "boolean" ? $requiresReview : void 0;
|
|
193
199
|
const formatVariables = decodedVariables;
|
|
194
200
|
const renderMessage = (msg, locales, fallback) => {
|
|
195
201
|
return renderMessageHelper({
|
|
@@ -217,6 +223,7 @@ async function createTranslator(_messages) {
|
|
|
217
223
|
source: $_source,
|
|
218
224
|
context,
|
|
219
225
|
maxChars,
|
|
226
|
+
requiresReview,
|
|
220
227
|
id,
|
|
221
228
|
hash: $_hash,
|
|
222
229
|
renderMessage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslationFunction.js","names":["getI18NConfig","getLocale","VAR_IDENTIFIER","createStringRenderWarning","createStringRenderError","createTranslationLoadingWarning","reactHasUse","createStringTranslationError","use"],"sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"sourcesContent":["// getTranslationFunction.ts (refactored)\n\nimport { getI18NConfig } from '../../config-dir/getI18NConfig';\nimport { getLocale } from '../../server';\nimport { hashSource } from 'generaltranslation/id';\nimport {\n createStringRenderError,\n createStringRenderWarning,\n createStringTranslationError,\n createTranslationLoadingWarning,\n} from '../../errors/createErrors';\nimport { decodeMsg, decodeOptions, reactHasUse } from 'gt-react/internal';\nimport type {\n InlineTranslationOptions,\n _Message,\n _Messages,\n} from 'gt-react/internal';\nimport {\n extractVars,\n condenseVars,\n VAR_IDENTIFIER,\n indexVars,\n} from 'generaltranslation/internal';\nimport type {\n FormatVariables,\n StringFormat,\n} from '@generaltranslation/format/types';\nimport { use } from '../../utils/use';\n\ntype RenderFn = (msg: string, locales: string[], fallback?: string) => string;\n\ntype GTStringOptions = InlineTranslationOptions & {\n $context?: string;\n $maxChars?: number;\n $id?: string;\n $_hash?: string;\n};\n\ntype RenderMessageParams = {\n message: string;\n variables: FormatVariables | undefined;\n locales: string[];\n fallback?: string;\n id?: string;\n maxChars?: number;\n format?: StringFormat;\n};\n\ntype InitResult = {\n id?: string;\n context?: string;\n maxChars?: number;\n _hash?: string;\n variables: FormatVariables;\n calculateHash: () => string;\n renderMessage: RenderFn;\n};\n\ntype Translator = {\n gt: (message: string, options?: GTStringOptions) => string;\n m: <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ) => T extends string ? string : T;\n};\n\nasync function createTranslator(_messages?: _Messages): Promise<Translator> {\n // ---------- SET UP ---------- //\n const I18NConfig = getI18NConfig();\n const locale = await getLocale();\n const defaultLocale = I18NConfig.getDefaultLocale();\n const [translationRequired] = I18NConfig.requiresTranslation(locale);\n const gtClass = I18NConfig.getGTClass();\n\n const translations = translationRequired\n ? await I18NConfig.getCachedTranslations(locale)\n : undefined;\n\n // --------- HELPERS --------- //\n /**\n * @description Format message and fallback:\n * (1) format message\n * (2) format fallback\n * (3)\n * - PRODUCTION: return fallback (unformatted)\n * - DEVELOPMENT: throw error\n */\n function renderMessageHelper({\n message,\n variables,\n locales,\n fallback,\n id,\n maxChars,\n format,\n }: RenderMessageParams) {\n try {\n // (1) Try to format message\n const declaredVars = extractVars(fallback || '');\n const formattedMessage = gtClass.formatMessage(\n Object.keys(declaredVars).length ? condenseVars(message) : message,\n {\n locales,\n variables: {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n dataFormat: format,\n }\n );\n const cutoffMessage = gtClass.formatCutoff(formattedMessage, {\n locales,\n maxChars,\n });\n return cutoffMessage;\n } catch (error) {\n if (process.env.NODE_ENV === 'production') {\n console.warn(createStringRenderWarning(message, id, error));\n } else {\n // (3) If no fallback, throw error (non-prod)\n if (!fallback) {\n throw new Error(createStringRenderError(message, id, error));\n }\n\n console.error(createStringRenderError(message, id, error));\n }\n\n // (2) If format fails, format fallback\n if (fallback) {\n return renderMessageHelper({\n message: fallback,\n locales,\n variables,\n id,\n maxChars,\n });\n }\n\n // (3) Fallback to original message (unformatted)\n const cutoffMessage = gtClass.formatCutoff(message, {\n locales,\n maxChars,\n });\n return cutoffMessage; // fallback to original message (unformatted)\n }\n }\n function initializeGT(\n message: string,\n options: GTStringOptions = {}\n ): InitResult | null {\n if (!message || typeof message !== 'string') return null;\n\n const {\n $id: id,\n $context: context,\n $maxChars: maxChars,\n $_hash: _hash,\n $format: format,\n ...variables\n } = options;\n const formatVariables = variables as FormatVariables;\n\n const renderMessage: RenderFn = (msg, locales, fallback) => {\n return renderMessageHelper({\n message: msg,\n locales,\n variables: formatVariables,\n id,\n fallback,\n maxChars,\n format,\n });\n };\n\n const calculateHash = () =>\n hashSource({\n source: indexVars(message),\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(id && { id }),\n dataFormat: format || 'ICU',\n });\n\n return {\n id,\n context,\n maxChars,\n _hash,\n variables: formatVariables,\n calculateHash,\n renderMessage,\n };\n }\n\n function getTranslationData(\n calculateHash: () => string,\n id?: string,\n _hash?: string\n ) {\n let translationEntry;\n let hash = ''; // lazily computed if needed\n if (id) translationEntry = translations?.[id];\n if (!translationEntry && _hash && translations?.[_hash] !== undefined) {\n hash = _hash;\n translationEntry = translations?.[_hash];\n }\n if (!translationEntry) {\n hash = calculateHash();\n translationEntry = translations?.[hash];\n }\n return { translationEntry, hash };\n }\n\n function scheduleTranslateOnDemand(args: {\n source: string;\n context?: string;\n maxChars?: number;\n id?: string;\n hash: string;\n renderMessage: RenderFn;\n }) {\n const { source, context, maxChars, id, hash, renderMessage } = args;\n try {\n I18NConfig.translate({\n source: indexVars(source),\n targetLocale: locale,\n options: {\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'ICU',\n },\n }).then((result) => {\n // eslint-disable-next-line no-console\n console.warn(\n createTranslationLoadingWarning({\n ...(id && { id }),\n source: renderMessage(source, [defaultLocale]),\n translation: renderMessage(\n result as string,\n [locale, defaultLocale],\n source\n ),\n })\n );\n });\n } catch (error) {\n console.warn(error);\n }\n }\n\n // ---------- PRELOAD TRANSLATIONS IF _MESSAGES SUPPLIED --------- //\n let preloadedTranslations: Record<string, string> | undefined;\n if (\n reactHasUse &&\n _messages &&\n I18NConfig.isDevelopmentApiEnabled() &&\n translationRequired\n ) {\n preloadedTranslations = {};\n const preload = async ({\n message,\n ...options\n }: _Message): Promise<void> => {\n if (!message) return;\n const init = initializeGT(message, options);\n if (!init) return;\n\n const { id, context, maxChars, _hash, calculateHash } = init;\n const { translationEntry, hash } = getTranslationData(\n calculateHash,\n id,\n _hash\n );\n if (translationEntry) return; // exists already\n\n try {\n preloadedTranslations![hash] = (await I18NConfig.translate({\n source: indexVars(message),\n targetLocale: locale,\n options: {\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'ICU',\n },\n })) as string;\n } catch (error) {\n console.warn(error);\n }\n };\n await Promise.all(_messages.map(preload));\n }\n\n // ---------- gt() ---------- /\n\n const gt = (message: string, options: GTStringOptions = {}): string => {\n const init = initializeGT(message, options);\n if (!init) return '';\n const { id, context, maxChars, _hash, calculateHash, renderMessage } = init;\n\n // Early: no translation needed\n if (!translationRequired) return renderMessage(message, [defaultLocale]);\n\n const { translationEntry, hash } = getTranslationData(\n calculateHash,\n id,\n _hash\n );\n\n if (translationEntry) {\n return renderMessage(\n translationEntry as string,\n [locale, defaultLocale],\n message\n );\n }\n\n if (!I18NConfig.isDevelopmentApiEnabled()) {\n console.warn(createStringTranslationError(message, id, 't'));\n return renderMessage(message, [defaultLocale]);\n }\n\n if (!translationEntry && preloadedTranslations?.[hash]) {\n return renderMessage(\n preloadedTranslations[hash],\n [locale, defaultLocale],\n message\n );\n }\n\n // On-demand translate\n scheduleTranslateOnDemand({\n source: message,\n context,\n maxChars,\n id,\n hash,\n renderMessage,\n });\n return renderMessage(message, [defaultLocale]);\n };\n\n // ---------- m() ---------- //\n const m = <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ): T extends string ? string : T => {\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Try to decode first\n const decodedOptions = decodeOptions(encodedMsg);\n\n // Fallback to t() if not an encoded message\n if (\n !decodedOptions ||\n typeof decodedOptions.$_hash !== 'string' ||\n typeof decodedOptions.$_source !== 'string'\n ) {\n return gt(encodedMsg, options) as T extends string ? string : T;\n }\n\n const {\n $_hash,\n $_source,\n $context,\n $id,\n $maxChars,\n $format,\n ...decodedVariables\n } = decodedOptions;\n const context = typeof $context === 'string' ? $context : undefined;\n const id = typeof $id === 'string' ? $id : undefined;\n const maxChars = typeof $maxChars === 'number' ? $maxChars : undefined;\n const format = typeof $format === 'string' ? $format : undefined;\n const formatVariables = decodedVariables as FormatVariables;\n\n const renderMessage: RenderFn = (msg, locales, fallback) => {\n return renderMessageHelper({\n message: msg,\n locales,\n variables: formatVariables,\n fallback,\n maxChars,\n format,\n });\n };\n\n // Early: default locale only\n if (!translationRequired)\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n\n // Translation exists?\n const translationEntry = translations?.[$_hash];\n\n if (translationEntry === null) {\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n if (translationEntry) {\n return renderMessage(\n translationEntry as string,\n [locale, defaultLocale],\n $_source\n ) as T extends string ? string : T;\n }\n\n // Dev-only paths for loading or preloaded\n if (!I18NConfig.isDevelopmentApiEnabled()) {\n console.warn(\n createStringTranslationError($_source, decodeMsg(encodedMsg), 'm')\n );\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n if (typeof preloadedTranslations?.[$_hash] !== 'undefined') {\n if (preloadedTranslations?.[$_hash]) {\n return renderMessage(\n preloadedTranslations[$_hash] as string,\n [locale, defaultLocale],\n $_source\n ) as T extends string ? string : T;\n }\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n // On-demand translate\n scheduleTranslateOnDemand({\n source: $_source,\n context,\n maxChars,\n id,\n hash: $_hash,\n renderMessage,\n });\n\n // Default: return source while translation loads\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n };\n\n return { gt: gt, m };\n}\n\n// ---------------- Public API (kept stable) ---------------- //\n\n/**\n * getGT() returns a function that translates an ICU message string.\n *\n * @returns A promise of the t() function used for translating strings.\n * The returned function accepts `InlineTranslationOptions` which includes:\n * - `$format` - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n * - `$context` - Additional context for the translation.\n * - `$id` - Optional identifier for the translation string.\n * - `$maxChars` - Maximum number of characters for the translated message.\n *\n * @example\n * const t = await getGT();\n * console.log(t('Hello, world!')); // Translates 'Hello, world!'\n */\nexport async function getGT(\n _messages?: _Messages\n): Promise<(message: string, options?: InlineTranslationOptions) => string> {\n const { gt } = await createTranslator(_messages);\n return gt;\n}\n\n/**\n * Hook wrapper for getGT\n */\nexport function useGT(_messages?: _Messages) {\n return use(getGT(_messages));\n}\n\n/**\n * getMessages() returns a function that translates an encoded ICU message string.\n *\n * @returns A promise of the m() function used for translating encoded ICU message strings\n *\n * @example\n * const encodedMsg = msg('Hello, world!')\n * const m = await getMessages();\n * console.log(m(encodedMsg)); // Translates 'Hello, world!'\n */\nexport async function getMessages(\n _messages?: _Messages\n): Promise<\n <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ) => T extends string ? string : T\n> {\n const { m } = await createTranslator(_messages);\n return m;\n}\n\n/**\n * Hook wrapper for getMessages\n */\nexport function useMessages(\n _messages?: _Messages\n): <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n) => T extends string ? string : T {\n return use(getMessages(_messages));\n}\n"],"mappings":";;;;;;;;;;AAkEA,eAAe,iBAAiB,WAA4C;CAE1E,MAAM,aAAaA,iCAAAA,eAAe;CAClC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,gBAAgB,WAAW,kBAAkB;CACnD,MAAM,CAAC,uBAAuB,WAAW,oBAAoB,OAAO;CACpE,MAAM,UAAU,WAAW,YAAY;CAEvC,MAAM,eAAe,sBACjB,MAAM,WAAW,sBAAsB,OAAO,GAC9C,KAAA;;;;;;;;;CAWJ,SAAS,oBAAoB,EAC3B,SACA,WACA,SACA,UACA,IACA,UACA,UACsB;AACtB,MAAI;GAEF,MAAM,gBAAA,GAAA,4BAAA,aAA2B,YAAY,GAAG;GAChD,MAAM,mBAAmB,QAAQ,cAC/B,OAAO,KAAK,aAAa,CAAC,UAAA,GAAA,4BAAA,cAAsB,QAAQ,GAAG,SAC3D;IACE;IACA,WAAW;KACT,GAAG;KACH,GAAG;MACFC,4BAAAA,iBAAiB;KACnB;IACD,YAAY;IACb,CACF;AAKD,UAJsB,QAAQ,aAAa,kBAAkB;IAC3D;IACA;IACD,CACmB;WACb,OAAO;AACd,OAAI,QAAQ,IAAI,aAAa,aAC3B,SAAQ,KAAKC,4BAAAA,0BAA0B,SAAS,IAAI,MAAM,CAAC;QACtD;AAEL,QAAI,CAAC,SACH,OAAM,IAAI,MAAMC,4BAAAA,wBAAwB,SAAS,IAAI,MAAM,CAAC;AAG9D,YAAQ,MAAMA,4BAAAA,wBAAwB,SAAS,IAAI,MAAM,CAAC;;AAI5D,OAAI,SACF,QAAO,oBAAoB;IACzB,SAAS;IACT;IACA;IACA;IACA;IACD,CAAC;AAQJ,UAJsB,QAAQ,aAAa,SAAS;IAClD;IACA;IACD,CACmB;;;CAGxB,SAAS,aACP,SACA,U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AE;AACzC,WAAQ,KACNA,4BAAAA,6BAA6B,WAAA,GAAA,kBAAA,WAAoB,WAAW,EAAE,IAAI,CACnE;AACD,UAAO,cAAc,UAAU,CAAC,cAAc,CAAC;;AAKjD,MAAI,OAAO,wBAAwB,YAAY,aAAa;AAC1D,OAAI,wBAAwB,QAC1B,QAAO,cACL,sBAAsB,SACtB,CAAC,QAAQ,cAAc,EACvB,SACD;AAEH,UAAO,cAAc,UAAU,CAAC,cAAc,CAAC;;AAMjD,4BAA0B;GACxB,QAAQ;GACR;GACA;GACA;GACA,MAAM;GACN;GACD,CAAC;AAGF,SAAO,cAAc,UAAU,CAAC,cAAc,CAAC;;AAKjD,QAAO;EAAM;EAAI;EAAG;;;;;;;;;;;;;;;;AAmBtB,eAAsB,MACpB,WAC0E;CAC1E,MAAM,EAAE,OAAO,MAAM,iBAAiB,UAAU;AAChD,QAAO;;;;;AAMT,SAAgB,MAAM,WAAuB;AAC3C,QAAOC,kBAAAA,IAAI,MAAM,UAAU,CAAC;;;;;;;;;;;;AAa9B,eAAsB,YACpB,WAMA;CACA,MAAM,EAAE,MAAM,MAAM,iBAAiB,UAAU;AAC/C,QAAO;;;;;AAMT,SAAgB,YACd,WAIiC;AACjC,QAAOA,kBAAAA,IAAI,YAAY,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"getTranslationFunction.js","names":["getI18NConfig","getLocale","VAR_IDENTIFIER","createStringRenderWarning","createStringRenderError","createTranslationLoadingWarning","reactHasUse","createStringTranslationError","use"],"sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"sourcesContent":["// getTranslationFunction.ts (refactored)\n\nimport { getI18NConfig } from '../../config-dir/getI18NConfig';\nimport { getLocale } from '../../server';\nimport { hashSource } from 'generaltranslation/id';\nimport {\n createStringRenderError,\n createStringRenderWarning,\n createStringTranslationError,\n createTranslationLoadingWarning,\n} from '../../errors/createErrors';\nimport { decodeMsg, decodeOptions, reactHasUse } from 'gt-react/internal';\nimport type {\n InlineTranslationOptions,\n _Message,\n _Messages,\n} from 'gt-react/internal';\nimport {\n extractVars,\n condenseVars,\n VAR_IDENTIFIER,\n indexVars,\n} from 'generaltranslation/internal';\nimport type {\n FormatVariables,\n StringFormat,\n} from '@generaltranslation/format/types';\nimport { use } from '../../utils/use';\n\ntype RenderFn = (msg: string, locales: string[], fallback?: string) => string;\n\ntype GTStringOptions = InlineTranslationOptions & {\n $context?: string;\n $maxChars?: number;\n $id?: string;\n $_hash?: string;\n};\n\ntype RenderMessageParams = {\n message: string;\n variables: FormatVariables | undefined;\n locales: string[];\n fallback?: string;\n id?: string;\n maxChars?: number;\n format?: StringFormat;\n};\n\ntype InitResult = {\n id?: string;\n context?: string;\n maxChars?: number;\n requiresReview?: boolean;\n _hash?: string;\n variables: FormatVariables;\n calculateHash: () => string;\n renderMessage: RenderFn;\n};\n\ntype Translator = {\n gt: (message: string, options?: GTStringOptions) => string;\n m: <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ) => T extends string ? string : T;\n};\n\nasync function createTranslator(_messages?: _Messages): Promise<Translator> {\n // ---------- SET UP ---------- //\n const I18NConfig = getI18NConfig();\n const locale = await getLocale();\n const defaultLocale = I18NConfig.getDefaultLocale();\n const [translationRequired] = I18NConfig.requiresTranslation(locale);\n const gtClass = I18NConfig.getGTClass();\n\n const translations = translationRequired\n ? await I18NConfig.getCachedTranslations(locale)\n : undefined;\n\n // --------- HELPERS --------- //\n /**\n * @description Format message and fallback:\n * (1) format message\n * (2) format fallback\n * (3)\n * - PRODUCTION: return fallback (unformatted)\n * - DEVELOPMENT: throw error\n */\n function renderMessageHelper({\n message,\n variables,\n locales,\n fallback,\n id,\n maxChars,\n format,\n }: RenderMessageParams) {\n try {\n // (1) Try to format message\n const declaredVars = extractVars(fallback || '');\n const formattedMessage = gtClass.formatMessage(\n Object.keys(declaredVars).length ? condenseVars(message) : message,\n {\n locales,\n variables: {\n ...variables,\n ...declaredVars,\n [VAR_IDENTIFIER]: 'other',\n },\n dataFormat: format,\n }\n );\n const cutoffMessage = gtClass.formatCutoff(formattedMessage, {\n locales,\n maxChars,\n });\n return cutoffMessage;\n } catch (error) {\n if (process.env.NODE_ENV === 'production') {\n console.warn(createStringRenderWarning(message, id, error));\n } else {\n // (3) If no fallback, throw error (non-prod)\n if (!fallback) {\n throw new Error(createStringRenderError(message, id, error));\n }\n\n console.error(createStringRenderError(message, id, error));\n }\n\n // (2) If format fails, format fallback\n if (fallback) {\n return renderMessageHelper({\n message: fallback,\n locales,\n variables,\n id,\n maxChars,\n });\n }\n\n // (3) Fallback to original message (unformatted)\n const cutoffMessage = gtClass.formatCutoff(message, {\n locales,\n maxChars,\n });\n return cutoffMessage; // fallback to original message (unformatted)\n }\n }\n function initializeGT(\n message: string,\n options: GTStringOptions = {}\n ): InitResult | null {\n if (!message || typeof message !== 'string') return null;\n\n const {\n $id: id,\n $context: context,\n $maxChars: maxChars,\n $_hash: _hash,\n $format: format,\n $requiresReview: requiresReview,\n ...variables\n } = options;\n const formatVariables = variables as FormatVariables;\n\n const renderMessage: RenderFn = (msg, locales, fallback) => {\n return renderMessageHelper({\n message: msg,\n locales,\n variables: formatVariables,\n id,\n fallback,\n maxChars,\n format,\n });\n };\n\n const calculateHash = () =>\n hashSource({\n source: indexVars(message),\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n ...(requiresReview === true && { requiresReview: true }),\n ...(id && { id }),\n dataFormat: format || 'ICU',\n });\n\n return {\n id,\n context,\n maxChars,\n requiresReview,\n _hash,\n variables: formatVariables,\n calculateHash,\n renderMessage,\n };\n }\n\n function getTranslationData(\n calculateHash: () => string,\n id?: string,\n _hash?: string\n ) {\n let translationEntry;\n let hash = ''; // lazily computed if needed\n if (id) translationEntry = translations?.[id];\n if (!translationEntry && _hash && translations?.[_hash] !== undefined) {\n hash = _hash;\n translationEntry = translations?.[_hash];\n }\n if (!translationEntry) {\n hash = calculateHash();\n translationEntry = translations?.[hash];\n }\n return { translationEntry, hash };\n }\n\n function scheduleTranslateOnDemand(args: {\n source: string;\n context?: string;\n maxChars?: number;\n requiresReview?: boolean;\n id?: string;\n hash: string;\n renderMessage: RenderFn;\n }) {\n const {\n source,\n context,\n maxChars,\n requiresReview,\n id,\n hash,\n renderMessage,\n } = args;\n try {\n // Dev-mode runtime translation is intentionally NOT review-gated (it's\n // a live preview; review gates production serving) — the flag rides\n // along so the platform records review intent on anything it persists\n I18NConfig.translate({\n source: indexVars(source),\n targetLocale: locale,\n options: {\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n ...(requiresReview === true && { $requiresReview: true }),\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'ICU',\n },\n }).then((result) => {\n // eslint-disable-next-line no-console\n console.warn(\n createTranslationLoadingWarning({\n ...(id && { id }),\n source: renderMessage(source, [defaultLocale]),\n translation: renderMessage(\n result as string,\n [locale, defaultLocale],\n source\n ),\n })\n );\n });\n } catch (error) {\n console.warn(error);\n }\n }\n\n // ---------- PRELOAD TRANSLATIONS IF _MESSAGES SUPPLIED --------- //\n let preloadedTranslations: Record<string, string> | undefined;\n if (\n reactHasUse &&\n _messages &&\n I18NConfig.isDevelopmentApiEnabled() &&\n translationRequired\n ) {\n preloadedTranslations = {};\n const preload = async ({\n message,\n ...options\n }: _Message): Promise<void> => {\n if (!message) return;\n const init = initializeGT(message, options);\n if (!init) return;\n\n const { id, context, maxChars, requiresReview, _hash, calculateHash } =\n init;\n const { translationEntry, hash } = getTranslationData(\n calculateHash,\n id,\n _hash\n );\n if (translationEntry) return; // exists already\n\n try {\n preloadedTranslations![hash] = (await I18NConfig.translate({\n source: indexVars(message),\n targetLocale: locale,\n options: {\n ...(context && { $context: context }),\n ...(maxChars != null && { $maxChars: maxChars }),\n ...(requiresReview === true && { $requiresReview: true }),\n ...(id && { $id: id }),\n $_hash: hash,\n $format: 'ICU',\n },\n })) as string;\n } catch (error) {\n console.warn(error);\n }\n };\n await Promise.all(_messages.map(preload));\n }\n\n // ---------- gt() ---------- /\n\n const gt = (message: string, options: GTStringOptions = {}): string => {\n const init = initializeGT(message, options);\n if (!init) return '';\n const {\n id,\n context,\n maxChars,\n requiresReview,\n _hash,\n calculateHash,\n renderMessage,\n } = init;\n\n // Early: no translation needed\n if (!translationRequired) return renderMessage(message, [defaultLocale]);\n\n const { translationEntry, hash } = getTranslationData(\n calculateHash,\n id,\n _hash\n );\n\n if (translationEntry) {\n return renderMessage(\n translationEntry as string,\n [locale, defaultLocale],\n message\n );\n }\n\n if (!I18NConfig.isDevelopmentApiEnabled()) {\n console.warn(createStringTranslationError(message, id, 't'));\n return renderMessage(message, [defaultLocale]);\n }\n\n if (!translationEntry && preloadedTranslations?.[hash]) {\n return renderMessage(\n preloadedTranslations[hash],\n [locale, defaultLocale],\n message\n );\n }\n\n // On-demand translate\n scheduleTranslateOnDemand({\n source: message,\n context,\n maxChars,\n requiresReview,\n id,\n hash,\n renderMessage,\n });\n return renderMessage(message, [defaultLocale]);\n };\n\n // ---------- m() ---------- //\n const m = <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ): T extends string ? string : T => {\n if (!encodedMsg) return encodedMsg as T extends string ? string : T;\n\n // Try to decode first\n const decodedOptions = decodeOptions(encodedMsg);\n\n // Fallback to t() if not an encoded message\n if (\n !decodedOptions ||\n typeof decodedOptions.$_hash !== 'string' ||\n typeof decodedOptions.$_source !== 'string'\n ) {\n return gt(encodedMsg, options) as T extends string ? string : T;\n }\n\n const {\n $_hash,\n $_source,\n $context,\n $id,\n $maxChars,\n $format,\n $requiresReview,\n ...decodedVariables\n } = decodedOptions;\n const context = typeof $context === 'string' ? $context : undefined;\n const id = typeof $id === 'string' ? $id : undefined;\n const maxChars = typeof $maxChars === 'number' ? $maxChars : undefined;\n const format = typeof $format === 'string' ? $format : undefined;\n const requiresReview =\n typeof $requiresReview === 'boolean' ? $requiresReview : undefined;\n const formatVariables = decodedVariables as FormatVariables;\n\n const renderMessage: RenderFn = (msg, locales, fallback) => {\n return renderMessageHelper({\n message: msg,\n locales,\n variables: formatVariables,\n fallback,\n maxChars,\n format,\n });\n };\n\n // Early: default locale only\n if (!translationRequired)\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n\n // Translation exists?\n const translationEntry = translations?.[$_hash];\n\n if (translationEntry === null) {\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n if (translationEntry) {\n return renderMessage(\n translationEntry as string,\n [locale, defaultLocale],\n $_source\n ) as T extends string ? string : T;\n }\n\n // Dev-only paths for loading or preloaded\n if (!I18NConfig.isDevelopmentApiEnabled()) {\n console.warn(\n createStringTranslationError($_source, decodeMsg(encodedMsg), 'm')\n );\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n if (typeof preloadedTranslations?.[$_hash] !== 'undefined') {\n if (preloadedTranslations?.[$_hash]) {\n return renderMessage(\n preloadedTranslations[$_hash] as string,\n [locale, defaultLocale],\n $_source\n ) as T extends string ? string : T;\n }\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n }\n\n // On-demand translate\n scheduleTranslateOnDemand({\n source: $_source,\n context,\n maxChars,\n requiresReview,\n id,\n hash: $_hash,\n renderMessage,\n });\n\n // Default: return source while translation loads\n return renderMessage($_source, [defaultLocale]) as T extends string\n ? string\n : T;\n };\n\n return { gt: gt, m };\n}\n\n// ---------------- Public API (kept stable) ---------------- //\n\n/**\n * getGT() returns a function that translates an ICU message string.\n *\n * @returns A promise of the t() function used for translating strings.\n * The returned function accepts `InlineTranslationOptions` which includes:\n * - `$format` - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n * - `$context` - Additional context for the translation.\n * - `$id` - Optional identifier for the translation string.\n * - `$maxChars` - Maximum number of characters for the translated message.\n *\n * @example\n * const t = await getGT();\n * console.log(t('Hello, world!')); // Translates 'Hello, world!'\n */\nexport async function getGT(\n _messages?: _Messages\n): Promise<(message: string, options?: InlineTranslationOptions) => string> {\n const { gt } = await createTranslator(_messages);\n return gt;\n}\n\n/**\n * Hook wrapper for getGT\n */\nexport function useGT(_messages?: _Messages) {\n return use(getGT(_messages));\n}\n\n/**\n * getMessages() returns a function that translates an encoded ICU message string.\n *\n * @returns A promise of the m() function used for translating encoded ICU message strings\n *\n * @example\n * const encodedMsg = msg('Hello, world!')\n * const m = await getMessages();\n * console.log(m(encodedMsg)); // Translates 'Hello, world!'\n */\nexport async function getMessages(\n _messages?: _Messages\n): Promise<\n <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n ) => T extends string ? string : T\n> {\n const { m } = await createTranslator(_messages);\n return m;\n}\n\n/**\n * Hook wrapper for getMessages\n */\nexport function useMessages(\n _messages?: _Messages\n): <T extends string | null | undefined>(\n encodedMsg: T,\n options?: InlineTranslationOptions\n) => T extends string ? string : T {\n return use(getMessages(_messages));\n}\n"],"mappings":";;;;;;;;;;AAmEA,eAAe,iBAAiB,WAA4C;CAE1E,MAAM,aAAaA,iCAAAA,eAAe;CAClC,MAAM,SAAS,MAAMC,0BAAAA,WAAW;CAChC,MAAM,gBAAgB,WAAW,kBAAkB;CACnD,MAAM,CAAC,uBAAuB,WAAW,oBAAoB,OAAO;CACpE,MAAM,UAAU,WAAW,YAAY;CAEvC,MAAM,eAAe,sBACjB,MAAM,WAAW,sBAAsB,OAAO,GAC9C,KAAA;;;;;;;;;CAWJ,SAAS,oBAAoB,EAC3B,SACA,WACA,SACA,UACA,IACA,UACA,UACsB;AACtB,MAAI;GAEF,MAAM,gBAAA,GAAA,4BAAA,aAA2B,YAAY,GAAG;GAChD,MAAM,mBAAmB,QAAQ,cAC/B,OAAO,KAAK,aAAa,CAAC,UAAA,GAAA,4BAAA,cAAsB,QAAQ,GAAG,SAC3D;IACE;IACA,WAAW;KACT,GAAG;KACH,GAAG;MACFC,4BAAAA,iBAAiB;KACnB;IACD,YAAY;IACb,CACF;AAKD,UAJsB,QAAQ,aAAa,kBAAkB;IAC3D;IACA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,WAAuB;AAC3C,QAAOC,kBAAAA,IAAI,MAAM,UAAU,CAAC;;;;;;;;;;;;AAa9B,eAAsB,YACpB,WAMA;CACA,MAAM,EAAE,MAAM,MAAM,iBAAiB,UAAU;AAC/C,QAAO;;;;;AAMT,SAAgB,YACd,WAIiC;AACjC,QAAOA,kBAAAA,IAAI,YAAY,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-next",
|
|
3
|
-
"version": "6.16.
|
|
3
|
+
"version": "6.16.37",
|
|
4
4
|
"description": "A Next.js library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.server.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"./dist/server.*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@generaltranslation/compiler": "1.3.
|
|
20
|
+
"@generaltranslation/compiler": "1.3.27",
|
|
21
21
|
"@generaltranslation/format": "0.1.1",
|
|
22
|
-
"@generaltranslation/supported-locales": "2.1.4",
|
|
23
22
|
"@generaltranslation/next-internal": "0.1.2",
|
|
24
|
-
"generaltranslation": "
|
|
25
|
-
"
|
|
26
|
-
"gt-react": "10.20.
|
|
23
|
+
"@generaltranslation/supported-locales": "2.1.5",
|
|
24
|
+
"generaltranslation": "8.2.19",
|
|
25
|
+
"gt-react": "10.20.5",
|
|
26
|
+
"gt-i18n": "0.9.9"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|