gt-next 11.0.7 → 11.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # gt-next
2
2
 
3
+ ## 11.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1894](https://github.com/generaltranslation/gt/pull/1894) [`0d50450`](https://github.com/generaltranslation/gt/commit/0d50450288bdea5ff4bb6b42f5360ac0b6c4e81d) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Correct the shipped `CompilerOptions.type` documentation to show `none` as the runtime default.
8
+
9
+ - [#1850](https://github.com/generaltranslation/gt/pull/1850) [`81d0efe`](https://github.com/generaltranslation/gt/commit/81d0efea4540e11ec0fca784ebbc61db3cf28288) Thanks [@bgub](https://github.com/bgub)! - Stop publishing unreachable `index.types` runtime bundles. The `index.types` entry only backs the exports map's `types` conditions, so only its declaration files are ever resolved; the runtime `.cjs`/`.mjs` artifacts (and sourcemaps) were dead weight in the published package (~179KB in gt-react, ~83KB in gt-next). They are now deleted after each build.
10
+
11
+ - Updated dependencies [[`5d93858`](https://github.com/generaltranslation/gt/commit/5d9385872eb041af0991fc273d5eddd7a032e584), [`81d0efe`](https://github.com/generaltranslation/gt/commit/81d0efea4540e11ec0fca784ebbc61db3cf28288), [`ffa855f`](https://github.com/generaltranslation/gt/commit/ffa855fa929d1c668e75d0c27a99dc704fcb2561), [`da32fa0`](https://github.com/generaltranslation/gt/commit/da32fa05bd718fc55ce418e68678c2d2691d5433), [`8836fbd`](https://github.com/generaltranslation/gt/commit/8836fbda088b5192b2eaa8e2109a724256458bc2), [`5721267`](https://github.com/generaltranslation/gt/commit/57212672a595c8c8578366636767bcbfe8ab6e57), [`b320e17`](https://github.com/generaltranslation/gt/commit/b320e176d581bfade57f0d122f7b95e8e3229cbf), [`8b9b440`](https://github.com/generaltranslation/gt/commit/8b9b4404b703b552b9aa327dc0ae85fce584c97c)]:
12
+ - generaltranslation@9.0.2
13
+ - gt-react@11.0.9
14
+ - @generaltranslation/react-core@11.0.9
15
+ - @generaltranslation/compiler@1.3.31
16
+ - gt-i18n@1.0.6
17
+
18
+ ## 11.0.8
19
+
20
+ ### Patch Changes
21
+
22
+ - [#1881](https://github.com/generaltranslation/gt/pull/1881) [`4ea53d6`](https://github.com/generaltranslation/gt/commit/4ea53d68e0889784d5255c9fc254b79950caace0) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Exclude custom translation IDs from SWC-generated content hashes to match the TypeScript compiler and runtime.
23
+
24
+ - Updated dependencies [[`7f0fbfe`](https://github.com/generaltranslation/gt/commit/7f0fbfef78f677372d39087252ab8d6c72d78e7e), [`ed53c71`](https://github.com/generaltranslation/gt/commit/ed53c71bc5c6a8d82feaef1b52f68d20b3794c0b), [`3ad93f8`](https://github.com/generaltranslation/gt/commit/3ad93f89da099ef345b707bf37db425662d87e2a)]:
25
+ - @generaltranslation/compiler@1.3.30
26
+ - generaltranslation@9.0.1
27
+ - gt-i18n@1.0.5
28
+ - gt-react@11.0.8
29
+ - @generaltranslation/react-core@11.0.8
30
+
3
31
  ## 11.0.7
4
32
 
5
33
  ### Patch Changes
@@ -9,7 +9,7 @@ export type HeadersAndCookies = {
9
9
  export type CompilerOptions = {
10
10
  /**
11
11
  * Which compiler plugin to use: babel, swc, or none
12
- * @default 'babel'
12
+ * @default 'none'
13
13
  */
14
14
  type: 'babel' | 'swc' | 'none';
15
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"withGTConfigProps.js","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["export type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n enableI18nCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'babel'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport type RenderMethod = 'skeleton' | 'replace' | 'default';\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n} as const;\n\nexport type BaseWithGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration. Credentials are read from environment variables.\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n disableInvalidLocaleWarning?: boolean;\n /** Regular expression source that limits i18n middleware routing by pathname. */\n pathRegex?: string;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n};\n\nexport type withGTConfigProps = BaseWithGTConfigProps & {\n /** Use GT_API_KEY instead. */\n apiKey?: never;\n /** Use NEXT_PUBLIC_GT_DEV_API_KEY or GT_DEV_API_KEY instead. */\n devApiKey?: never;\n /** Use NEXT_PUBLIC_GT_PROJECT_ID or GT_PROJECT_ID instead. */\n projectId?: never;\n};\n"],"mappings":";;AAkCA,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACZ"}
1
+ {"version":3,"file":"withGTConfigProps.js","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["export type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n enableI18nCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'none'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport type RenderMethod = 'skeleton' | 'replace' | 'default';\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n} as const;\n\nexport type BaseWithGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration. Credentials are read from environment variables.\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n disableInvalidLocaleWarning?: boolean;\n /** Regular expression source that limits i18n middleware routing by pathname. */\n pathRegex?: string;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n};\n\nexport type withGTConfigProps = BaseWithGTConfigProps & {\n /** Use GT_API_KEY instead. */\n apiKey?: never;\n /** Use NEXT_PUBLIC_GT_DEV_API_KEY or GT_DEV_API_KEY instead. */\n devApiKey?: never;\n /** Use NEXT_PUBLIC_GT_PROJECT_ID or GT_PROJECT_ID instead. */\n projectId?: never;\n};\n"],"mappings":";;AAkCA,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"withGTConfigProps.mjs","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["export type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n enableI18nCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'babel'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport type RenderMethod = 'skeleton' | 'replace' | 'default';\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n} as const;\n\nexport type BaseWithGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration. Credentials are read from environment variables.\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n disableInvalidLocaleWarning?: boolean;\n /** Regular expression source that limits i18n middleware routing by pathname. */\n pathRegex?: string;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n};\n\nexport type withGTConfigProps = BaseWithGTConfigProps & {\n /** Use GT_API_KEY instead. */\n apiKey?: never;\n /** Use NEXT_PUBLIC_GT_DEV_API_KEY or GT_DEV_API_KEY instead. */\n devApiKey?: never;\n /** Use NEXT_PUBLIC_GT_PROJECT_ID or GT_PROJECT_ID instead. */\n projectId?: never;\n};\n"],"mappings":";AAkCA,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACZ"}
1
+ {"version":3,"file":"withGTConfigProps.mjs","names":[],"sources":["../../../src/config-dir/props/withGTConfigProps.ts"],"sourcesContent":["export type HeadersAndCookies = {\n localeHeaderName?: string;\n localeCookieName?: string;\n enableI18nCookieName?: string;\n referrerLocaleCookieName?: string;\n localeRoutingEnabledCookieName?: string;\n resetLocaleCookieName?: string;\n};\n\nexport type CompilerOptions = {\n /**\n * Which compiler plugin to use: babel, swc, or none\n * @default 'none'\n */\n type: 'babel' | 'swc' | 'none';\n /**\n * Log level for the compiler plugin.\n * @default 'warn'\n */\n logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';\n /**\n * Whether to compile the translations at build time.\n * @default true\n */\n compileTimeHash?: boolean;\n /**\n * Whether to disable build checks.\n * @default false\n */\n disableBuildChecks?: boolean;\n};\n\nexport type RenderMethod = 'skeleton' | 'replace' | 'default';\n\nexport const REQUEST_FUNCTION_TO_CONFIG_KEY = {\n getLocale: 'getLocalePath',\n getRegion: 'getRegionPath',\n} as const;\n\nexport type BaseWithGTConfigProps = {\n // Additional top-level keys are forwarded as runtime translation metadata.\n [key: string]: unknown;\n // Request scoped filepath\n dictionary?: string;\n config?: string;\n loadTranslationsPath?: string;\n loadDictionaryPath?: string;\n // Cloud integration. Credentials are read from environment variables.\n runtimeUrl?: string | null;\n cacheUrl?: string | null;\n cacheExpiryTime?: number;\n // Locale info\n locales?: string[];\n defaultLocale?: string;\n ignoreBrowserLocales?: boolean;\n disableInvalidLocaleWarning?: boolean;\n /** Regular expression source that limits i18n middleware routing by pathname. */\n pathRegex?: string;\n // Rendering\n renderSettings?: {\n method: RenderMethod;\n timeout?: number;\n };\n // Batching config\n maxConcurrentRequests?: number;\n maxBatchSize?: number;\n batchInterval?: number; // ms\n // Translation assistance\n description?: string;\n // ESLint integration\n eslint?: boolean; // Enable/disable ESLint config generation (default: true)\n eslintSeverity?: 'error' | 'warn'; // Severity level for ESLint rules (default: 'warn')\n overwriteESLintConfig?: boolean; // Allow overwriting existing eslint.config.mjs (default: false)\n // Other\n experimentalCompilerOptions?: CompilerOptions;\n headersAndCookies?: HeadersAndCookies;\n _usingPlugin?: boolean;\n // Request function paths\n getLocalePath?: string;\n getRegionPath?: string;\n};\n\nexport type withGTConfigProps = BaseWithGTConfigProps & {\n /** Use GT_API_KEY instead. */\n apiKey?: never;\n /** Use NEXT_PUBLIC_GT_DEV_API_KEY or GT_DEV_API_KEY instead. */\n devApiKey?: never;\n /** Use NEXT_PUBLIC_GT_PROJECT_ID or GT_PROJECT_ID instead. */\n projectId?: never;\n};\n"],"mappings":";AAkCA,MAAa,iCAAiC;CAC5C,WAAW;CACX,WAAW;CACZ"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "gt-next",
3
- "version": "11.0.7",
3
+ "version": "11.0.9",
4
4
  "description": "A Next.js library for automatic internationalization.",
5
5
  "main": "dist/index.server.js",
6
6
  "peerDependencies": {
7
- "@generaltranslation/compiler": "^1.3.29",
7
+ "@generaltranslation/compiler": "^1.3.31",
8
8
  "next": ">=13.0.0 <15.2.1 || >15.2.2",
9
9
  "react": ">=16.8.0 <20.0.0",
10
10
  "react-dom": ">=16.8.0 <20.0.0"
@@ -29,10 +29,10 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@generaltranslation/format": "0.1.2",
32
- "@generaltranslation/react-core": "11.0.7",
33
- "generaltranslation": "9.0.0",
34
- "gt-react": "11.0.7",
35
- "gt-i18n": "1.0.4"
32
+ "@generaltranslation/react-core": "11.0.9",
33
+ "generaltranslation": "9.0.2",
34
+ "gt-react": "11.0.9",
35
+ "gt-i18n": "1.0.6"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
@@ -52,7 +52,7 @@
52
52
  "next": "15.2.3",
53
53
  "tsdown": "^0.21.10",
54
54
  "typescript": "^5.9.2",
55
- "@generaltranslation/compiler": "1.3.29"
55
+ "@generaltranslation/compiler": "1.3.31"
56
56
  },
57
57
  "exports": {
58
58
  ".": {
@@ -1,507 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./_virtual/_rolldown/runtime.js");
3
- const require_errors_createErrors = require("./errors/createErrors.js");
4
- let _generaltranslation_react_core_pure = require("@generaltranslation/react-core/pure");
5
- let gt_react = require("gt-react");
6
- //#region src/index.types.ts
7
- /**
8
- * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
9
- *
10
- * @param {React.ReactNode} children - The children components that will use the translation context.
11
- * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.
12
- * @param {string} locale - The locale to use for the translation context.
13
- *
14
- * @returns {JSX.Element} The provider component for General Translation context.
15
- */
16
- function GTProvider(_) {
17
- throw new Error(require_errors_createErrors.typesFileError);
18
- }
19
- /**
20
- * Build-time translation component that renders its children in the user's given locale.
21
- *
22
- * @example
23
- * ```jsx
24
- * // Basic usage:
25
- * <T id="welcome_message">
26
- * Hello, <Var>{name}</Var>!
27
- * </T>
28
- * ```
29
- *
30
- * @example
31
- * ```jsx
32
- * // Translating a plural
33
- * <T id="item_count">
34
- * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>
35
- * You have <Num children={n}/> items.
36
- * </Plural>
37
- * </T>
38
- * ```
39
- *
40
- * @param {React.ReactNode} children - The content to be translated or displayed.
41
- * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.
42
- * @param {any} [context] - Additional context for translation key generation.
43
- *
44
- * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.
45
- *
46
- * @throws {Error} If a plural translation is requested but the `n` option is not provided.
47
- */
48
- const T = () => {
49
- throw new Error(require_errors_createErrors.typesFileError);
50
- };
51
- /** @internal _gtt - The GT transformation for the component. */
52
- T._gtt = "translate";
53
- /**
54
- * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
55
- *
56
- * @example
57
- * ```jsx
58
- * <Currency
59
- * currency="USD"
60
- * >
61
- * 1000
62
- * </Currency>
63
- * ```
64
- *
65
- * @param {any} [children] - Optional content to render inside the currency component.
66
- * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).
67
- * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
68
- * @returns {React.JSX.Element} The formatted currency component.
69
- */
70
- const Currency = () => {
71
- throw new Error(require_errors_createErrors.typesFileError);
72
- };
73
- /** @internal _gtt - The GT transformation for the component. */
74
- Currency._gtt = "variable-currency";
75
- /**
76
- * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
77
- * It utilizes the current locale and optional format settings to display the date.
78
- *
79
- * @example
80
- * ```jsx
81
- * <DateTime>
82
- * {new Date()}
83
- * </DateTime>
84
- * ```
85
- *
86
- * @param {any} [children] - Optional content (typically a date) to render inside the component.
87
- * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
88
- * @returns {Promise<React.JSX.Element>} The formatted date or time component.
89
- */
90
- const DateTime = () => {
91
- throw new Error(require_errors_createErrors.typesFileError);
92
- };
93
- /** @internal _gtt - The GT transformation for the component. */
94
- DateTime._gtt = "variable-datetime";
95
- /**
96
- * The `<RelativeTime>` component renders a localized relative time string
97
- * (e.g., "2 hours ago", "in 3 days") using `Intl.RelativeTimeFormat`.
98
- *
99
- * @example
100
- * ```jsx
101
- * <RelativeTime date={someDate} />
102
- * ```
103
- *
104
- * @param {Date} [date] - A date to compute relative time from now.
105
- * @param {number} [value] - Explicit numeric value. Requires `unit`.
106
- * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.
107
- * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.
108
- * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.
109
- * @returns {Promise<React.JSX.Element>} The formatted relative time component.
110
- */
111
- const RelativeTime = () => {
112
- throw new Error(require_errors_createErrors.typesFileError);
113
- };
114
- /** @internal _gtt - The GT transformation for the component. */
115
- RelativeTime._gtt = "variable-relative-time";
116
- /**
117
- * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
118
- * It formats the number according to the current locale and optionally passed formatting options.
119
- *
120
- * @example
121
- * ```jsx
122
- * <Num
123
- * options={{ style: "decimal", maximumFractionDigits: 2 }}
124
- * >
125
- * 1000
126
- * </Num>
127
- * ```
128
- *
129
- * @param {any} [children] - Optional content (typically a number) to render inside the component.
130
- * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
131
- * @returns {React.JSX.Element} The formatted number component.
132
- */
133
- const Num = () => {
134
- throw new Error(require_errors_createErrors.typesFileError);
135
- };
136
- /** @internal _gtt - The GT transformation for the component. */
137
- Num._gtt = "variable-number";
138
- /**
139
- * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.
140
- * If `children` is provided, it will be used; otherwise, the `value` is rendered.
141
- *
142
- * @example
143
- * ```jsx
144
- * <Var>
145
- * John
146
- * </Var>
147
- * ```
148
- *
149
- * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
150
- * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.
151
- */
152
- const Var = () => {
153
- throw new Error(require_errors_createErrors.typesFileError);
154
- };
155
- /** @internal _gtt - The GT transformation for the component. */
156
- Var._gtt = "variable-variable";
157
- /**
158
- * Marks JSX children as derivable by the GT compiler and CLI.
159
- *
160
- * Use `<Derive>` inside translated JSX when child content is computed from
161
- * source code, but should still be discovered during extraction instead of
162
- * treated as a runtime interpolation variable. The CLI attempts to resolve the
163
- * derivable children into every possible static value and includes those values
164
- * in the source content that gets translated.
165
- *
166
- * `<Derive>` renders its children unchanged at runtime.
167
- *
168
- * Run `gt validate` after adding or changing `<Derive>` usage to verify that
169
- * each derivable expression can be resolved by the CLI before translating or
170
- * building.
171
- *
172
- * @example
173
- * ```jsx
174
- * function getSubject() {
175
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
176
- * }
177
- * ...
178
- * <T>
179
- * <Derive>
180
- * {getSubject()}
181
- * </Derive>
182
- * is going to school today.
183
- * </T>
184
- * ```
185
- *
186
- * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.
187
- * @returns {T} The same children, unchanged at runtime.
188
- */
189
- const Derive = () => {
190
- throw new Error(require_errors_createErrors.typesFileError);
191
- };
192
- /** @internal _gtt - The GT transformation for the component. */
193
- Derive._gtt = "derive";
194
- /**
195
- * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
196
- * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
197
- * If the specified `branch` is present in the `branches` object, it renders the content of that branch.
198
- * If the `branch` is not found, it renders the provided `children` as fallback content.
199
- *
200
- * @example
201
- * ```jsx
202
- * <Branch
203
- * branch="summary"
204
- * summary={<p>This is a summary</p>}
205
- * details={<p>Details here</p>}
206
- * >
207
- * <p>Fallback content</p>
208
- * </Branch>
209
- * ```
210
- * If the `branch` prop is set to `"summary"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.
211
- *
212
- * @param {any} [children] - Fallback content to render if no matching branch is found.
213
- * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
214
- * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
215
- * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.
216
- * @returns {React.JSX.Element} The rendered branch or fallback content.
217
- */
218
- const Branch = () => {
219
- throw new Error(require_errors_createErrors.typesFileError);
220
- };
221
- /** @internal _gtt - The GT transformation for the component. */
222
- Branch._gtt = "branch";
223
- /**
224
- * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
225
- * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
226
- * based on the current locale or a default locale. If no matching plural branch is found, the component renders
227
- * the fallback `children` content.
228
- *
229
- * @example
230
- * ```jsx
231
- * <Plural
232
- * n={1}
233
- * one="There is 1 item"
234
- * other="There are {n} items"
235
- * />
236
- * ```
237
- * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
238
- * `"There are {n} items"`.
239
- *
240
- * @param {any} [children] - Fallback content to render if no matching plural branch is found.
241
- * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
242
- * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
243
- * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular
244
- * and `other` for plural forms, but it may vary depending on the locale.
245
- * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
246
- * @throws {Error} If `n` is not provided or not a valid number.
247
- */
248
- const Plural = () => {
249
- throw new Error(require_errors_createErrors.typesFileError);
250
- };
251
- /** @internal _gtt - The GT transformation for the component. */
252
- Plural._gtt = "plural";
253
- /**
254
- * A dropdown component that allows users to select a locale.
255
- * @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.
256
- * @param {object} customNames - An optional object to map locales to custom names.
257
- * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.
258
- */
259
- const LocaleSelector = () => {
260
- throw new Error(require_errors_createErrors.typesFileError);
261
- };
262
- /**
263
- * A dropdown component that allows users to select a region.
264
- * @param {string[]} regions - An optional list of ISO 3166 region codes to use for the dropdown. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.
265
- * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.
266
- */
267
- const RegionSelector = () => {
268
- throw new Error(require_errors_createErrors.typesFileError);
269
- };
270
- /**
271
- * Resolve the user's locale from a Next Pages Router server-side request.
272
- *
273
- * @param context - The GetServerSideProps context for the request.
274
- * @returns The resolved locale.
275
- */
276
- function parseLocale(_) {
277
- throw new Error(require_errors_createErrors.typesFileError);
278
- }
279
- /**
280
- * Wraps a Pages Router `getServerSideProps` function and adds the resolved GT
281
- * locale and translations snapshot to returned page props.
282
- */
283
- function withGTServerSideProps(_) {
284
- throw new Error(require_errors_createErrors.typesFileError);
285
- }
286
- /**
287
- * Wraps a Pages Router `getStaticProps` function and adds the generated locale
288
- * and its translation snapshot. The default locale uses an empty snapshot.
289
- */
290
- const withGTStaticProps = () => {
291
- throw new Error(require_errors_createErrors.typesFileError);
292
- };
293
- /**
294
- * Checks whether a locale is valid and supported by the current gt-next config.
295
- *
296
- * @param locale - The locale candidate to validate.
297
- * @returns True when the locale resolves to one of the configured locales.
298
- */
299
- function isLocaleSupported(_) {
300
- throw new Error(require_errors_createErrors.typesFileError);
301
- }
302
- /**
303
- * Returns the string translation function `t`.
304
- *
305
- * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.
306
- * @param {GTTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.
307
- * @param {string} [options.$context] - Additional context for the translation.
308
- * @param {string} [options.$id] - Optional identifier for the translation string.
309
- * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.
310
- * @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.
311
- * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.
312
- *
313
- * @example
314
- * const t = useGT();
315
- * console.log(t('To be or not to be...'));
316
- *
317
- * const t = useGT();
318
- * return (<>
319
- * {
320
- * t('My name is {customName}', { customName: "Brian" } )
321
- * }
322
- * </>);
323
- *
324
- */
325
- const useGT = () => {
326
- throw new Error(require_errors_createErrors.typesFileError);
327
- };
328
- /**
329
- * Returns the dictionary access function `t`.
330
- *
331
- * @param {string} [id] - Optional prefix to prepend to the translation keys.
332
- * @returns {Function} A translation function that accepts a key string and returns the translated value.
333
- * The returned function accepts interpolation variables.
334
- *
335
- * @example
336
- * const t = useTranslations('user');
337
- * console.log(t('name')); // Translates item 'user.name'
338
- *
339
- * const t = useTranslations();
340
- * console.log(t('hello')); // Translates item 'hello'
341
- */
342
- const useTranslations = () => {
343
- throw new Error(require_errors_createErrors.typesFileError);
344
- };
345
- /**
346
- * Returns the user's current locale.
347
- *
348
- * @returns {string} BCP 47 locale tag, e.g., 'en-US'.
349
- *
350
- * @example
351
- * const locale = useLocale();
352
- * console.log(locale); // 'en-US'
353
- */
354
- const useLocale = () => {
355
- throw new Error(require_errors_createErrors.typesFileError);
356
- };
357
- const useSetLocale = () => {
358
- throw new Error(require_errors_createErrors.typesFileError);
359
- };
360
- const useLocaleSelector = () => {
361
- throw new Error(require_errors_createErrors.typesFileError);
362
- };
363
- /**
364
- * Returns the user's current region.
365
- *
366
- * @returns {string | undefined} ISO 3166 region code, e.g., 'US', or undefined if not set.
367
- *
368
- * @example
369
- * const region = useRegion();
370
- * console.log(region); // 'US'
371
- */
372
- const useRegion = () => {
373
- throw new Error(require_errors_createErrors.typesFileError);
374
- };
375
- /**
376
- * Returns the user's list of supported locales.
377
- *
378
- * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].
379
- *
380
- * @example
381
- * const locales = useLocales();
382
- * console.log(locale); // ['en-US', 'fr', 'jp]
383
- */
384
- const useLocales = () => {
385
- throw new Error(require_errors_createErrors.typesFileError);
386
- };
387
- /**
388
- * Returns the application's default locale.
389
- *
390
- * If no default locale is provided, it defaults to 'en'.
391
- *
392
- * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.
393
- *
394
- * @example
395
- * const locale = useDefaultLocale();
396
- * console.log(locale); // 'en-US'
397
- */
398
- const useDefaultLocale = () => {
399
- throw new Error(require_errors_createErrors.typesFileError);
400
- };
401
- /**
402
- * Returns the locale properties for the given locale.
403
- *
404
- * @param {string} locale - The locale to get the properties for.
405
- * @returns {LocaleProperties} The locale properties for the given locale.
406
- *
407
- * @example
408
- * const localeProperties = useLocaleProperties('en-US');
409
- * console.log(localeProperties);
410
- */
411
- const useLocaleProperties = () => {
412
- throw new Error(require_errors_createErrors.typesFileError);
413
- };
414
- /**
415
- * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.
416
- *
417
- * If no locale is provided, the direction for the current user's locale is returned.
418
- *
419
- * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.
420
- * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.
421
- *
422
- * @example
423
- * const dir = useLocaleDirection(); // e.g., 'ltr'
424
- * const arabicDir = useLocaleDirection('ar'); // 'rtl'
425
- */
426
- const useLocaleDirection = () => {
427
- throw new Error(require_errors_createErrors.typesFileError);
428
- };
429
- /**
430
- * Registers a message to be translated. Returns the message unchanged if no options are provided.
431
- * @param {string | string[]} message The message to encode.
432
- * @param {GTTranslationOptions} [options] The options to encode.
433
- * @returns The message or array of messages.
434
- *
435
- * @note - This function registers the message before the build process. The actual translation does not
436
- * occur until the m() function is invoked.
437
- *
438
- * @note - Message format
439
- * A message is broken into two parts separated by colons:
440
- * - interpolated content - the content with interpolated variables
441
- * - hash + options - a unique identifier for the source content and options for the translation
442
- *
443
- * @example - Basic usage
444
- *
445
- * const message1 = msg('Hello, World!');
446
- * console.log(message1); // "Hello, World!"
447
- *
448
- * const message2 = msg('Hello, {name}!', { name: 'Brian' });
449
- * console.log(message2); // "Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9"
450
- *
451
- * @example - Array usage
452
- *
453
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);
454
- * console.log(messages); // ["Hello, Alice!", "Hello, Bob!"]
455
- *
456
- * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`
457
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });
458
- * // "Hello, Alice!" id: "greetings.0"
459
- * // "Hello, Bob!" id: "greetings.1"
460
- */
461
- const useMessages = () => {
462
- throw new Error(require_errors_createErrors.typesFileError);
463
- };
464
- //#endregion
465
- exports.Branch = Branch;
466
- exports.Currency = Currency;
467
- exports.DateTime = DateTime;
468
- exports.Derive = Derive;
469
- exports.GTProvider = GTProvider;
470
- exports.LocaleSelector = LocaleSelector;
471
- exports.Num = Num;
472
- exports.Plural = Plural;
473
- exports.RegionSelector = RegionSelector;
474
- exports.RelativeTime = RelativeTime;
475
- exports.T = T;
476
- exports.Var = Var;
477
- exports.declareVar = _generaltranslation_react_core_pure.declareVar;
478
- exports.decodeMsg = _generaltranslation_react_core_pure.decodeMsg;
479
- exports.decodeOptions = _generaltranslation_react_core_pure.decodeOptions;
480
- exports.decodeVars = _generaltranslation_react_core_pure.decodeVars;
481
- exports.derive = _generaltranslation_react_core_pure.derive;
482
- exports.getDefaultLocale = gt_react.getDefaultLocale;
483
- exports.getLocaleProperties = gt_react.getLocaleProperties;
484
- exports.getLocales = gt_react.getLocales;
485
- exports.getTranslationsSnapshot = gt_react.getTranslationsSnapshot;
486
- exports.getVersionId = gt_react.getVersionId;
487
- exports.gtFallback = _generaltranslation_react_core_pure.gtFallback;
488
- exports.isLocaleSupported = isLocaleSupported;
489
- exports.mFallback = _generaltranslation_react_core_pure.mFallback;
490
- exports.msg = _generaltranslation_react_core_pure.msg;
491
- exports.parseLocale = parseLocale;
492
- exports.resolveCanonicalLocale = gt_react.resolveCanonicalLocale;
493
- exports.useDefaultLocale = useDefaultLocale;
494
- exports.useGT = useGT;
495
- exports.useLocale = useLocale;
496
- exports.useLocaleDirection = useLocaleDirection;
497
- exports.useLocaleProperties = useLocaleProperties;
498
- exports.useLocaleSelector = useLocaleSelector;
499
- exports.useLocales = useLocales;
500
- exports.useMessages = useMessages;
501
- exports.useRegion = useRegion;
502
- exports.useSetLocale = useSetLocale;
503
- exports.useTranslations = useTranslations;
504
- exports.withGTServerSideProps = withGTServerSideProps;
505
- exports.withGTStaticProps = withGTStaticProps;
506
-
507
- //# sourceMappingURL=index.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.js","names":["typesFileError"],"sources":["../src/index.types.ts"],"sourcesContent":["import { typesFileError } from './errors/createErrors';\nimport { T as _T } from './server-dir/buildtime/T';\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\nimport type {\n WithGTStaticProps,\n WithGTStaticPropsFunction,\n} from './pages-dir/withGTStaticProps';\nimport {\n useTranslations as _useTranslations,\n useLocale as _useLocale,\n useRegion as _useRegion,\n useLocales as _useLocales,\n useDefaultLocale as _useDefaultLocale,\n useLocaleProperties as _useLocaleProperties,\n Currency as _Currency,\n DateTime as _DateTime,\n RelativeTime as _RelativeTime,\n Num as _Num,\n Var as _Var,\n Branch as _Branch,\n Plural as _Plural,\n Derive as _Derive,\n useLocaleDirection as _useLocaleDirection,\n} from 'gt-react';\nimport {\n LocaleSelector as _LocaleSelector,\n RegionSelector as _RegionSelector,\n useSetLocale as _useSetLocale,\n useLocaleSelector as _useLocaleSelector,\n getTranslationsSnapshot,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from 'gt-react';\nimport { GTProvider as _GTProvider } from 'gt-react';\nimport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n} from '@generaltranslation/react-core/pure';\n\ntype Message = {\n message: string;\n $id?: string;\n $context?: string;\n $maxChars?: number;\n $_hash?: string;\n};\ntype Messages = Message[];\n\n/**\n * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.\n *\n * @param {React.ReactNode} children - The children components that will use the translation context.\n * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.\n * @param {string} locale - The locale to use for the translation context.\n *\n * @returns {JSX.Element} The provider component for General Translation context.\n */\nexport function GTProvider(\n _: {\n id?: string;\n } & Partial<Parameters<typeof _GTProvider>[0]>\n): React.ReactNode {\n throw new Error(typesFileError);\n}\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport const T: typeof _T = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate';\n\n/**\n * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.\n *\n * @example\n * ```jsx\n * <Currency\n * currency=\"USD\"\n * >\n * 1000\n * </Currency>\n * ```\n *\n * @param {any} [children] - Optional content to render inside the currency component.\n * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).\n * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.\n * @returns {React.JSX.Element} The formatted currency component.\n */\nexport const Currency: typeof _Currency = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nCurrency._gtt = 'variable-currency';\n\n/**\n * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.\n * It utilizes the current locale and optional format settings to display the date.\n *\n * @example\n * ```jsx\n * <DateTime>\n * {new Date()}\n * </DateTime>\n * ```\n *\n * @param {any} [children] - Optional content (typically a date) to render inside the component.\n * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.\n * @returns {Promise<React.JSX.Element>} The formatted date or time component.\n */\nexport const DateTime: typeof _DateTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDateTime._gtt = 'variable-datetime';\n\n/**\n * The `<RelativeTime>` component renders a localized relative time string\n * (e.g., \"2 hours ago\", \"in 3 days\") using `Intl.RelativeTimeFormat`.\n *\n * @example\n * ```jsx\n * <RelativeTime date={someDate} />\n * ```\n *\n * @param {Date} [date] - A date to compute relative time from now.\n * @param {number} [value] - Explicit numeric value. Requires `unit`.\n * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.\n * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.\n * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.\n * @returns {Promise<React.JSX.Element>} The formatted relative time component.\n */\nexport const RelativeTime: typeof _RelativeTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nRelativeTime._gtt = 'variable-relative-time';\n\n/**\n * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.\n * It formats the number according to the current locale and optionally passed formatting options.\n *\n * @example\n * ```jsx\n * <Num\n * options={{ style: \"decimal\", maximumFractionDigits: 2 }}\n * >\n * 1000\n * </Num>\n * ```\n *\n * @param {any} [children] - Optional content (typically a number) to render inside the component.\n * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.\n * @returns {React.JSX.Element} The formatted number component.\n */\nexport const Num: typeof _Num = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nNum._gtt = 'variable-number';\n\n/**\n * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.\n * If `children` is provided, it will be used; otherwise, the `value` is rendered.\n *\n * @example\n * ```jsx\n * <Var>\n * John\n * </Var>\n * ```\n *\n * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.\n * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.\n */\nexport const Var: typeof _Var = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nVar._gtt = 'variable-variable';\n\n/**\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` inside translated JSX when child content is computed from\n * source code, but should still be discovered during extraction instead of\n * treated as a runtime interpolation variable. The CLI attempts to resolve the\n * derivable children into every possible static value and includes those values\n * in the source content that gets translated.\n *\n * `<Derive>` renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `<Derive>` usage to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Derive>\n * {getSubject()}\n * </Derive>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Derive: typeof _Derive = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDerive._gtt = 'derive';\n\n/**\n * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.\n * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).\n * If the specified `branch` is present in the `branches` object, it renders the content of that branch.\n * If the `branch` is not found, it renders the provided `children` as fallback content.\n *\n * @example\n * ```jsx\n * <Branch\n * branch=\"summary\"\n * summary={<p>This is a summary</p>}\n * details={<p>Details here</p>}\n * >\n * <p>Fallback content</p>\n * </Branch>\n * ```\n * If the `branch` prop is set to `\"summary\"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.\n *\n * @param {any} [children] - Fallback content to render if no matching branch is found.\n * @param {string} [name=\"branch\"] - Optional name for the component, used for metadata or tracking purposes.\n * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.\n * @returns {React.JSX.Element} The rendered branch or fallback content.\n */\nexport const Branch: typeof _Branch = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nBranch._gtt = 'branch';\n\n/**\n * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).\n * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,\n * based on the current locale or a default locale. If no matching plural branch is found, the component renders\n * the fallback `children` content.\n *\n * @example\n * ```jsx\n * <Plural\n * n={1}\n * one=\"There is 1 item\"\n * other=\"There are {n} items\"\n * />\n * ```\n * In this example, if `n` is 1, it renders `\"There is 1 item\"`. If `n` is a different number, it renders\n * `\"There are {n} items\"`.\n *\n * @param {any} [children] - Fallback content to render if no matching plural branch is found.\n * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.\n * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular\n * and `other` for plural forms, but it may vary depending on the locale.\n * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.\n * @throws {Error} If `n` is not provided or not a valid number.\n */\nexport const Plural: typeof _Plural = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nPlural._gtt = 'plural';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} locales - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} customNames - An optional object to map locales to custom names.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport const LocaleSelector: typeof _LocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} regions - An optional list of ISO 3166 region codes to use for the dropdown. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n */\nexport const RegionSelector: typeof _RegionSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Resolve the user's locale from a Next Pages Router server-side request.\n *\n * @param context - The GetServerSideProps context for the request.\n * @returns The resolved locale.\n */\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(typesFileError);\n}\n\n/**\n * Wraps a Pages Router `getServerSideProps` function and adds the resolved GT\n * locale and translations snapshot to returned page props.\n */\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(typesFileError);\n}\n\n/**\n * Wraps a Pages Router `getStaticProps` function and adds the generated locale\n * and its translation snapshot. The default locale uses an empty snapshot.\n */\nexport const withGTStaticProps: WithGTStaticPropsFunction = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Checks whether a locale is valid and supported by the current gt-next config.\n *\n * @param locale - The locale candidate to validate.\n * @returns True when the locale resolves to one of the configured locales.\n */\nexport function isLocaleSupported(_: unknown): boolean {\n throw new Error(typesFileError);\n}\n\n/**\n * Returns the string translation function `t`.\n *\n * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.\n * @param {GTTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.\n * @param {string} [options.$context] - Additional context for the translation.\n * @param {string} [options.$id] - Optional identifier for the translation string.\n * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.\n * @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.\n * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n *\n * @example\n * const t = useGT();\n * console.log(t('To be or not to be...'));\n *\n * const t = useGT();\n * return (<>\n * {\n * t('My name is {customName}', { customName: \"Brian\" } )\n * }\n * </>);\n *\n */\nexport const useGT: (\n _messages?: Messages\n) => (message: string, options?: GTTranslationOptions) => string = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the dictionary access function `t`.\n *\n * @param {string} [id] - Optional prefix to prepend to the translation keys.\n * @returns {Function} A translation function that accepts a key string and returns the translated value.\n * The returned function accepts interpolation variables.\n *\n * @example\n * const t = useTranslations('user');\n * console.log(t('name')); // Translates item 'user.name'\n *\n * const t = useTranslations();\n * console.log(t('hello')); // Translates item 'hello'\n */\nexport const useTranslations: typeof _useTranslations = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current locale.\n *\n * @returns {string} BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useLocale: typeof _useLocale = () => {\n throw new Error(typesFileError);\n};\n\nexport const useSetLocale: typeof _useSetLocale = () => {\n throw new Error(typesFileError);\n};\n\nexport const useLocaleSelector: typeof _useLocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current region.\n *\n * @returns {string | undefined} ISO 3166 region code, e.g., 'US', or undefined if not set.\n *\n * @example\n * const region = useRegion();\n * console.log(region); // 'US'\n */\nexport const useRegion: typeof _useRegion = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's list of supported locales.\n *\n * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].\n *\n * @example\n * const locales = useLocales();\n * console.log(locale); // ['en-US', 'fr', 'jp]\n */\nexport const useLocales: typeof _useLocales = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the application's default locale.\n *\n * If no default locale is provided, it defaults to 'en'.\n *\n * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useDefaultLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useDefaultLocale: typeof _useDefaultLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the locale properties for the given locale.\n *\n * @param {string} locale - The locale to get the properties for.\n * @returns {LocaleProperties} The locale properties for the given locale.\n *\n * @example\n * const localeProperties = useLocaleProperties('en-US');\n * console.log(localeProperties);\n */\nexport const useLocaleProperties: typeof _useLocaleProperties = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.\n *\n * If no locale is provided, the direction for the current user's locale is returned.\n *\n * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.\n * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.\n *\n * @example\n * const dir = useLocaleDirection(); // e.g., 'ltr'\n * const arabicDir = useLocaleDirection('ar'); // 'rtl'\n */\nexport const useLocaleDirection: typeof _useLocaleDirection = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Registers a message to be translated. Returns the message unchanged if no options are provided.\n * @param {string | string[]} message The message to encode.\n * @param {GTTranslationOptions} [options] The options to encode.\n * @returns The message or array of messages.\n *\n * @note - This function registers the message before the build process. The actual translation does not\n * occur until the m() function is invoked.\n *\n * @note - Message format\n * A message is broken into two parts separated by colons:\n * - interpolated content - the content with interpolated variables\n * - hash + options - a unique identifier for the source content and options for the translation\n *\n * @example - Basic usage\n *\n * const message1 = msg('Hello, World!');\n * console.log(message1); // \"Hello, World!\"\n *\n * const message2 = msg('Hello, {name}!', { name: 'Brian' });\n * console.log(message2); // \"Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9\"\n *\n * @example - Array usage\n *\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);\n * console.log(messages); // [\"Hello, Alice!\", \"Hello, Bob!\"]\n *\n * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });\n * // \"Hello, Alice!\" id: \"greetings.0\"\n * // \"Hello, Bob!\" id: \"greetings.1\"\n */\nexport const useMessages: (\n _messages?: Messages\n) => <T extends string | null | undefined>(\n encodedMsg: T,\n options?: GTTranslationOptions\n) => T extends string ? string : T = () => {\n throw new Error(typesFileError);\n};\n\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n WithGTServerSideProps,\n WithGTStaticProps,\n};\n\nexport type { StringFormat };\n\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n mFallback,\n gtFallback,\n derive,\n declareVar,\n decodeVars,\n getTranslationsSnapshot,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0EA,SAAgB,WACd,GAGiB;AACjB,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCjC,MAAa,UAAqB;AAChC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,EAAE,OAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;AAiBhB,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;;AAkBhB,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,aAAa,OAAO;;;;;;;;;;;;;;;;;;AAmBpB,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;AAgBX,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCX,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;AAQd,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;AAQjC,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;AASjC,SAAgB,YAGd,GAAuD;AACvD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;AAOjC,SAAgB,sBAKd,GACmE;AACnE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;AAOjC,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;AASjC,SAAgB,kBAAkB,GAAqB;AACrD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;AA0BjC,MAAa,cAE4D;AACvE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;AAiBjC,MAAa,wBAAiD;AAC5D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,kBAAqC;AAChD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;AAGjC,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;AAGjC,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,kBAAqC;AAChD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;AAYjC,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;AAcjC,MAAa,yBAAmD;AAC9D,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;AAajC,MAAa,4BAAyD;AACpE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;AAejC,MAAa,2BAAuD;AAClE,OAAM,IAAI,MAAMA,4BAAAA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCjC,MAAa,oBAK8B;AACzC,OAAM,IAAI,MAAMA,4BAAAA,eAAe"}
@@ -1,465 +0,0 @@
1
- import { typesFileError } from "./errors/createErrors.mjs";
2
- import { declareVar, decodeMsg, decodeOptions, decodeVars, derive, gtFallback, mFallback, msg } from "@generaltranslation/react-core/pure";
3
- import { getDefaultLocale, getLocaleProperties, getLocales, getTranslationsSnapshot, getVersionId, resolveCanonicalLocale } from "gt-react";
4
- //#region src/index.types.ts
5
- /**
6
- * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
7
- *
8
- * @param {React.ReactNode} children - The children components that will use the translation context.
9
- * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.
10
- * @param {string} locale - The locale to use for the translation context.
11
- *
12
- * @returns {JSX.Element} The provider component for General Translation context.
13
- */
14
- function GTProvider(_) {
15
- throw new Error(typesFileError);
16
- }
17
- /**
18
- * Build-time translation component that renders its children in the user's given locale.
19
- *
20
- * @example
21
- * ```jsx
22
- * // Basic usage:
23
- * <T id="welcome_message">
24
- * Hello, <Var>{name}</Var>!
25
- * </T>
26
- * ```
27
- *
28
- * @example
29
- * ```jsx
30
- * // Translating a plural
31
- * <T id="item_count">
32
- * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>
33
- * You have <Num children={n}/> items.
34
- * </Plural>
35
- * </T>
36
- * ```
37
- *
38
- * @param {React.ReactNode} children - The content to be translated or displayed.
39
- * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.
40
- * @param {any} [context] - Additional context for translation key generation.
41
- *
42
- * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.
43
- *
44
- * @throws {Error} If a plural translation is requested but the `n` option is not provided.
45
- */
46
- const T = () => {
47
- throw new Error(typesFileError);
48
- };
49
- /** @internal _gtt - The GT transformation for the component. */
50
- T._gtt = "translate";
51
- /**
52
- * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
53
- *
54
- * @example
55
- * ```jsx
56
- * <Currency
57
- * currency="USD"
58
- * >
59
- * 1000
60
- * </Currency>
61
- * ```
62
- *
63
- * @param {any} [children] - Optional content to render inside the currency component.
64
- * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).
65
- * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
66
- * @returns {React.JSX.Element} The formatted currency component.
67
- */
68
- const Currency = () => {
69
- throw new Error(typesFileError);
70
- };
71
- /** @internal _gtt - The GT transformation for the component. */
72
- Currency._gtt = "variable-currency";
73
- /**
74
- * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
75
- * It utilizes the current locale and optional format settings to display the date.
76
- *
77
- * @example
78
- * ```jsx
79
- * <DateTime>
80
- * {new Date()}
81
- * </DateTime>
82
- * ```
83
- *
84
- * @param {any} [children] - Optional content (typically a date) to render inside the component.
85
- * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
86
- * @returns {Promise<React.JSX.Element>} The formatted date or time component.
87
- */
88
- const DateTime = () => {
89
- throw new Error(typesFileError);
90
- };
91
- /** @internal _gtt - The GT transformation for the component. */
92
- DateTime._gtt = "variable-datetime";
93
- /**
94
- * The `<RelativeTime>` component renders a localized relative time string
95
- * (e.g., "2 hours ago", "in 3 days") using `Intl.RelativeTimeFormat`.
96
- *
97
- * @example
98
- * ```jsx
99
- * <RelativeTime date={someDate} />
100
- * ```
101
- *
102
- * @param {Date} [date] - A date to compute relative time from now.
103
- * @param {number} [value] - Explicit numeric value. Requires `unit`.
104
- * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.
105
- * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.
106
- * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.
107
- * @returns {Promise<React.JSX.Element>} The formatted relative time component.
108
- */
109
- const RelativeTime = () => {
110
- throw new Error(typesFileError);
111
- };
112
- /** @internal _gtt - The GT transformation for the component. */
113
- RelativeTime._gtt = "variable-relative-time";
114
- /**
115
- * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
116
- * It formats the number according to the current locale and optionally passed formatting options.
117
- *
118
- * @example
119
- * ```jsx
120
- * <Num
121
- * options={{ style: "decimal", maximumFractionDigits: 2 }}
122
- * >
123
- * 1000
124
- * </Num>
125
- * ```
126
- *
127
- * @param {any} [children] - Optional content (typically a number) to render inside the component.
128
- * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
129
- * @returns {React.JSX.Element} The formatted number component.
130
- */
131
- const Num = () => {
132
- throw new Error(typesFileError);
133
- };
134
- /** @internal _gtt - The GT transformation for the component. */
135
- Num._gtt = "variable-number";
136
- /**
137
- * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.
138
- * If `children` is provided, it will be used; otherwise, the `value` is rendered.
139
- *
140
- * @example
141
- * ```jsx
142
- * <Var>
143
- * John
144
- * </Var>
145
- * ```
146
- *
147
- * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
148
- * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.
149
- */
150
- const Var = () => {
151
- throw new Error(typesFileError);
152
- };
153
- /** @internal _gtt - The GT transformation for the component. */
154
- Var._gtt = "variable-variable";
155
- /**
156
- * Marks JSX children as derivable by the GT compiler and CLI.
157
- *
158
- * Use `<Derive>` inside translated JSX when child content is computed from
159
- * source code, but should still be discovered during extraction instead of
160
- * treated as a runtime interpolation variable. The CLI attempts to resolve the
161
- * derivable children into every possible static value and includes those values
162
- * in the source content that gets translated.
163
- *
164
- * `<Derive>` renders its children unchanged at runtime.
165
- *
166
- * Run `gt validate` after adding or changing `<Derive>` usage to verify that
167
- * each derivable expression can be resolved by the CLI before translating or
168
- * building.
169
- *
170
- * @example
171
- * ```jsx
172
- * function getSubject() {
173
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
174
- * }
175
- * ...
176
- * <T>
177
- * <Derive>
178
- * {getSubject()}
179
- * </Derive>
180
- * is going to school today.
181
- * </T>
182
- * ```
183
- *
184
- * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.
185
- * @returns {T} The same children, unchanged at runtime.
186
- */
187
- const Derive = () => {
188
- throw new Error(typesFileError);
189
- };
190
- /** @internal _gtt - The GT transformation for the component. */
191
- Derive._gtt = "derive";
192
- /**
193
- * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
194
- * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
195
- * If the specified `branch` is present in the `branches` object, it renders the content of that branch.
196
- * If the `branch` is not found, it renders the provided `children` as fallback content.
197
- *
198
- * @example
199
- * ```jsx
200
- * <Branch
201
- * branch="summary"
202
- * summary={<p>This is a summary</p>}
203
- * details={<p>Details here</p>}
204
- * >
205
- * <p>Fallback content</p>
206
- * </Branch>
207
- * ```
208
- * If the `branch` prop is set to `"summary"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.
209
- *
210
- * @param {any} [children] - Fallback content to render if no matching branch is found.
211
- * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
212
- * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
213
- * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.
214
- * @returns {React.JSX.Element} The rendered branch or fallback content.
215
- */
216
- const Branch = () => {
217
- throw new Error(typesFileError);
218
- };
219
- /** @internal _gtt - The GT transformation for the component. */
220
- Branch._gtt = "branch";
221
- /**
222
- * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
223
- * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
224
- * based on the current locale or a default locale. If no matching plural branch is found, the component renders
225
- * the fallback `children` content.
226
- *
227
- * @example
228
- * ```jsx
229
- * <Plural
230
- * n={1}
231
- * one="There is 1 item"
232
- * other="There are {n} items"
233
- * />
234
- * ```
235
- * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
236
- * `"There are {n} items"`.
237
- *
238
- * @param {any} [children] - Fallback content to render if no matching plural branch is found.
239
- * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
240
- * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
241
- * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular
242
- * and `other` for plural forms, but it may vary depending on the locale.
243
- * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
244
- * @throws {Error} If `n` is not provided or not a valid number.
245
- */
246
- const Plural = () => {
247
- throw new Error(typesFileError);
248
- };
249
- /** @internal _gtt - The GT transformation for the component. */
250
- Plural._gtt = "plural";
251
- /**
252
- * A dropdown component that allows users to select a locale.
253
- * @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.
254
- * @param {object} customNames - An optional object to map locales to custom names.
255
- * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.
256
- */
257
- const LocaleSelector = () => {
258
- throw new Error(typesFileError);
259
- };
260
- /**
261
- * A dropdown component that allows users to select a region.
262
- * @param {string[]} regions - An optional list of ISO 3166 region codes to use for the dropdown. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.
263
- * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.
264
- */
265
- const RegionSelector = () => {
266
- throw new Error(typesFileError);
267
- };
268
- /**
269
- * Resolve the user's locale from a Next Pages Router server-side request.
270
- *
271
- * @param context - The GetServerSideProps context for the request.
272
- * @returns The resolved locale.
273
- */
274
- function parseLocale(_) {
275
- throw new Error(typesFileError);
276
- }
277
- /**
278
- * Wraps a Pages Router `getServerSideProps` function and adds the resolved GT
279
- * locale and translations snapshot to returned page props.
280
- */
281
- function withGTServerSideProps(_) {
282
- throw new Error(typesFileError);
283
- }
284
- /**
285
- * Wraps a Pages Router `getStaticProps` function and adds the generated locale
286
- * and its translation snapshot. The default locale uses an empty snapshot.
287
- */
288
- const withGTStaticProps = () => {
289
- throw new Error(typesFileError);
290
- };
291
- /**
292
- * Checks whether a locale is valid and supported by the current gt-next config.
293
- *
294
- * @param locale - The locale candidate to validate.
295
- * @returns True when the locale resolves to one of the configured locales.
296
- */
297
- function isLocaleSupported(_) {
298
- throw new Error(typesFileError);
299
- }
300
- /**
301
- * Returns the string translation function `t`.
302
- *
303
- * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.
304
- * @param {GTTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.
305
- * @param {string} [options.$context] - Additional context for the translation.
306
- * @param {string} [options.$id] - Optional identifier for the translation string.
307
- * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.
308
- * @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.
309
- * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.
310
- *
311
- * @example
312
- * const t = useGT();
313
- * console.log(t('To be or not to be...'));
314
- *
315
- * const t = useGT();
316
- * return (<>
317
- * {
318
- * t('My name is {customName}', { customName: "Brian" } )
319
- * }
320
- * </>);
321
- *
322
- */
323
- const useGT = () => {
324
- throw new Error(typesFileError);
325
- };
326
- /**
327
- * Returns the dictionary access function `t`.
328
- *
329
- * @param {string} [id] - Optional prefix to prepend to the translation keys.
330
- * @returns {Function} A translation function that accepts a key string and returns the translated value.
331
- * The returned function accepts interpolation variables.
332
- *
333
- * @example
334
- * const t = useTranslations('user');
335
- * console.log(t('name')); // Translates item 'user.name'
336
- *
337
- * const t = useTranslations();
338
- * console.log(t('hello')); // Translates item 'hello'
339
- */
340
- const useTranslations = () => {
341
- throw new Error(typesFileError);
342
- };
343
- /**
344
- * Returns the user's current locale.
345
- *
346
- * @returns {string} BCP 47 locale tag, e.g., 'en-US'.
347
- *
348
- * @example
349
- * const locale = useLocale();
350
- * console.log(locale); // 'en-US'
351
- */
352
- const useLocale = () => {
353
- throw new Error(typesFileError);
354
- };
355
- const useSetLocale = () => {
356
- throw new Error(typesFileError);
357
- };
358
- const useLocaleSelector = () => {
359
- throw new Error(typesFileError);
360
- };
361
- /**
362
- * Returns the user's current region.
363
- *
364
- * @returns {string | undefined} ISO 3166 region code, e.g., 'US', or undefined if not set.
365
- *
366
- * @example
367
- * const region = useRegion();
368
- * console.log(region); // 'US'
369
- */
370
- const useRegion = () => {
371
- throw new Error(typesFileError);
372
- };
373
- /**
374
- * Returns the user's list of supported locales.
375
- *
376
- * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].
377
- *
378
- * @example
379
- * const locales = useLocales();
380
- * console.log(locale); // ['en-US', 'fr', 'jp]
381
- */
382
- const useLocales = () => {
383
- throw new Error(typesFileError);
384
- };
385
- /**
386
- * Returns the application's default locale.
387
- *
388
- * If no default locale is provided, it defaults to 'en'.
389
- *
390
- * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.
391
- *
392
- * @example
393
- * const locale = useDefaultLocale();
394
- * console.log(locale); // 'en-US'
395
- */
396
- const useDefaultLocale = () => {
397
- throw new Error(typesFileError);
398
- };
399
- /**
400
- * Returns the locale properties for the given locale.
401
- *
402
- * @param {string} locale - The locale to get the properties for.
403
- * @returns {LocaleProperties} The locale properties for the given locale.
404
- *
405
- * @example
406
- * const localeProperties = useLocaleProperties('en-US');
407
- * console.log(localeProperties);
408
- */
409
- const useLocaleProperties = () => {
410
- throw new Error(typesFileError);
411
- };
412
- /**
413
- * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.
414
- *
415
- * If no locale is provided, the direction for the current user's locale is returned.
416
- *
417
- * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.
418
- * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.
419
- *
420
- * @example
421
- * const dir = useLocaleDirection(); // e.g., 'ltr'
422
- * const arabicDir = useLocaleDirection('ar'); // 'rtl'
423
- */
424
- const useLocaleDirection = () => {
425
- throw new Error(typesFileError);
426
- };
427
- /**
428
- * Registers a message to be translated. Returns the message unchanged if no options are provided.
429
- * @param {string | string[]} message The message to encode.
430
- * @param {GTTranslationOptions} [options] The options to encode.
431
- * @returns The message or array of messages.
432
- *
433
- * @note - This function registers the message before the build process. The actual translation does not
434
- * occur until the m() function is invoked.
435
- *
436
- * @note - Message format
437
- * A message is broken into two parts separated by colons:
438
- * - interpolated content - the content with interpolated variables
439
- * - hash + options - a unique identifier for the source content and options for the translation
440
- *
441
- * @example - Basic usage
442
- *
443
- * const message1 = msg('Hello, World!');
444
- * console.log(message1); // "Hello, World!"
445
- *
446
- * const message2 = msg('Hello, {name}!', { name: 'Brian' });
447
- * console.log(message2); // "Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9"
448
- *
449
- * @example - Array usage
450
- *
451
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);
452
- * console.log(messages); // ["Hello, Alice!", "Hello, Bob!"]
453
- *
454
- * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`
455
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });
456
- * // "Hello, Alice!" id: "greetings.0"
457
- * // "Hello, Bob!" id: "greetings.1"
458
- */
459
- const useMessages = () => {
460
- throw new Error(typesFileError);
461
- };
462
- //#endregion
463
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RegionSelector, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getLocaleProperties, getLocales, getTranslationsSnapshot, getVersionId, gtFallback, isLocaleSupported, mFallback, msg, parseLocale, resolveCanonicalLocale, useDefaultLocale, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useSetLocale, useTranslations, withGTServerSideProps, withGTStaticProps };
464
-
465
- //# sourceMappingURL=index.types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.mjs","names":[],"sources":["../src/index.types.ts"],"sourcesContent":["import { typesFileError } from './errors/createErrors';\nimport { T as _T } from './server-dir/buildtime/T';\nimport type {\n GetServerSideProps,\n GetServerSidePropsContext,\n PreviewData,\n} from 'next';\nimport type { ParsedUrlQuery } from 'querystring';\nimport type { WithGTServerSideProps } from './pages-dir/withGTServerSideProps';\nimport type {\n WithGTStaticProps,\n WithGTStaticPropsFunction,\n} from './pages-dir/withGTStaticProps';\nimport {\n useTranslations as _useTranslations,\n useLocale as _useLocale,\n useRegion as _useRegion,\n useLocales as _useLocales,\n useDefaultLocale as _useDefaultLocale,\n useLocaleProperties as _useLocaleProperties,\n Currency as _Currency,\n DateTime as _DateTime,\n RelativeTime as _RelativeTime,\n Num as _Num,\n Var as _Var,\n Branch as _Branch,\n Plural as _Plural,\n Derive as _Derive,\n useLocaleDirection as _useLocaleDirection,\n} from 'gt-react';\nimport {\n LocaleSelector as _LocaleSelector,\n RegionSelector as _RegionSelector,\n useSetLocale as _useSetLocale,\n useLocaleSelector as _useLocaleSelector,\n getTranslationsSnapshot,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from 'gt-react';\nimport { GTProvider as _GTProvider } from 'gt-react';\nimport type { GTTranslationOptions, RuntimeTranslationOptions } from 'gt-react';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n} from '@generaltranslation/react-core/pure';\n\ntype Message = {\n message: string;\n $id?: string;\n $context?: string;\n $maxChars?: number;\n $_hash?: string;\n};\ntype Messages = Message[];\n\n/**\n * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.\n *\n * @param {React.ReactNode} children - The children components that will use the translation context.\n * @param {string} id - ID of a nested dictionary, so that only a subset of a large dictionary needs to be sent to the client.\n * @param {string} locale - The locale to use for the translation context.\n *\n * @returns {JSX.Element} The provider component for General Translation context.\n */\nexport function GTProvider(\n _: {\n id?: string;\n } & Partial<Parameters<typeof _GTProvider>[0]>\n): React.ReactNode {\n throw new Error(typesFileError);\n}\n\n/**\n * Build-time translation component that renders its children in the user's given locale.\n *\n * @example\n * ```jsx\n * // Basic usage:\n * <T id=\"welcome_message\">\n * Hello, <Var>{name}</Var>!\n * </T>\n * ```\n *\n * @example\n * ```jsx\n * // Translating a plural\n * <T id=\"item_count\">\n * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>\n * You have <Num children={n}/> items.\n * </Plural>\n * </T>\n * ```\n *\n * @param {React.ReactNode} children - The content to be translated or displayed.\n * @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.\n * @param {any} [context] - Additional context for translation key generation.\n *\n * @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.\n *\n * @throws {Error} If a plural translation is requested but the `n` option is not provided.\n */\nexport const T: typeof _T = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nT._gtt = 'translate';\n\n/**\n * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.\n *\n * @example\n * ```jsx\n * <Currency\n * currency=\"USD\"\n * >\n * 1000\n * </Currency>\n * ```\n *\n * @param {any} [children] - Optional content to render inside the currency component.\n * @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).\n * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.\n * @returns {React.JSX.Element} The formatted currency component.\n */\nexport const Currency: typeof _Currency = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nCurrency._gtt = 'variable-currency';\n\n/**\n * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.\n * It utilizes the current locale and optional format settings to display the date.\n *\n * @example\n * ```jsx\n * <DateTime>\n * {new Date()}\n * </DateTime>\n * ```\n *\n * @param {any} [children] - Optional content (typically a date) to render inside the component.\n * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.\n * @returns {Promise<React.JSX.Element>} The formatted date or time component.\n */\nexport const DateTime: typeof _DateTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDateTime._gtt = 'variable-datetime';\n\n/**\n * The `<RelativeTime>` component renders a localized relative time string\n * (e.g., \"2 hours ago\", \"in 3 days\") using `Intl.RelativeTimeFormat`.\n *\n * @example\n * ```jsx\n * <RelativeTime date={someDate} />\n * ```\n *\n * @param {Date} [date] - A date to compute relative time from now.\n * @param {number} [value] - Explicit numeric value. Requires `unit`.\n * @param {Intl.RelativeTimeFormatUnit} [unit] - The unit of time.\n * @param {Date} [baseDate] - Base date for computing relative time. Defaults to `new Date()` at render time. Required for hydration safety.\n * @param {Intl.RelativeTimeFormatOptions} [options={}] - Formatting options.\n * @returns {Promise<React.JSX.Element>} The formatted relative time component.\n */\nexport const RelativeTime: typeof _RelativeTime = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nRelativeTime._gtt = 'variable-relative-time';\n\n/**\n * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.\n * It formats the number according to the current locale and optionally passed formatting options.\n *\n * @example\n * ```jsx\n * <Num\n * options={{ style: \"decimal\", maximumFractionDigits: 2 }}\n * >\n * 1000\n * </Num>\n * ```\n *\n * @param {any} [children] - Optional content (typically a number) to render inside the component.\n * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.\n * @returns {React.JSX.Element} The formatted number component.\n */\nexport const Num: typeof _Num = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nNum._gtt = 'variable-number';\n\n/**\n * The `<Var>` component renders a variable value, which can either be passed as `children` or a `value`.\n * If `children` is provided, it will be used; otherwise, the `value` is rendered.\n *\n * @example\n * ```jsx\n * <Var>\n * John\n * </Var>\n * ```\n *\n * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.\n * @returns {React.JSX.Element} The rendered variable component with either `children` or `value`.\n */\nexport const Var: typeof _Var = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nVar._gtt = 'variable-variable';\n\n/**\n * Marks JSX children as derivable by the GT compiler and CLI.\n *\n * Use `<Derive>` inside translated JSX when child content is computed from\n * source code, but should still be discovered during extraction instead of\n * treated as a runtime interpolation variable. The CLI attempts to resolve the\n * derivable children into every possible static value and includes those values\n * in the source content that gets translated.\n *\n * `<Derive>` renders its children unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `<Derive>` usage to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * <T>\n * <Derive>\n * {getSubject()}\n * </Derive>\n * is going to school today.\n * </T>\n * ```\n *\n * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.\n * @returns {T} The same children, unchanged at runtime.\n */\nexport const Derive: typeof _Derive = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nDerive._gtt = 'derive';\n\n/**\n * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.\n * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).\n * If the specified `branch` is present in the `branches` object, it renders the content of that branch.\n * If the `branch` is not found, it renders the provided `children` as fallback content.\n *\n * @example\n * ```jsx\n * <Branch\n * branch=\"summary\"\n * summary={<p>This is a summary</p>}\n * details={<p>Details here</p>}\n * >\n * <p>Fallback content</p>\n * </Branch>\n * ```\n * If the `branch` prop is set to `\"summary\"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.\n *\n * @param {any} [children] - Fallback content to render if no matching branch is found.\n * @param {string} [name=\"branch\"] - Optional name for the component, used for metadata or tracking purposes.\n * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible branches as keys and their corresponding content as values.\n * @returns {React.JSX.Element} The rendered branch or fallback content.\n */\nexport const Branch: typeof _Branch = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nBranch._gtt = 'branch';\n\n/**\n * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).\n * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,\n * based on the current locale or a default locale. If no matching plural branch is found, the component renders\n * the fallback `children` content.\n *\n * @example\n * ```jsx\n * <Plural\n * n={1}\n * one=\"There is 1 item\"\n * other=\"There are {n} items\"\n * />\n * ```\n * In this example, if `n` is 1, it renders `\"There is 1 item\"`. If `n` is a different number, it renders\n * `\"There are {n} items\"`.\n *\n * @param {any} [children] - Fallback content to render if no matching plural branch is found.\n * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.\n * @param {string} [locale] - Optional parameter, the locale to use for pluralization format.\n * @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular\n * and `other` for plural forms, but it may vary depending on the locale.\n * @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.\n * @throws {Error} If `n` is not provided or not a valid number.\n */\nexport const Plural: typeof _Plural = () => {\n throw new Error(typesFileError);\n};\n/** @internal _gtt - The GT transformation for the component. */\nPlural._gtt = 'plural';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} locales - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} customNames - An optional object to map locales to custom names.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport const LocaleSelector: typeof _LocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} regions - An optional list of ISO 3166 region codes to use for the dropdown. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n */\nexport const RegionSelector: typeof _RegionSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Resolve the user's locale from a Next Pages Router server-side request.\n *\n * @param context - The GetServerSideProps context for the request.\n * @returns The resolved locale.\n */\nexport function parseLocale<\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(_: GetServerSidePropsContext<Params, Preview>): string {\n throw new Error(typesFileError);\n}\n\n/**\n * Wraps a Pages Router `getServerSideProps` function and adds the resolved GT\n * locale and translations snapshot to returned page props.\n */\nexport function withGTServerSideProps<\n Props extends Record<string, unknown> = Record<string, unknown>,\n Params extends ParsedUrlQuery = ParsedUrlQuery,\n Preview extends PreviewData = PreviewData,\n>(\n _?: GetServerSideProps<Props, Params, Preview>\n): GetServerSideProps<WithGTServerSideProps<Props>, Params, Preview> {\n throw new Error(typesFileError);\n}\n\n/**\n * Wraps a Pages Router `getStaticProps` function and adds the generated locale\n * and its translation snapshot. The default locale uses an empty snapshot.\n */\nexport const withGTStaticProps: WithGTStaticPropsFunction = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Checks whether a locale is valid and supported by the current gt-next config.\n *\n * @param locale - The locale candidate to validate.\n * @returns True when the locale resolves to one of the configured locales.\n */\nexport function isLocaleSupported(_: unknown): boolean {\n throw new Error(typesFileError);\n}\n\n/**\n * Returns the string translation function `t`.\n *\n * @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.\n * @param {GTTranslationOptions} [options] - Translation options including variables and special `$`-prefixed options.\n * @param {string} [options.$context] - Additional context for the translation.\n * @param {string} [options.$id] - Optional identifier for the translation string.\n * @param {number} [options.$maxChars] - Maximum number of characters for the translated message.\n * @param {boolean} [options.$requiresReview] - Whether the translated message requires approval before use. Must be a boolean literal.\n * @param {StringFormat} [options.$format] - The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'.\n *\n * @example\n * const t = useGT();\n * console.log(t('To be or not to be...'));\n *\n * const t = useGT();\n * return (<>\n * {\n * t('My name is {customName}', { customName: \"Brian\" } )\n * }\n * </>);\n *\n */\nexport const useGT: (\n _messages?: Messages\n) => (message: string, options?: GTTranslationOptions) => string = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the dictionary access function `t`.\n *\n * @param {string} [id] - Optional prefix to prepend to the translation keys.\n * @returns {Function} A translation function that accepts a key string and returns the translated value.\n * The returned function accepts interpolation variables.\n *\n * @example\n * const t = useTranslations('user');\n * console.log(t('name')); // Translates item 'user.name'\n *\n * const t = useTranslations();\n * console.log(t('hello')); // Translates item 'hello'\n */\nexport const useTranslations: typeof _useTranslations = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current locale.\n *\n * @returns {string} BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useLocale: typeof _useLocale = () => {\n throw new Error(typesFileError);\n};\n\nexport const useSetLocale: typeof _useSetLocale = () => {\n throw new Error(typesFileError);\n};\n\nexport const useLocaleSelector: typeof _useLocaleSelector = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's current region.\n *\n * @returns {string | undefined} ISO 3166 region code, e.g., 'US', or undefined if not set.\n *\n * @example\n * const region = useRegion();\n * console.log(region); // 'US'\n */\nexport const useRegion: typeof _useRegion = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the user's list of supported locales.\n *\n * @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].\n *\n * @example\n * const locales = useLocales();\n * console.log(locale); // ['en-US', 'fr', 'jp]\n */\nexport const useLocales: typeof _useLocales = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the application's default locale.\n *\n * If no default locale is provided, it defaults to 'en'.\n *\n * @returns {string} A BCP 47 locale tag, e.g., 'en-US'.\n *\n * @example\n * const locale = useDefaultLocale();\n * console.log(locale); // 'en-US'\n */\nexport const useDefaultLocale: typeof _useDefaultLocale = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Returns the locale properties for the given locale.\n *\n * @param {string} locale - The locale to get the properties for.\n * @returns {LocaleProperties} The locale properties for the given locale.\n *\n * @example\n * const localeProperties = useLocaleProperties('en-US');\n * console.log(localeProperties);\n */\nexport const useLocaleProperties: typeof _useLocaleProperties = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Retrieves the text direction ('ltr' or 'rtl') for the current or specified locale from the `<GTProvider>` context.\n *\n * If no locale is provided, the direction for the current user's locale is returned.\n *\n * @param {string} [locale] - Optional locale code (e.g., 'ar', 'en-US'). If omitted, uses the current locale from context.\n * @returns {'ltr' | 'rtl'} The text direction for the locale: 'rtl' for right-to-left languages, otherwise 'ltr'.\n *\n * @example\n * const dir = useLocaleDirection(); // e.g., 'ltr'\n * const arabicDir = useLocaleDirection('ar'); // 'rtl'\n */\nexport const useLocaleDirection: typeof _useLocaleDirection = () => {\n throw new Error(typesFileError);\n};\n\n/**\n * Registers a message to be translated. Returns the message unchanged if no options are provided.\n * @param {string | string[]} message The message to encode.\n * @param {GTTranslationOptions} [options] The options to encode.\n * @returns The message or array of messages.\n *\n * @note - This function registers the message before the build process. The actual translation does not\n * occur until the m() function is invoked.\n *\n * @note - Message format\n * A message is broken into two parts separated by colons:\n * - interpolated content - the content with interpolated variables\n * - hash + options - a unique identifier for the source content and options for the translation\n *\n * @example - Basic usage\n *\n * const message1 = msg('Hello, World!');\n * console.log(message1); // \"Hello, World!\"\n *\n * const message2 = msg('Hello, {name}!', { name: 'Brian' });\n * console.log(message2); // \"Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9\"\n *\n * @example - Array usage\n *\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);\n * console.log(messages); // [\"Hello, Alice!\", \"Hello, Bob!\"]\n *\n * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`\n * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });\n * // \"Hello, Alice!\" id: \"greetings.0\"\n * // \"Hello, Bob!\" id: \"greetings.1\"\n */\nexport const useMessages: (\n _messages?: Messages\n) => <T extends string | null | undefined>(\n encodedMsg: T,\n options?: GTTranslationOptions\n) => T extends string ? string : T = () => {\n throw new Error(typesFileError);\n};\n\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n WithGTServerSideProps,\n WithGTStaticProps,\n};\n\nexport type { StringFormat };\n\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n mFallback,\n gtFallback,\n derive,\n declareVar,\n decodeVars,\n getTranslationsSnapshot,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n};\n"],"mappings":";;;;;;;;;;;;;AA0EA,SAAgB,WACd,GAGiB;AACjB,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCjC,MAAa,UAAqB;AAChC,OAAM,IAAI,MAAM,eAAe;;;AAGjC,EAAE,OAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAM,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;AAiBhB,MAAa,iBAAmC;AAC9C,OAAM,IAAI,MAAM,eAAe;;;AAGjC,SAAS,OAAO;;;;;;;;;;;;;;;;;AAkBhB,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAM,eAAe;;;AAGjC,aAAa,OAAO;;;;;;;;;;;;;;;;;;AAmBpB,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAM,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;AAgBX,MAAa,YAAyB;AACpC,OAAM,IAAI,MAAM,eAAe;;;AAGjC,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCX,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAM,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAM,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Bd,MAAa,eAA+B;AAC1C,OAAM,IAAI,MAAM,eAAe;;;AAGjC,OAAO,OAAO;;;;;;;AAQd,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAM,eAAe;;;;;;;AAQjC,MAAa,uBAA+C;AAC1D,OAAM,IAAI,MAAM,eAAe;;;;;;;;AASjC,SAAgB,YAGd,GAAuD;AACvD,OAAM,IAAI,MAAM,eAAe;;;;;;AAOjC,SAAgB,sBAKd,GACmE;AACnE,OAAM,IAAI,MAAM,eAAe;;;;;;AAOjC,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAM,eAAe;;;;;;;;AASjC,SAAgB,kBAAkB,GAAqB;AACrD,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;AA0BjC,MAAa,cAE4D;AACvE,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;;;;AAiBjC,MAAa,wBAAiD;AAC5D,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;AAYjC,MAAa,kBAAqC;AAChD,OAAM,IAAI,MAAM,eAAe;;AAGjC,MAAa,qBAA2C;AACtD,OAAM,IAAI,MAAM,eAAe;;AAGjC,MAAa,0BAAqD;AAChE,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;AAYjC,MAAa,kBAAqC;AAChD,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;AAYjC,MAAa,mBAAuC;AAClD,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;AAcjC,MAAa,yBAAmD;AAC9D,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;AAajC,MAAa,4BAAyD;AACpE,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;;AAejC,MAAa,2BAAuD;AAClE,OAAM,IAAI,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCjC,MAAa,oBAK8B;AACzC,OAAM,IAAI,MAAM,eAAe"}