gt-react 11.0.3 β†’ 11.0.4

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.
@@ -95,6 +95,26 @@ function initializeGTSRA(config) {
95
95
  (0, _generaltranslation_react_core_pure.internalInitializeGTSRA)(addRuntimeCredentials(config));
96
96
  }
97
97
  //#endregion
98
+ //#region src/functions/parseLocale.ts
99
+ /**
100
+ * Resolve the user's locale from a Web Request.
101
+ *
102
+ * The configured locale cookie takes precedence over the Accept-Language
103
+ * header. If neither contains a supported locale, the configured default
104
+ * locale is returned.
105
+ *
106
+ * This is intended for incoming server requests. A Request created in the
107
+ * browser does not automatically include document cookies or Accept-Language.
108
+ */
109
+ function parseLocale(request) {
110
+ const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
111
+ const candidates = [];
112
+ const cookieLocale = (0, gt_i18n_internal.getCookieValue)(request.headers.get("cookie"), i18nConfig.getLocaleCookieName());
113
+ if (cookieLocale) candidates.push(cookieLocale);
114
+ candidates.push(...(0, gt_i18n_internal.parseAcceptLanguage)(request.headers.get("accept-language")));
115
+ return i18nConfig.resolveSupportedLocale(candidates);
116
+ }
117
+ //#endregion
98
118
  //#region src/hooks/conditions-store.ts
99
119
  /**
100
120
  * Returns a function that sets the locale
@@ -478,6 +498,7 @@ Object.defineProperty(exports, "msg", {
478
498
  return _generaltranslation_react_core_pure.msg;
479
499
  }
480
500
  });
501
+ exports.parseLocale = parseLocale;
481
502
  Object.defineProperty(exports, "resolveCanonicalLocale", {
482
503
  enumerable: true,
483
504
  get: function() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.cjs","names":["ReadonlyConditionStore","I18nStore","InternalGTProvider","InternalLocaleSelector","InternalRegionSelector"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/hooks/conditions-store.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type I18nConfigParams,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(\n config: I18nConfigParams & ReactI18nCacheParams\n): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { useCallback } from 'react';\nimport { useConditionStore } from '@generaltranslation/react-core/hooks';\n\n/**\n * Returns a function that sets the locale\n */\nexport function useSetLocale() {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => {\n conditionStore.setLocale(locale);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the region\n */\nexport function useSetRegion() {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => {\n conditionStore.setRegion(region);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the enableI18n flag in the condition store.\n */\nexport function useSetEnableI18n() {\n const conditionStore = useConditionStore();\n return useCallback(\n (enableI18n: boolean) => {\n conditionStore.setEnableI18n(enableI18n);\n },\n [conditionStore]\n );\n}\n","import { useSetLocale } from '../hooks/conditions-store';\nimport { useInternalLocaleSelector } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import { useSetLocale, useSetRegion } from '../hooks/conditions-store';\nimport { useInternalRegionSelector } from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\nexport {\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from './hooks/conditions-store';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KA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GAAI;EACJ,CAAA;;;;;;;;;;;;;;;;;;;;;;;ACHN,SAAgB,eAAe,EAC7B,SAAS,UACT,eACA,+BACA,2BACA,mBAAmB,OACnB,GAAG,SAC6C;CAEhD,MAAM,EAAE,QAAQ,SAAS,YAAY,QAAQ,WAAW,cACtD,kBAAkB;EAChB,SAAS;EACT;EACA;EACA;EACD,CAAC;CAEJ,MAAM,gBAAgB,WAAmB;AACvC,MAAI,kBAAkB;GACpB,MAAM,eAAe,WAAW,IAAI,OAAO,EAAE;AAE7C,OAAI,gBAAgB,WAAW,aAAc,WAAU,aAAa;;AAEtE,YAAU,OAAO;;AAGnB,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;ACpCN,MAAa,kBAAmC,YAAY;AAC1D,OAAM,IAAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAuBH,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
1
+ {"version":3,"file":"index.server.cjs","names":["ReadonlyConditionStore","I18nStore","InternalGTProvider","InternalLocaleSelector","InternalRegionSelector"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/hooks/conditions-store.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type I18nConfigParams,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(\n config: I18nConfigParams & ReactI18nCacheParams\n): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { useCallback } from 'react';\nimport { useConditionStore } from '@generaltranslation/react-core/hooks';\n\n/**\n * Returns a function that sets the locale\n */\nexport function useSetLocale() {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => {\n conditionStore.setLocale(locale);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the region\n */\nexport function useSetRegion() {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => {\n conditionStore.setRegion(region);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the enableI18n flag in the condition store.\n */\nexport function useSetEnableI18n() {\n const conditionStore = useConditionStore();\n return useCallback(\n (enableI18n: boolean) => {\n conditionStore.setEnableI18n(enableI18n);\n },\n [conditionStore]\n );\n}\n","import { useSetLocale } from '../hooks/conditions-store';\nimport { useInternalLocaleSelector } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import { useSetLocale, useSetRegion } from '../hooks/conditions-store';\nimport { useInternalRegionSelector } from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\nexport {\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from './hooks/conditions-store';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAAM,aAAa,CAAC;;AAEnE,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAMhD,SAAS,wBAAwB,EAAE,QAAQ,UAAU,cAAc,aAAa,KAAK,KAAK,QAAQ,SAAS,WAAW;CACrH,MAAM,SAAS,SAAS,WAAW,GAAG,OAAO,GAAG,SAAS,KAAK,GAAG,OAAO,KAAK,WAAW,GAAG,SAAS,KAAK;CACzG,MAAM,aAAa,MAAM,GAAG,cAAc,aAAa,CAAC,WAAW,mBAAmB,cAAc,IAAI,CAAC,KAAK;CAC9G,MAAM,sBAAsB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,SAAS,KAAK,cAAc,OAAO,CAAC;CACrF,MAAM,eAAe;EACpB;EACA;EACA,sBAAsB,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AK;EACN,CAAC,CACH;;AAuBH,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
@@ -82,6 +82,20 @@ type TxProps = Record<string, ReactNode> & {
82
82
  */
83
83
  declare function initializeGTSRA(config: I18nConfigParams & ReactI18nCacheParams$1): void;
84
84
  //#endregion
85
+ //#region src/functions/parseLocale.d.ts
86
+ type RequestWithHeaders = Pick<Request, 'headers'>;
87
+ /**
88
+ * Resolve the user's locale from a Web Request.
89
+ *
90
+ * The configured locale cookie takes precedence over the Accept-Language
91
+ * header. If neither contains a supported locale, the configured default
92
+ * locale is returned.
93
+ *
94
+ * This is intended for incoming server requests. A Request created in the
95
+ * browser does not automatically include document cookies or Accept-Language.
96
+ */
97
+ declare function parseLocale(request: RequestWithHeaders): string;
98
+ //#endregion
85
99
  //#region ../format/dist/types-COaQnqVZ.d.cts
86
100
  //#region src/locales/customLocaleMapping.d.ts
87
101
  type CustomMapping = Record<string, string | Partial<LocaleProperties>>; //#endregion
@@ -267,5 +281,5 @@ type InitializeGTSPA = typeof initializeGTSPA$1;
267
281
  declare const initializeGTSPA: InitializeGTSPA;
268
282
  declare function Tx(_props: TxProps): Promise<ReactNode>;
269
283
  //#endregion
270
- export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
284
+ export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
271
285
  //# sourceMappingURL=index.server.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.d.cts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/conditions-store.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;KCdA,iCAAA,GAAoC,IAAA,CAC9C,2BAAA;EAGA,MAAA,GAAS,gBAAA;EACT,UAAA;AAAA;;;;;;;;;;;iBCMoB,iBAAA,CACpB,MAAA,EAAQ,gBAAA,GACN,sBAAA,GACA,iCAAA,GAAiC,OAAA;;;KC1BzB,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;iBCIc,eAAA,CACd,MAAA,EAAQ,gBAA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OAAA,EAAS,QAAA;EACT,aAAA;EACA,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,GACG;AAAA,GACF,mBAAA,GAAsB,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,KA8BvB,mBAAA;EACV,OAAA;EACA,WAAA,GAAc,SAAA;EACd,aAAA;IAAA,CACG,MAAA;MAEK,IAAA;MAAe,KAAA;MAAgB,MAAA;IAAA;EAAA;EAEvC,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;;;KCrDE,eAAA,UAAe,iBAAA;AAAA,cAEP,eAAA,EAAiB,eAAA;AAAA,iBAiCR,EAAA,CAAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
1
+ {"version":3,"file":"index.server.d.cts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/conditions-store.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;KCdA,iCAAA,GAAoC,IAAA,CAC9C,2BAAA;EAGA,MAAA,GAAS,gBAAA;EACT,UAAA;AAAA;;;;;;;;;;;iBCMoB,iBAAA,CACpB,MAAA,EAAQ,gBAAA,GACN,sBAAA,GACA,iCAAA,GAAiC,OAAA;;;KC1BzB,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;iBCIc,eAAA,CACd,MAAA,EAAQ,gBAAA,GAAmB,sBAAA;;;KCRxB,kBAAA,GAAqB,IAAA,CAAK,OAAA;;;;;;;;;;;iBAYf,WAAA,CAAY,OAAA,EAAS,kBAAA;;;;KCdhCA,aAAAA,GAAgBG,MAAAA,kBAAwBD,OAAAA,CAAQD,gBAAAA;AAAAA;AAAAA,KAGhDA,gBAAAA;EACHG,IAAAA;EACAC,IAAAA;EACAC,UAAAA;EACAC,YAAAA;EACAC,YAAAA;EACAC,kBAAAA;EACAC,kBAAAA;EACAC,wBAAAA;EACAC,UAAAA;EACAC,UAAAA;EACA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AA;EAAA;EAEvC,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;;;KCpDE,eAAA,UAAe,iBAAA;AAAA,cAEP,eAAA,EAAiB,eAAA;AAAA,iBAiCR,EAAA,CAAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
@@ -82,6 +82,20 @@ type TxProps = Record<string, ReactNode> & {
82
82
  */
83
83
  declare function initializeGTSRA(config: I18nConfigParams & ReactI18nCacheParams$1): void;
84
84
  //#endregion
85
+ //#region src/functions/parseLocale.d.ts
86
+ type RequestWithHeaders = Pick<Request, 'headers'>;
87
+ /**
88
+ * Resolve the user's locale from a Web Request.
89
+ *
90
+ * The configured locale cookie takes precedence over the Accept-Language
91
+ * header. If neither contains a supported locale, the configured default
92
+ * locale is returned.
93
+ *
94
+ * This is intended for incoming server requests. A Request created in the
95
+ * browser does not automatically include document cookies or Accept-Language.
96
+ */
97
+ declare function parseLocale(request: RequestWithHeaders): string;
98
+ //#endregion
85
99
  //#region ../format/dist/types-COaQnqVZ.d.cts
86
100
  //#region src/locales/customLocaleMapping.d.ts
87
101
  type CustomMapping = Record<string, string | Partial<LocaleProperties>>; //#endregion
@@ -267,5 +281,5 @@ type InitializeGTSPA = typeof initializeGTSPA$1;
267
281
  declare const initializeGTSPA: InitializeGTSPA;
268
282
  declare function Tx(_props: TxProps): Promise<ReactNode>;
269
283
  //#endregion
270
- export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
284
+ export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
271
285
  //# sourceMappingURL=index.server.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/conditions-store.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;KCdA,iCAAA,GAAoC,IAAA,CAC9C,2BAAA;EAGA,MAAA,GAAS,gBAAA;EACT,UAAA;AAAA;;;;;;;;;;;iBCMoB,iBAAA,CACpB,MAAA,EAAQ,gBAAA,GACN,sBAAA,GACA,iCAAA,GAAiC,OAAA;;;KC1BzB,OAAA,GAAU,MA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AAA;EAAA;EACjB,aAAA,GAAgB,aAAA;EAAA,CACf,GAAA;AAAA;;;;;;;;;;;;AbhCH;;;;;AACA;;;;;iBcoBgB,cAAA,CAAA;EACd,OAAA,EAAS,QAAA;EACT,aAAA;EACA,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,GACG;AAAA,GACF,mBAAA,GAAsB,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,KA8BvB,mBAAA;EACV,OAAA;EACA,WAAA,GAAc,SAAA;EACd,aAAA;IAAA,CACG,MAAA;MAEK,IAAA;MAAe,KAAA;MAAgB,MAAA;IAAA;EAAA;EAEvC,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;;;KCrDE,eAAA,UAAe,iBAAA;AAAA,cAEP,eAAA,EAAiB,eAAA;AAAA,iBAiCR,EAAA,CAAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
1
+ {"version":3,"file":"index.server.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/conditions-store.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;KCdA,iCAAA,GAAoC,IAAA,CAC9C,2BAAA;EAGA,MAAA,GAAS,gBAAA;EACT,UAAA;AAAA;;;;;;;;;;;iBCMoB,iBAAA,CACpB,MAAA,EAAQ,gBAAA,GACN,sBAAA,GACA,iCAAA,GAAiC,OAAA;;;KC1BzB,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;iBCIc,eAAA,CACd,MAAA,EAAQ,gBAAA,GAAmB,sBAAA;;;KCRxB,kBAAA,GAAqB,IAAA,CAAK,OAAA;;;;;;;;;;;iBAYf,WAAA,CAAY,OAAA,EAAS,kBAAA;;;;KCdhCA,aAAAA,GAAgBG,MAAAA,kBAAwBD,OAAAA,CAAQD,gBAAAA;AAAAA;AAAAA,KAGhDA,gBAAAA;EACHG,IAAAA;EACAC,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AA,KA8BvB,mBAAA;EACV,OAAA;EACA,WAAA,GAAc,SAAA;EACd,aAAA;IAAA,CACG,MAAA;MAEK,IAAA;MAAe,KAAA;MAAgB,MAAA;IAAA;EAAA;EAEvC,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;;;KCpDE,eAAA,UAAe,iBAAA;AAAA,cAEP,eAAA,EAAiB,eAAA;AAAA,iBAiCR,EAAA,CAAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { ReactI18nCache, ReadonlyConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, internalInitializeGTSRA, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t } from "@generaltranslation/react-core/pure";
3
- import { GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, getRuntimeEnvironment } from "gt-i18n/internal";
2
+ import { ReactI18nCache, ReadonlyConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getI18nConfig, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, internalInitializeGTSRA, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t } from "@generaltranslation/react-core/pure";
3
+ import { GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, getCookieValue, getRuntimeEnvironment, parseAcceptLanguage } from "gt-i18n/internal";
4
4
  import { useCallback, useMemo, useRef } from "react";
5
5
  import { useConditionStore, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useTranslations } from "@generaltranslation/react-core/hooks";
6
6
  import { Branch, Currency, DateTime, Derive, GtInternalTranslateJsx, GtInternalVar, I18nStore, InternalGTProvider, InternalLocaleSelector, InternalRegionSelector, Num, Plural, RelativeTime, T, Var } from "@generaltranslation/react-core/components";
@@ -94,6 +94,26 @@ function initializeGTSRA(config) {
94
94
  internalInitializeGTSRA(addRuntimeCredentials(config));
95
95
  }
96
96
  //#endregion
97
+ //#region src/functions/parseLocale.ts
98
+ /**
99
+ * Resolve the user's locale from a Web Request.
100
+ *
101
+ * The configured locale cookie takes precedence over the Accept-Language
102
+ * header. If neither contains a supported locale, the configured default
103
+ * locale is returned.
104
+ *
105
+ * This is intended for incoming server requests. A Request created in the
106
+ * browser does not automatically include document cookies or Accept-Language.
107
+ */
108
+ function parseLocale(request) {
109
+ const i18nConfig = getI18nConfig();
110
+ const candidates = [];
111
+ const cookieLocale = getCookieValue(request.headers.get("cookie"), i18nConfig.getLocaleCookieName());
112
+ if (cookieLocale) candidates.push(cookieLocale);
113
+ candidates.push(...parseAcceptLanguage(request.headers.get("accept-language")));
114
+ return i18nConfig.resolveSupportedLocale(candidates);
115
+ }
116
+ //#endregion
97
117
  //#region src/hooks/conditions-store.ts
98
118
  /**
99
119
  * Returns a function that sets the locale
@@ -291,6 +311,6 @@ async function Tx(_props) {
291
311
  throw new Error("Tx is only supported via RSC");
292
312
  }
293
313
  //#endregion
294
- export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, RegionSelector, RelativeTime, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
314
+ export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, RegionSelector, RelativeTime, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
295
315
 
296
316
  //# sourceMappingURL=index.server.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.mjs","names":[],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/hooks/conditions-store.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type I18nConfigParams,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(\n config: I18nConfigParams & ReactI18nCacheParams\n): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { useCallback } from 'react';\nimport { useConditionStore } from '@generaltranslation/react-core/hooks';\n\n/**\n * Returns a function that sets the locale\n */\nexport function useSetLocale() {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => {\n conditionStore.setLocale(locale);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the region\n */\nexport function useSetRegion() {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => {\n conditionStore.setRegion(region);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the enableI18n flag in the condition store.\n */\nexport function useSetEnableI18n() {\n const conditionStore = useConditionStore();\n return useCallback(\n (enableI18n: boolean) => {\n conditionStore.setEnableI18n(enableI18n);\n },\n [conditionStore]\n );\n}\n","import { useSetLocale } from '../hooks/conditions-store';\nimport { useInternalLocaleSelector } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import { useSetLocale, useSetRegion } from '../hooks/conditions-store';\nimport { useInternalRegionSelector } from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\nexport {\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from './hooks/conditions-store';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAAM,aAAa,CAAC;;AAEnE,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB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"}
1
+ {"version":3,"file":"index.server.mjs","names":[],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/hooks/conditions-store.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type I18nConfigParams,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(\n config: I18nConfigParams & ReactI18nCacheParams\n): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { useCallback } from 'react';\nimport { useConditionStore } from '@generaltranslation/react-core/hooks';\n\n/**\n * Returns a function that sets the locale\n */\nexport function useSetLocale() {\n const conditionStore = useConditionStore();\n return useCallback(\n (locale: string) => {\n conditionStore.setLocale(locale);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the region\n */\nexport function useSetRegion() {\n const conditionStore = useConditionStore();\n return useCallback(\n (region: string | undefined) => {\n conditionStore.setRegion(region);\n },\n [conditionStore]\n );\n}\n\n/**\n * Returns a function that sets the enableI18n flag in the condition store.\n */\nexport function useSetEnableI18n() {\n const conditionStore = useConditionStore();\n return useCallback(\n (enableI18n: boolean) => {\n conditionStore.setEnableI18n(enableI18n);\n },\n [conditionStore]\n );\n}\n","import { useSetLocale } from '../hooks/conditions-store';\nimport { useInternalLocaleSelector } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import { useSetLocale, useSetRegion } from '../hooks/conditions-store';\nimport { useInternalRegionSelector } from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\nexport {\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from './hooks/conditions-store';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAAM,aAAa,CAAC;;AAEnE,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK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C,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;ACnCN,MAAa,kBAAmC,YAAY;AAC1D,OAAM,IAAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAuBH,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
@@ -350,9 +350,9 @@ const createInvalidLocaleWarning = (locale) => createDiagnosticMessage({
350
350
  * @param cookieName - The name of the cookie
351
351
  * @returns The locale from the cookie or undefined if not found or invalid
352
352
  */
353
- function getCookieValue({ cookieName }) {
353
+ function getCookieValue$1({ cookieName }) {
354
354
  if (typeof document === "undefined") return void 0;
355
- return document.cookie.split("; ").find((row) => row.startsWith(`${cookieName}=`))?.split("=")[1];
355
+ return (0, gt_i18n_internal.getCookieValue)(document.cookie, cookieName);
356
356
  }
357
357
  /**
358
358
  * Sets a cookie value for a given cookie name
@@ -368,7 +368,7 @@ function setCookieValue({ cookieName, value }) {
368
368
  //#region src/condition-store/readBrowserLocale.ts
369
369
  function readBrowserLocale(localeCookieName) {
370
370
  const candidates = [];
371
- const cookieLocale = getCookieValue({ cookieName: localeCookieName });
371
+ const cookieLocale = getCookieValue$1({ cookieName: localeCookieName });
372
372
  if (cookieLocale) candidates.push(cookieLocale);
373
373
  const navigatorLocales = navigator?.languages || [];
374
374
  candidates.push(...navigatorLocales);
@@ -393,7 +393,7 @@ var BrowserConditionStore = class {
393
393
  this.reload();
394
394
  };
395
395
  this.getRegion = () => {
396
- const cookieRegion = getCookieValue({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() });
396
+ const cookieRegion = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() });
397
397
  if (cookieRegion) return cookieRegion;
398
398
  return this.customGetRegion?.();
399
399
  };
@@ -402,7 +402,7 @@ var BrowserConditionStore = class {
402
402
  this.reload();
403
403
  };
404
404
  this.getEnableI18n = () => {
405
- const cookieEnableI18n = getCookieValue({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
405
+ const cookieEnableI18n = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
406
406
  if (cookieEnableI18n === void 0) return this.customGetEnableI18n?.() ?? true;
407
407
  return cookieEnableI18n === "true";
408
408
  };
@@ -512,11 +512,11 @@ function determineLocale({ _getLocale: getLocale, locale }) {
512
512
  return i18nConfig.resolveSupportedLocale(candidates);
513
513
  }
514
514
  function determineRegion({ _getRegion: getRegion, region }) {
515
- return getCookieValue({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() }) || getRegion?.() || region;
515
+ return getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() }) || getRegion?.() || region;
516
516
  }
517
517
  function determineEnableI18n({ enableI18n, _getEnableI18n: getEnableI18n }) {
518
518
  if (enableI18n !== void 0) return enableI18n;
519
- const cookieEnableI18n = getCookieValue({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
519
+ const cookieEnableI18n = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
520
520
  if (cookieEnableI18n === void 0) return getEnableI18n?.() ?? true;
521
521
  return cookieEnableI18n === "true";
522
522
  }
@@ -587,6 +587,26 @@ function initializeGTSRA(config) {
587
587
  (0, _generaltranslation_react_core_pure.internalInitializeGTSRA)(addRuntimeCredentials(config));
588
588
  }
589
589
  //#endregion
590
+ //#region src/functions/parseLocale.ts
591
+ /**
592
+ * Resolve the user's locale from a Web Request.
593
+ *
594
+ * The configured locale cookie takes precedence over the Accept-Language
595
+ * header. If neither contains a supported locale, the configured default
596
+ * locale is returned.
597
+ *
598
+ * This is intended for incoming server requests. A Request created in the
599
+ * browser does not automatically include document cookies or Accept-Language.
600
+ */
601
+ function parseLocale(request) {
602
+ const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
603
+ const candidates = [];
604
+ const cookieLocale = (0, gt_i18n_internal.getCookieValue)(request.headers.get("cookie"), i18nConfig.getLocaleCookieName());
605
+ if (cookieLocale) candidates.push(cookieLocale);
606
+ candidates.push(...(0, gt_i18n_internal.parseAcceptLanguage)(request.headers.get("accept-language")));
607
+ return i18nConfig.resolveSupportedLocale(candidates);
608
+ }
609
+ //#endregion
590
610
  //#region src/hooks/conditions-store.ts
591
611
  /**
592
612
  * Returns a function that sets the locale
@@ -939,6 +959,7 @@ Object.defineProperty(exports, "msg", {
939
959
  return _generaltranslation_react_core_pure.msg;
940
960
  }
941
961
  });
962
+ exports.parseLocale = parseLocale;
942
963
  Object.defineProperty(exports, "resolveCanonicalLocale", {
943
964
  enumerable: true,
944
965
  get: function() {