gt-next 6.16.35 → 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 +23 -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/errors/createErrors.d.ts +1 -0
- package/dist/errors/createErrors.d.ts.map +1 -1
- package/dist/errors/createErrors.js +7 -0
- package/dist/errors/createErrors.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/getLocale.d.ts.map +1 -1
- package/dist/request/getLocale.js +2 -2
- package/dist/request/getLocale.js.map +1 -1
- package/dist/request/localeValidation.d.ts +14 -0
- package/dist/request/localeValidation.d.ts.map +1 -0
- package/dist/request/localeValidation.js +37 -0
- package/dist/request/localeValidation.js.map +1 -0
- package/dist/request/registerLocale.d.ts +1 -1
- package/dist/request/registerLocale.d.ts.map +1 -1
- package/dist/request/registerLocale.js +5 -3
- package/dist/request/registerLocale.js.map +1 -1
- package/dist/request/utils/legacyGetLocaleFunction.d.ts.map +1 -1
- package/dist/request/utils/legacyGetLocaleFunction.js +2 -2
- package/dist/request/utils/legacyGetLocaleFunction.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/dist/server.d.ts +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
18
|
+
## 6.16.36
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#1768](https://github.com/generaltranslation/gt/pull/1768) [`da5385f`](https://github.com/generaltranslation/gt/commit/da5385f6ce6497c542a68d4c9207ce2bd0aa2a25) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Retry main releases that were blocked by recent release workflow failures.
|
|
23
|
+
|
|
24
|
+
- [#1729](https://github.com/generaltranslation/gt/pull/1729) [`3b389dc`](https://github.com/generaltranslation/gt/commit/3b389dc08f3d86e2cea91a25e22840c188328d94) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Fallback to the default locale when request locale resolution returns an invalid or unsupported locale. This prevents request-derived locale values from causing runtime errors, and adds `isLocaleSupported()` to `gt-next/server` for apps that want to explicitly reject invalid locale route params.
|
|
25
|
+
|
|
3
26
|
## 6.16.35
|
|
4
27
|
|
|
5
28
|
### 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;IAClB,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,a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;;OAEG;IACH,mBAAmB;;;;;;;oBAnLT,YAAY;sBACV,MAAM;;;;;;;;;;IAmNlB;;;OAGG;IACH,UAAU,IAAI,EAAE;IAMhB;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;OAGG;IACH,UAAU,IAAI,MAAM,EAAE;IAItB;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAMlC,mBAAmB,IAAI,MAAM;IAI7B,mBAAmB,IAAI,MAAM;IAM7B;;OAEG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,uBAAuB,IAAI,OAAO;IAIlC;;OAEG;IACH,sBAAsB,IAAI,OAAO;IAMjC;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;IAUvD;;;;OAIG;IACG,yBAAyB,CAC7B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAIlC;;;;OAIG;IACH,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAMhE;;;;;OAKG;IACG,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAMlE,iBAAiB,CAAC,EAChB,MAAM,EACN,YAAY,EACZ,OAAO,GACR,EAAE,wBAAwB,GAAG,kBAAkB,GAAG,SAAS;IAItD,SAAS,CAAC,EACd,MAAM,EACN,YAAY,EACZ,OAAO,GACR,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAW1D"}
|
|
@@ -9,7 +9,7 @@ let gt_react_internal = require("gt-react/internal");
|
|
|
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;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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,YAdiB,KAAK,aAAa,cAczB;GACX;;;;;;CAOH,aAAiB;AACf,SAAO,KAAK,aAAa,YAAY;;;;;;CASvC,mBAA2B;AACzB,SAAO,KAAK,aAAa,kBAAkB;;;;;;CAO7C,aAAuB;AACrB,SAAO,KAAK,aAAa,YAAY;;;;;;CAOvC,eAAmC;AACjC,SAAO,KAAK,aAAa,cAAc;;CAKzC,sBAA8B;AAC5B,SAAO,KAAK;;CAGd,sBAA8B;AAC5B,SAAO,KAAK;;;;;CAQd,uBAAgC;AAC9B,SAAO,KAAK;;;;;CAMd,sBAA+B;AAC7B,SAAO,KAAK;;;;;CAMd,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"}
|
|
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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B,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,GAAG,OAAO,CAAC;IAC1D;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,yCAAyC;;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C;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;AACrD,KAAI;EACF,IAAI;AACJ,MAAI,MAAM,OACR,cAAa,MAAM;WACV,GAAA,QAAG,WAAWA,kDAAAA,yBAAyB,OAAO,CACvD,cAAaA,kDAAAA,yBAAyB;WAC7B,GAAA,QAAG,WAAW,uBAAuB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a,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,SAAgB,aACd,YACA,QAA2B,EAAE,EACI;CACjC,MAAM,qBAAsB,cAAc,EAAE;CAI5C,IAAI,eAA+C,EAAE;A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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"}
|
|
@@ -22,6 +22,7 @@ export declare const missingVariablesError: (variables: string[], message: strin
|
|
|
22
22
|
export declare const createStringRenderError: (message: string, id: string | undefined, error?: unknown) => string;
|
|
23
23
|
export declare const invalidLocalesError: (locales: string[]) => string;
|
|
24
24
|
export declare const invalidCanonicalLocalesError: (locales: string[]) => string;
|
|
25
|
+
export declare const createInvalidRequestLocaleWarning: (locale: string, defaultLocale: string) => string;
|
|
25
26
|
export declare const createInvalidIcuDictionaryEntryError: (id: string) => string;
|
|
26
27
|
export declare const createInvalidIcuDictionaryEntryWarning: (id: string) => string;
|
|
27
28
|
export declare const createBadFilepathWarning: (filename: string, dir: string[]) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
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SAAS,MAAM,EAAE,WAMhD,CAAC;AAElB,eAAO,MAAM,4BAA4B,GACvC,cAAc,MAAM,EACpB,cAAc,MAAM,WAOlB,CAAC;AAEL,eAAO,MAAM,oBAAoB,QAI/B,CAAC;AAEH,eAAO,MAAM,YAAY,QAIoE,CAAC;AAE9F,eAAO,MAAM,iBAAiB,QAG5B,CAAC;AAEH,eAAO,MAAM,+BAA+B,GAAI,8BAI7C;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,WAK8E,CAAC;AAEhF,eAAO,MAAM,gCAAgC,QAE3C,CAAC;AAEH,eAAO,MAAM,yBAAyB,QAGpC,CAAC;AAEH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,EAAE,WACiF,CAAC;AAE9I,eAAO,MAAM,mCAAmC,GAAI,SAAS,MAAM,EAAE,WACkF,CAAC;AAExJ,eAAO,MAAM,8BAA8B,kIAAgI,CAAC;AAE5K,eAAO,MAAM,iCAAiC,GAAI,MAAM,OAAO,GAAG,KAAK,WAC8B,CAAC;AAEtG,eAAO,MAAM,kCAAkC,GAAI,MAAM,OAAO,GAAG,KAAK,4NAGyD,CAAC;AAElI,eAAO,MAAM,wCAAwC,QAE8C,CAAC;AAEpG,eAAO,MAAM,+BAA+B,0FAA0F,CAAC;AAEvI,eAAO,MAAM,yBAAyB,GACpC,SAAS,MAAM,EACf,IAAI,MAAM,GAAG,SAAS,EACtB,QAAQ,OAAO,WAOb,CAAC;AAEL,eAAO,MAAM,mCAAmC,0JAAyK,CAAC"}
|
|
@@ -121,6 +121,12 @@ const invalidCanonicalLocalesError = (locales) => require_errors_diagnostics.cre
|
|
|
121
121
|
fix: "Use valid BCP 47 locale codes before starting translation",
|
|
122
122
|
details: locales
|
|
123
123
|
});
|
|
124
|
+
const createInvalidRequestLocaleWarning = (locale, defaultLocale) => require_errors_diagnostics.createGtNextDiagnostic({
|
|
125
|
+
severity: "Warning",
|
|
126
|
+
whatHappened: `Locale "${locale}" is not valid or is not supported by this app`,
|
|
127
|
+
wayOut: `The default locale "${defaultLocale}" will be used for this request`,
|
|
128
|
+
fix: "Use a valid BCP 47 locale code, add a custom mapping, or configure the locale in gt-next"
|
|
129
|
+
});
|
|
124
130
|
const createInvalidIcuDictionaryEntryError = (id) => require_errors_diagnostics.createGtNextDiagnostic({
|
|
125
131
|
severity: "Error",
|
|
126
132
|
whatHappened: `Dictionary entry "${id}" contains invalid ICU syntax`,
|
|
@@ -204,6 +210,7 @@ exports.createInvalidDictionaryEntryWarning = createInvalidDictionaryEntryWarnin
|
|
|
204
210
|
exports.createInvalidDictionaryTranslationEntryWarning = createInvalidDictionaryTranslationEntryWarning;
|
|
205
211
|
exports.createInvalidIcuDictionaryEntryError = createInvalidIcuDictionaryEntryError;
|
|
206
212
|
exports.createInvalidIcuDictionaryEntryWarning = createInvalidIcuDictionaryEntryWarning;
|
|
213
|
+
exports.createInvalidRequestLocaleWarning = createInvalidRequestLocaleWarning;
|
|
207
214
|
exports.createMismatchingHashWarning = createMismatchingHashWarning;
|
|
208
215
|
exports.createNoEntryFoundWarning = createNoEntryFoundWarning;
|
|
209
216
|
exports.createRequiredPrefixError = createRequiredPrefixError;
|