@generaltranslation/react-core 1.8.20 → 2.0.0-odysseus.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components-rsc.cjs.min.cjs +2 -0
  3. package/dist/components-rsc.cjs.min.cjs.map +1 -0
  4. package/dist/components-rsc.d.ts +531 -0
  5. package/dist/components-rsc.d.ts.map +1 -0
  6. package/dist/components-rsc.esm.min.mjs +2 -0
  7. package/dist/components-rsc.esm.min.mjs.map +1 -0
  8. package/dist/components.cjs.min.cjs +2 -0
  9. package/dist/components.cjs.min.cjs.map +1 -0
  10. package/dist/components.d.ts +495 -0
  11. package/dist/components.d.ts.map +1 -0
  12. package/dist/components.esm.min.mjs +2 -0
  13. package/dist/components.esm.min.mjs.map +1 -0
  14. package/dist/hooks.cjs.min.cjs +2 -0
  15. package/dist/hooks.cjs.min.cjs.map +1 -0
  16. package/dist/hooks.d.ts +130 -0
  17. package/dist/hooks.d.ts.map +1 -0
  18. package/dist/hooks.esm.min.mjs +2 -0
  19. package/dist/hooks.esm.min.mjs.map +1 -0
  20. package/dist/pure.cjs.min.cjs +2 -0
  21. package/dist/pure.cjs.min.cjs.map +1 -0
  22. package/dist/pure.d.ts +677 -0
  23. package/dist/pure.d.ts.map +1 -0
  24. package/dist/pure.esm.min.mjs +2 -0
  25. package/dist/pure.esm.min.mjs.map +1 -0
  26. package/package.json +40 -35
  27. package/dist/errors.cjs.min.cjs +0 -2
  28. package/dist/errors.cjs.min.cjs.map +0 -1
  29. package/dist/errors.d.ts +0 -5
  30. package/dist/errors.d.ts.map +0 -1
  31. package/dist/errors.esm.min.mjs +0 -2
  32. package/dist/errors.esm.min.mjs.map +0 -1
  33. package/dist/index.cjs.min.cjs +0 -2
  34. package/dist/index.cjs.min.cjs.map +0 -1
  35. package/dist/index.d.ts +0 -1385
  36. package/dist/index.d.ts.map +0 -1
  37. package/dist/index.esm.min.mjs +0 -2
  38. package/dist/index.esm.min.mjs.map +0 -1
  39. package/dist/internal.cjs.min.cjs +0 -2
  40. package/dist/internal.cjs.min.cjs.map +0 -1
  41. package/dist/internal.d.ts +0 -765
  42. package/dist/internal.d.ts.map +0 -1
  43. package/dist/internal.esm.min.mjs +0 -2
  44. package/dist/internal.esm.min.mjs.map +0 -1
  45. package/dist/types.d.ts +0 -437
  46. package/dist/types.d.ts.map +0 -1
@@ -1,765 +0,0 @@
1
- import React, { ReactNode } from "react";
2
-
3
- //#region ../format/dist/types-COaQnqVZ.d.cts
4
- //#endregion
5
- //#region src/types-dir/jsx/variables.d.ts
6
- type VariableType = 'v' | 'n' | 'd' | 'c' | 'rt';
7
- /**
8
- * Variables are used to store the variable name and type.
9
- */
10
- type Variable = {
11
- k: string;
12
- i?: number;
13
- v?: VariableType;
14
- }; //#endregion
15
- //#region src/types-dir/jsx/content.d.ts
16
- /**
17
- * Map of data-_gt properties to their corresponding React props
18
- */
19
- declare const HTML_CONTENT_PROPS: {
20
- readonly pl: "placeholder";
21
- readonly ti: "title";
22
- readonly alt: "alt";
23
- readonly arl: "aria-label";
24
- readonly arb: "aria-labelledby";
25
- readonly ard: "aria-describedby";
26
- };
27
- type HtmlContentPropKeysRecord = Partial<Record<keyof typeof HTML_CONTENT_PROPS, string>>;
28
- /**
29
- * GTProp is an internal property used to contain data for translating and rendering elements.
30
- * note, transformations are only read on the server side if they are 'plural' or 'branch'
31
- */
32
- type GTProp = {
33
- b?: Record<string, JsxChildren>;
34
- t?: 'p' | 'b';
35
- } & HtmlContentPropKeysRecord;
36
- type JsxElement = {
37
- t?: string;
38
- i?: number;
39
- d?: GTProp;
40
- c?: JsxChildren;
41
- };
42
- type JsxChild = string | JsxElement | Variable;
43
- /**
44
- * The format of the string content
45
- */
46
- type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';
47
- /**
48
- * The format of the content.
49
- */
50
- /**
51
- * A content type representing JSX elements.
52
- */
53
- type JsxChildren = JsxChild | JsxChild[];
54
- /**
55
- * A content type representing ICU messages.
56
- */
57
- //#endregion
58
- //#region ../core/dist/types-CdRgQtET.d.cts
59
- type TransformationPrefix = 'translate' | 'variable' | 'plural' | 'branch' | 'fragment' | 'derive';
60
- type VariableTransformationSuffix = 'variable' | 'number' | 'datetime' | 'currency' | 'relative-time';
61
- type InjectionType = 'automatic' | 'manual'; //#endregion
62
- //#region src/types.d.ts
63
- /**
64
- * @deprecated Use {@link Content} instead.
65
- */
66
- //#endregion
67
- //#region ../i18n/dist/options-D0Lnxv2X.d.cts
68
- //#region src/translation-functions/types/options.d.ts
69
- type BaseTranslationOptions = Record<string, unknown>;
70
- /**
71
- * Options for string resolution
72
- * Used by the gt() function
73
- */
74
- type InlineTranslationOptions = BaseTranslationOptions & {
75
- $context?: string;
76
- $id?: string; /** The data format for the message (e.g., 'ICU', 'STRING'). Defaults to 'ICU'. */
77
- $format?: StringFormat; /** The locale to use for formatting the message. */
78
- $locale?: string;
79
- /**
80
- * @deprecated use {@link $locale} instead
81
- */
82
- $_locales?: string | string[];
83
- $_hash?: string;
84
- $maxChars?: number; /** @deprecated use {@link EncodedTranslationOptions} instead */
85
- $_source?: string;
86
- };
87
- /**
88
- * Options for string resolution
89
- * Used by the m() function
90
- */
91
- //#endregion
92
- //#region ../i18n/dist/functions-DI1QpQoC.d.cts
93
- /**
94
- * Synchronous resolution function type
95
- * @param {string} message - The message to translate.
96
- * @param {InlineTranslationOptions} options - The options for the translation.
97
- * @returns {string} The translated message.
98
- *
99
- * @important This is base type for user API
100
- *
101
- * TODO: next major version, this should be <T extends string | null | undefined>(message: T, options?: InlineTranslationOptions) => T extends string ? string : T;
102
- */
103
- type SyncResolutionFunctionWithFallback = (message: string, options?: InlineTranslationOptions) => string;
104
- /**
105
- * Type for the gt() function
106
- * @param {string} message - The message to translate
107
- * @param {InlineTranslationOptions} options - The options for the translation
108
- * @returns {string} The translated message
109
- * TODO: next major version, remove the "...type" suffix, it's redundant
110
- */
111
- type GTFunctionType = SyncResolutionFunctionWithFallback;
112
- /**
113
- * Type for the m() function
114
- * @param {string | null | undefined} encodedMsg - The encoded message to decode and interpolate.
115
- * @param {InlineTranslationOptions} options - The options to interpolate.
116
- * @returns {string | null | undefined} The decoded and interpolated message.
117
- * TODO: next major version, this should be <T extends string | null | undefined>(message: T, options?: InlineTranslationOptions) => T extends string ? string : T;
118
- * TODO: next major version, remove the "...type" suffix, it's redundant
119
- */
120
- type MFunctionType = <T extends string | null | undefined>(encodedMsg: T, options?: Record<string, any>) => T extends string ? string : T;
121
- /**
122
- * Type for the t() function
123
- * @param {string} id - The id of the translation to translate.
124
- * @param {DictionaryTranslationOptions} options - The options for the translation.
125
- * @returns {string} The translated message.
126
- * TODO: next major version, remove the "...type" suffix, it's redundant
127
- */
128
- //#endregion
129
- //#region ../i18n/dist/message-C62MTLwE.d.cts
130
- //#region src/translation-functions/types/message.d.ts
131
- /**
132
- * Valid types for messages that can be registered.
133
- * msg('Hello, World!')
134
- * msg(['Hello, World!', 'Welcome, {user}!'])
135
- */
136
- type RegisterableMessages = string | string[] | readonly string[]; //#endregion
137
- //#endregion
138
- //#region src/types-dir/types.d.ts
139
- /**
140
- * TaggedElement is a React element with a GTProp property.
141
- */
142
- type GTTag = {
143
- id: number;
144
- injectionType: InjectionType;
145
- transformation?: TransformationPrefix;
146
- branches?: Record<string, TaggedChildren>;
147
- variableType?: VariableTransformationSuffix;
148
- };
149
- type TaggedElementProps = Record<string, unknown> & {
150
- 'data-_gt': GTTag;
151
- children?: TaggedChildren;
152
- branch?: string | number | boolean;
153
- n?: number;
154
- key?: React.Key;
155
- };
156
- type TaggedElement = React.ReactElement<TaggedElementProps>;
157
- type TaggedChild = Exclude<React.ReactNode, React.ReactElement> | TaggedElement;
158
- type TaggedChildren = TaggedChild[] | TaggedChild;
159
- /**
160
- * For dictionaries, we have Entry and MetaEntry
161
- */
162
- type Entry = string;
163
- type MetaEntry = {
164
- $context?: string;
165
- $maxChars?: number;
166
- $_hash?: string;
167
- [key: string]: unknown;
168
- };
169
- type DictionaryEntry = Entry | [Entry] | [Entry, MetaEntry];
170
- type Dictionary = {
171
- [key: string]: Dictionary | DictionaryEntry;
172
- } | (Dictionary | DictionaryEntry)[];
173
- type FlattenedDictionary = {
174
- [key: string]: DictionaryEntry;
175
- };
176
- /**
177
- * Translated content types
178
- * TODO: move these types to JsxElement etc from generaltranslation/types
179
- * remember to omit the t property (tag name) from the translated element
180
- */
181
- type TranslatedElement = {
182
- i?: number;
183
- d?: GTProp;
184
- c?: TranslatedChildren;
185
- };
186
- type TranslatedChild = TranslatedElement | string | Variable;
187
- type TranslatedChildren = TranslatedChild | TranslatedChild[];
188
- type Translations = {
189
- [hash: string]: TranslatedChildren | null;
190
- };
191
- type RenderMethod = 'skeleton' | 'replace' | 'default';
192
- type RelativeTimeFormatOptions = Intl.RelativeTimeFormatOptions & {
193
- unit?: Intl.RelativeTimeFormatUnit;
194
- baseDate?: Date;
195
- };
196
- type VariableProps = {
197
- /** Whether the variable was automatically injected by the compiler */variableType: VariableType;
198
- variableValue: unknown;
199
- variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | RelativeTimeFormatOptions;
200
- variableName: string;
201
- injectionType: InjectionType;
202
- };
203
- type RenderVariable = ({
204
- variableType,
205
- variableValue,
206
- variableOptions,
207
- locales,
208
- injectionType
209
- }: Omit<VariableProps, 'variableName'> & {
210
- locales: string[];
211
- }) => React.ReactNode;
212
- //#endregion
213
- //#region src/internal/flattenDictionary.d.ts
214
- /**
215
- * Flattens a nested dictionary by concatenating nested keys.
216
- * Throws an error if two keys result in the same flattened key.
217
- * @param {Record<string, any>} dictionary - The dictionary to flatten.
218
- * @param {string} [prefix=''] - The prefix for nested keys.
219
- * @returns {Record<string, React.ReactNode>} The flattened dictionary object.
220
- * @throws {Error} If two keys result in the same flattened key.
221
- */
222
- declare function flattenDictionary(dictionary: Dictionary, prefix?: string): FlattenedDictionary;
223
- //#endregion
224
- //#region src/internal/addGTIdentifier.d.ts
225
- declare function addGTIdentifier(children: ReactNode, startingIndex?: number): TaggedChildren;
226
- //#endregion
227
- //#region src/internal/removeInjectedT.d.ts
228
- /**
229
- * Remove injected _T components at runtime. This is only for i18n-context T components to use.
230
- * This is necessary because when dealing with deriving fragmented content. The compiler will always
231
- * inject a `_T` component.
232
- *
233
- * Only remove if within a `<Derive>` or `<Static>` component as this scopes this behavior
234
- * to only where it can actually appear.
235
- */
236
- declare function removeInjectedT(children: ReactNode): ReactNode;
237
- //#endregion
238
- //#region src/internal/writeChildrenAsObjects.d.ts
239
- /**
240
- * Transforms children elements into objects, processing each child recursively if needed.
241
- * TaggedChildren are transformed into JsxChildren
242
- * @param {Children} children - The children to process.
243
- * @returns {object} The processed children as objects.
244
- */
245
- declare function writeChildrenAsObjects(children: TaggedChildren): JsxChildren;
246
- //#endregion
247
- //#region src/branches/plurals/getPluralBranch.d.ts
248
- /**
249
- * Main function to get the appropriate branch based on the provided number and branches.
250
- *
251
- * @param {number} n - The number to determine the branch for.
252
- * @param {any} branches - The object containing possible branches.
253
- * @returns {any} The determined branch.
254
- */
255
- declare function getPluralBranch(n: number, locales: string[], branches: Record<string, unknown>): unknown;
256
- //#endregion
257
- //#region src/dictionaries/getDictionaryEntry.d.ts
258
- declare function isValidDictionaryEntry(value: unknown): value is DictionaryEntry;
259
- declare function getDictionaryEntry<T extends Dictionary>(dictionary: T, id: string): Dictionary | DictionaryEntry | undefined;
260
- //#endregion
261
- //#region src/dictionaries/getEntryAndMetadata.d.ts
262
- declare function getEntryAndMetadata(value: DictionaryEntry): {
263
- entry: string;
264
- metadata?: MetaEntry;
265
- };
266
- //#endregion
267
- //#region src/variables/_getVariableProps.d.ts
268
- type VariableElementProps = {
269
- 'data-_gt': GTTag & {
270
- transformation: 'variable';
271
- };
272
- [key: string]: unknown;
273
- };
274
- declare function getVariableProps(props: VariableElementProps): VariableProps;
275
- //#endregion
276
- //#region src/rendering/isVariableObject.d.ts
277
- declare function isVariableObject(obj: unknown): obj is Variable;
278
- //#endregion
279
- //#region src/variables/getVariableName.d.ts
280
- declare const defaultVariableNames: {
281
- readonly variable: "value";
282
- readonly number: "n";
283
- readonly datetime: "date";
284
- readonly currency: "cost";
285
- readonly 'relative-time': "time";
286
- };
287
- declare function getVariableName(props: Record<string, unknown> | undefined, variableType: keyof typeof defaultVariableNames): string;
288
- //#endregion
289
- //#region src/rendering/renderDefaultChildren.d.ts
290
- declare function renderDefaultChildren({
291
- children,
292
- defaultLocale,
293
- renderVariable
294
- }: {
295
- children: TaggedChildren;
296
- defaultLocale: string;
297
- renderVariable: RenderVariable;
298
- }): React.ReactNode;
299
- //#endregion
300
- //#region src/rendering/renderTranslatedChildren.d.ts
301
- declare function renderTranslatedChildren({
302
- source,
303
- target,
304
- locales,
305
- renderVariable
306
- }: {
307
- source: TaggedChildren;
308
- target: TranslatedChildren;
309
- locales: string[];
310
- renderVariable: RenderVariable;
311
- }): ReactNode;
312
- //#endregion
313
- //#region src/rendering/getDefaultRenderSettings.d.ts
314
- declare const getDefaultRenderSettings: (environment?: "development" | "production" | "test") => {
315
- method: RenderMethod;
316
- timeout: number;
317
- };
318
- //#endregion
319
- //#region src/rendering/renderSkeleton.d.ts
320
- /**
321
- * renderSkeleton is a function that handles the rendering behavior for the skeleton loading method.
322
- * It replaces all content with empty strings
323
- * @returns an empty string
324
- */
325
- declare function renderSkeleton(): React.ReactNode;
326
- //#endregion
327
- //#region src/utils/cookies.d.ts
328
- /**
329
- * Cookie name for tracking the referrer locale
330
- */
331
- declare const defaultLocaleCookieName = "generaltranslation.locale";
332
- /**
333
- * Cookie name for tracking the user's selected region
334
- */
335
- declare const defaultRegionCookieName = "generaltranslation.region";
336
- /**
337
- * Cookie name for persisting the enableI18n feature flag
338
- * "true" or "false"
339
- */
340
- declare const defaultEnableI18nCookieName = "generaltranslation.enable-i18n";
341
- //#endregion
342
- //#region src/dictionaries/mergeDictionaries.d.ts
343
- declare function mergeDictionaries(defaultLocaleDictionary: Dictionary, localeDictionary: Dictionary): Dictionary;
344
- //#endregion
345
- //#region src/promises/reactHasUse.d.ts
346
- declare const reactHasUse: boolean;
347
- //#endregion
348
- //#region src/dictionaries/getSubtree.d.ts
349
- declare function getSubtree<T extends Dictionary>({
350
- dictionary,
351
- id
352
- }: {
353
- dictionary: T;
354
- id: string;
355
- }): Dictionary | DictionaryEntry | undefined;
356
- /**
357
- * @description A function that gets a subtree from a dictionary
358
- * @param dictionary - new dictionary to get the subtree from
359
- * @param id - id of the subtree to get
360
- * @param sourceDictionary - source dictionary to model off of
361
- * @returns
362
- */
363
- declare function getSubtreeWithCreation<T extends Dictionary>({
364
- dictionary,
365
- id,
366
- sourceDictionary
367
- }: {
368
- dictionary: T;
369
- id: string;
370
- sourceDictionary: T;
371
- }): Dictionary | DictionaryEntry | undefined;
372
- //#endregion
373
- //#region src/dictionaries/injectEntry.d.ts
374
- /**
375
- * @description Injects an entry into a translations object
376
- * @param translations - The translations object to inject the entry into
377
- * @param entry - The entry to inject
378
- * @param hash - The hash of the entry
379
- * @param sourceDictionary - The source dictionary to model the new dictionary after
380
- */
381
- declare function injectEntry(dictionaryEntry: DictionaryEntry, dictionary: Dictionary | DictionaryEntry, id: string, sourceDictionary: Dictionary | DictionaryEntry): DictionaryEntry | undefined;
382
- //#endregion
383
- //#region src/dictionaries/isDictionaryEntry.d.ts
384
- /**
385
- * Type guard function that checks if a value is a DictionaryEntry
386
- * @param value - The value to check
387
- * @returns true if the value is a DictionaryEntry, false otherwise
388
- */
389
- declare function isDictionaryEntry(value: Dictionary | DictionaryEntry | undefined): value is DictionaryEntry;
390
- //#endregion
391
- //#region src/dictionaries/stripMetadataFromEntries.d.ts
392
- /**
393
- * @description Iterate over tree and remove metadata leaving just the entry
394
- */
395
- declare function stripMetadataFromEntries(dictionary: Dictionary): Dictionary;
396
- //#endregion
397
- //#region src/dictionaries/injectHashes.d.ts
398
- /**
399
- * @description Given a dictionary, adds hashes to all dictionary entries
400
- * @param dictionary - The dictionary to add hashes to
401
- * @param id - The starting point of dictionary (if subtree)
402
- */
403
- declare function injectHashes(dictionary: Dictionary, id?: string): {
404
- dictionary: Dictionary;
405
- updateDictionary: boolean;
406
- };
407
- //#endregion
408
- //#region src/dictionaries/injectTranslations.d.ts
409
- /**
410
- * @description Injects translations into a dictionary
411
- * @param dictionary - The dictionary to inject translations into
412
- * @param translationsDictionary - The translations to inject into the dictionary
413
- * @param translations - The translations to inject into the dictionary
414
- * @param id - The id of the dictionary to inject translations into
415
- */
416
- declare function injectTranslations(dictionary: Dictionary, translationsDictionary: Dictionary, translations: Translations, missingTranslations: {
417
- source: string;
418
- metadata: {
419
- $id: string;
420
- $context?: string;
421
- $maxChars?: number;
422
- $_hash: string;
423
- };
424
- }[], prefixToRemove?: string): {
425
- dictionary: Dictionary;
426
- updateDictionary: boolean;
427
- };
428
- //#endregion
429
- //#region src/dictionaries/injectFallbacks.d.ts
430
- /**
431
- * @description Injects fallbacks into a dictionary
432
- * @param dictionary - The dictionary to inject translations into
433
- * @param translationsDictionary - The translations to inject into the dictionary
434
- * @param translations - The translations to inject into the dictionary
435
- * @param id - The id of the dictionary to inject translations into
436
- */
437
- declare function injectFallbacks(dictionary: Dictionary, translationsDictionary: Dictionary, missingTranslations: {
438
- source: string;
439
- metadata: {
440
- $id: string;
441
- $context?: string;
442
- $maxChars?: number;
443
- $_hash: string;
444
- };
445
- }[], prefixToRemove?: string): Dictionary;
446
- //#endregion
447
- //#region src/dictionaries/injectAndMerge.d.ts
448
- /**
449
- * @description Given a subtree and a dictionary, injects the subtree into the dictionary at the given id
450
- * @param dictionary - The dictionary to inject the subtree into
451
- * @param subtree - The subtree to inject into the dictionary
452
- * @param id - The id of the subtree to inject into the dictionary
453
- */
454
- declare function injectAndMerge(dictionary: Dictionary, subtree: Dictionary, id: string): Dictionary;
455
- //#endregion
456
- //#region src/dictionaries/collectUntranslatedEntries.d.ts
457
- /**
458
- * @description Collects all untranslated entries from a dictionary
459
- * @param dictionary - The dictionary to collect untranslated entries from
460
- * @param translationsDictionary - The translated dictionary to compare against
461
- * @param id - The id of the dictionary to collect untranslated entries from
462
- * @returns An array of untranslated entries
463
- */
464
- declare function collectUntranslatedEntries(dictionary: Dictionary, translationsDictionary: Dictionary, id?: string): {
465
- source: string;
466
- metadata: {
467
- $id: string;
468
- $context?: string;
469
- $maxChars?: number;
470
- $_hash: string;
471
- };
472
- }[];
473
- //#endregion
474
- //#region ../i18n/dist/index-BLWcN0wI.d.cts
475
- //#region src/translation-functions/fallbacks/gtFallback.d.ts
476
- /**
477
- * A fallback function for the gt() function that decodes and interpolates.
478
- * @param {string | null | undefined} message - The ICU formatted message to interpolate.
479
- * @param {InlineTranslationOptions} options - The options to interpolate.
480
- * @returns - The decoded and interpolated message.
481
- *
482
- * @note This function is useful as a placeholder when for incrementally migrating to the m() function.
483
- * @example
484
- * // A backwards compatible translation function
485
- * function getMessage(gt: GTFunctionType = gtFallback) {
486
- * return gt('Hello, world!');
487
- * }
488
- *
489
- * // Here i18n has been implemented
490
- * function WithTranslation() {
491
- * const gt = useGT();
492
- * return <>{getMessage(gt)}</>;
493
- * }
494
- *
495
- *
496
- * // i18n has not yet been implemented yet
497
- * function WithoutTranslations() {
498
- * return <>{getMessage()}</>;
499
- * }
500
- */
501
- declare const gtFallback: GTFunctionType; //#endregion
502
- //#region src/translation-functions/fallbacks/mFallback.d.ts
503
- /**
504
- * A fallback function for the m() function that decodes and interpolates.
505
- * @param {string | null | undefined} encodedMsg - The encoded message to decode and interpolate.
506
- * @param {InlineTranslationOptions} options - The options to interpolate.
507
- * @returns - The decoded and interpolated message.
508
- *
509
- * @note This function is useful as a placeholder when for incrementally migrating to the m() function.
510
- * @example
511
- * // A backwards compatible translation function
512
- * function getMessage(m: MFunctionType = mFallback) {
513
- * return m(msg('Hello, world!'));
514
- * }
515
- *
516
- * // Here i18n has been implemented
517
- * function WithTranslation() {
518
- * const m = useMessages();
519
- * return <>{getMessage(m)}</>;
520
- * }
521
- *
522
- *
523
- * // i18n has not yet been implemented yet
524
- * function WithoutTranslations() {
525
- * return <>{getMessage()}</>;
526
- * }
527
- */
528
- declare const mFallback: MFunctionType; //#endregion
529
- //#endregion
530
- //#region ../core/dist/internal.d.cts
531
- //#endregion
532
- //#region src/derive/decodeVars.d.ts
533
- /**
534
- * Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()
535
- * @example
536
- * const encodedIcu = "Hi" + declareVar("Brian") + ", my name is {name}"
537
- * // 'Hi {_gt_, select, other {Brian}}, my name is {name}'
538
- * decodeVars(encodedIcu)
539
- * // 'Hi Brian, my name is {name}'
540
- */
541
- declare function decodeVars(icuString: string): string; //#endregion
542
- //#region src/derive/declareVar.d.ts
543
- /**
544
- * Mark as a non-translatable string. Use within a derive() call to mark content as not derivable (e.g., not possible to statically analyze).
545
- *
546
- * @example
547
- * function nonDerivableFunction() {
548
- * return Math.random();
549
- * }
550
- *
551
- * function derivableFunction() {
552
- * if (condition) {
553
- * return declareVar(nonDerivableFunction())
554
- * }
555
- * return 'John Doe';
556
- * }
557
- *
558
- * const gt = useGT();
559
- * gt(`My name is ${derive(derivableFunction())}`);
560
- *
561
- * @param {string | number | boolean | null | undefined} variable - The variable to sanitize.
562
- * @param {Object} [options] - The options for the sanitization.
563
- * @param {string} [options.$name] - The name of the variable.
564
- * @returns {string} The sanitized value.
565
- */
566
- declare function declareVar(variable: string | number | boolean | null | undefined, options?: {
567
- $name?: string;
568
- }): string; //#endregion
569
- //#region src/derive/derive.d.ts
570
- /**
571
- * Marks content as derivable by the GT compiler and CLI.
572
- *
573
- * Use `derive()` when a translation string or context needs content that is
574
- * computed from source code, but should still be discovered during extraction
575
- * instead of treated as a runtime interpolation variable. The CLI attempts to
576
- * resolve the derivable expression into every possible static value and
577
- * includes those values in the source content that gets translated.
578
- *
579
- * `derive()` returns its argument unchanged at runtime.
580
- *
581
- * Run `gt validate` after adding or changing `derive()` calls to verify that
582
- * each derivable expression can be resolved by the CLI before translating or
583
- * building.
584
- *
585
- * @example
586
- * ```jsx
587
- * function getSubject() {
588
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
589
- * }
590
- * ...
591
- * gt(`My name is ${derive(getSubject())}`);
592
- * ```
593
- *
594
- * @param {T extends string | boolean | number | null | undefined} content - Content to derive for translation extraction.
595
- * @returns {T} The same content, unchanged at runtime.
596
- */
597
- declare function derive<T extends string | boolean | number | null | undefined>(content: T): T;
598
- /**
599
- * @deprecated Use derive() instead.
600
- *
601
- * Marks content as derivable by the GT compiler and CLI.
602
- *
603
- * Use `derive()` instead of `declareStatic()` for new code. This alias is kept
604
- * for backwards compatibility and returns its argument unchanged at runtime.
605
- *
606
- * Run `gt validate` after adding or changing derived content to verify that
607
- * each derivable expression can be resolved by the CLI before translating or
608
- * building.
609
- *
610
- * @example
611
- * ```jsx
612
- * function getSubject() {
613
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
614
- * }
615
- * ...
616
- * gt(`My name is ${declareStatic(getSubject())}`);
617
- * ```
618
- *
619
- * @param {T extends string | boolean | number | null | undefined} content - Content to derive for translation extraction.
620
- * @returns {T} The same content, unchanged at runtime.
621
- */
622
- declare const declareStatic: typeof derive; //#endregion
623
- //#region src/derive/indexVars.d.ts
624
- /**
625
- * Given an ICU string adds identifiers to each _gt_ placeholder
626
- * indexVars('Hello {_gt_} {_gt_} World') => 'Hello {_gt_1_} {_gt_2_} World'
627
- */
628
- //#endregion
629
- //#region ../i18n/dist/index.d.cts
630
- //#endregion
631
- //#region src/translation-functions/msg/msg.d.ts
632
- /**
633
- * Registers a message to be translated. Returns the message unchanged if no options are provided.
634
- * @param {string | string[]} message The message to encode.
635
- * @param {InlineTranslationOptions} [options] The options to encode.
636
- * @returns The message or array of messages.
637
- *
638
- * @note - This function registers the message before the build process. The actual translation does not
639
- * occur until the m() function is invoked.
640
- *
641
- * @note - Message format
642
- * A message is broken into two parts separated by colons:
643
- * - interpolated content - the content with interpolated variables
644
- * - hash + options - a unique identifier for the source content and options for the translation
645
- *
646
- * @example - Basic usage
647
- *
648
- * const message1 = msg('Hello, World!');
649
- * console.log(message1); // "Hello, World!"
650
- *
651
- * const message2 = msg('Hello, {name}!', { name: 'Brian' });
652
- * console.log(message2); // "Hello, Brian:eyIkX2hhc2giOiAiMHgxMjMiLCAiJF9zb3VyY2UiOiAiSGVsbG8sIHtuYW1lfSEiLCAibmFtZSI6ICJCcmlhbiJ9"
653
- *
654
- * @example - Array usage
655
- *
656
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!']);
657
- * console.log(messages); // ["Hello, Alice!", "Hello, Bob!"]
658
- *
659
- * @example - When specifying an id for an array, each message will have a unique id of `${id}.${index}`
660
- * const messages = msg(['Hello, Alice!', 'Hello, Bob!'], { $id: 'greetings' });
661
- * // "Hello, Alice!" id: "greetings.0"
662
- * // "Hello, Bob!" id: "greetings.1"
663
- *
664
- * @important Internal note: until other packages are updated to use i18n-context practices, msg cannot use any functions that use i18nManager at all!
665
- */
666
- declare function msg<T extends RegisterableMessages = string>(message: T): T;
667
- declare function msg<T extends RegisterableMessages = string>(message: T, options?: InlineTranslationOptions): T extends string ? string : string[]; //#endregion
668
- //#region src/translation-functions/msg/decodeMsg.d.ts
669
- /**
670
- * Extracts the original interpolated message string.
671
- * If the message cannot be decoded (i.e., it does not contain a colon separator),
672
- * the input is returned as-is.
673
- * @param encodedMsg The message to decode.
674
- * @returns The decoded message, or the input if it cannot be decoded.
675
- */
676
- declare function decodeMsg(encodedMsg: string): string;
677
- declare function decodeMsg<T extends null | undefined>(encodedMsg: T): T;
678
- declare function decodeMsg<T extends string | null | undefined>(encodedMsg: T): T extends string ? string : T; //#endregion
679
- //#region src/translation-functions/msg/decodeOptions.d.ts
680
- /**
681
- * Decodes the options from an encoded message.
682
- * @param encodedMsg The message to decode.
683
- * @returns The decoded options.
684
- */
685
- declare function decodeOptions(encodedMsg: string): InlineTranslationOptions | null; //#endregion
686
- //#endregion
687
- //#region src/variables/Derive.d.ts
688
- /**
689
- * Marks JSX children as derivable by the GT compiler and CLI.
690
- *
691
- * Use `<Derive>` inside translated JSX when child content is computed from
692
- * source code, but should still be discovered during extraction instead of
693
- * treated as a runtime interpolation variable. The CLI attempts to resolve the
694
- * derivable children into every possible static value and includes those values
695
- * in the source content that gets translated.
696
- *
697
- * `<Derive>` renders its children unchanged at runtime.
698
- *
699
- * Run `gt validate` after adding or changing `<Derive>` usage to verify that
700
- * each derivable expression can be resolved by the CLI before translating or
701
- * building.
702
- *
703
- * @example
704
- * ```jsx
705
- * function getSubject() {
706
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
707
- * }
708
- * ...
709
- * <T>
710
- * <Derive>
711
- * {getSubject()}
712
- * </Derive>
713
- * is going to school today.
714
- * </T>
715
- * ```
716
- *
717
- * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.
718
- * @returns {T} The same children, unchanged at runtime.
719
- */
720
- declare function Derive<T extends React.ReactNode>({
721
- children
722
- }: {
723
- children: T;
724
- }): T;
725
- declare namespace Derive {
726
- var _gtt: string;
727
- }
728
- /**
729
- * @deprecated Use `<Derive>` instead.
730
- *
731
- * Marks JSX children as derivable by the GT compiler and CLI.
732
- *
733
- * Use `<Derive>` instead of `<Static>` for new code. This alias is kept for
734
- * backwards compatibility and renders its children unchanged at runtime.
735
- *
736
- * Run `gt validate` after adding or changing derived JSX content to verify that
737
- * each derivable expression can be resolved by the CLI before translating or
738
- * building.
739
- *
740
- * @example
741
- * ```jsx
742
- * function getSubject() {
743
- * return (Math.random() > 0.5) ? "Alice" : "Brian";
744
- * }
745
- * ...
746
- * <T>
747
- * <Static>
748
- * {getSubject()}
749
- * </Static>
750
- * is going to school today.
751
- * </T>
752
- * ```
753
- *
754
- * @param {T extends React.ReactNode} children - JSX content to derive for translation extraction.
755
- * @returns {T} The same children, unchanged at runtime.
756
- */
757
- declare function Static<T extends React.ReactNode>(props: {
758
- children: T;
759
- }): T;
760
- declare namespace Static {
761
- var _gtt: string;
762
- }
763
- //#endregion
764
- export { Derive, Static, addGTIdentifier, collectUntranslatedEntries, declareStatic, declareVar, decodeMsg, decodeOptions, decodeVars, defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, derive, flattenDictionary, getDefaultRenderSettings, getDictionaryEntry, getEntryAndMetadata, getPluralBranch, getSubtree, getSubtreeWithCreation, getVariableName, getVariableProps, gtFallback, injectAndMerge, injectEntry, injectFallbacks, injectHashes, injectTranslations, isDictionaryEntry, isValidDictionaryEntry, isVariableObject, mFallback, mergeDictionaries, msg, reactHasUse, removeInjectedT, renderDefaultChildren, renderSkeleton, renderTranslatedChildren, stripMetadataFromEntries, writeChildrenAsObjects };
765
- //# sourceMappingURL=internal.d.ts.map