gt-react 9.2.30 → 10.0.0-alpha.15
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 +0 -12
- package/LICENSE.md +1 -1
- package/dist/client.cjs.min.cjs +3 -3
- package/dist/client.d.ts +69 -74
- package/dist/client.esm.min.mjs +3 -3
- package/dist/dictionaries/getEntryAndMetadata.d.ts +2 -2
- package/dist/dictionaries/getEntryAndMetadata.d.ts.map +1 -1
- package/dist/dictionaries/loadDictionaryHelper.d.ts.map +1 -1
- package/dist/hooks/useGTClass.d.ts +1 -1
- package/dist/hooks/useGTClass.d.ts.map +1 -1
- package/dist/hooks/useLocaleSelector.d.ts +1 -10
- package/dist/hooks/useLocaleSelector.d.ts.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal/addGTIdentifier.d.ts +3 -2
- package/dist/internal/addGTIdentifier.d.ts.map +1 -1
- package/dist/internal/writeChildrenAsObjects.d.ts.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts +3 -3
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts +3 -3
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useErrorChecks.d.ts.map +1 -1
- package/dist/provider/hooks/useLoadTranslations.d.ts +6 -4
- package/dist/provider/hooks/useLoadTranslations.d.ts.map +1 -1
- package/dist/provider/hooks/useRuntimeTranslation.d.ts +7 -5
- package/dist/provider/hooks/useRuntimeTranslation.d.ts.map +1 -1
- package/dist/rendering/isVariableObject.d.ts +1 -1
- package/dist/rendering/isVariableObject.d.ts.map +1 -1
- package/dist/rendering/renderDefaultChildren.d.ts +3 -3
- package/dist/rendering/renderDefaultChildren.d.ts.map +1 -1
- package/dist/rendering/renderTranslatedChildren.d.ts +2 -2
- package/dist/rendering/renderTranslatedChildren.d.ts.map +1 -1
- package/dist/translation/inline/T.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context.d.ts +6 -4
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +8 -6
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/types.d.ts +34 -52
- package/dist/types/types.d.ts.map +1 -1
- package/dist/ui/LocaleSelector.d.ts.map +1 -1
- package/dist/variables/Currency.d.ts +7 -7
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/DateTime.d.ts +5 -6
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/Num.d.ts +6 -6
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Var.d.ts +2 -3
- package/dist/variables/Var.d.ts.map +1 -1
- package/dist/variables/_getVariableProps.d.ts +8 -5
- package/dist/variables/_getVariableProps.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
@@ -1,53 +1,54 @@
|
|
1
1
|
import * as React$1 from 'react';
|
2
2
|
import React__default from 'react';
|
3
|
+
import { JsxChildren } from 'generaltranslation/internal';
|
4
|
+
import { HtmlContentPropKeysRecord, Variable, VariableTransformationSuffix, JsxChildren as JsxChildren$1, CustomMapping } from 'generaltranslation/types';
|
3
5
|
import * as generaltranslation from 'generaltranslation';
|
4
6
|
import { GT } from 'generaltranslation';
|
5
|
-
import * as generaltranslation_types from 'generaltranslation/types';
|
6
|
-
import { CustomMapping } from 'generaltranslation/types';
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
8
|
+
import * as generaltranslation_dist_locales_getLocaleProperties from 'generaltranslation/dist/locales/getLocaleProperties';
|
8
9
|
|
10
|
+
/**
|
11
|
+
* For dictionaries, we have Entry and MetaEntry
|
12
|
+
*/
|
9
13
|
type Entry = string;
|
10
|
-
type
|
14
|
+
type MetaEntry = {
|
11
15
|
context?: string;
|
12
|
-
|
13
|
-
[key: string]: any;
|
16
|
+
[key: string]: unknown;
|
14
17
|
};
|
15
|
-
type DictionaryEntry = Entry | [Entry] | [Entry,
|
18
|
+
type DictionaryEntry = Entry | [Entry] | [Entry, MetaEntry];
|
16
19
|
type Dictionary = {
|
17
20
|
[key: string]: Dictionary | DictionaryEntry;
|
18
21
|
};
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
variable?: 'variable' | 'number' | 'datetime' | 'currency';
|
23
|
-
};
|
22
|
+
/**
|
23
|
+
* Translated content types
|
24
|
+
*/
|
24
25
|
type TranslatedElement = {
|
25
26
|
type: string;
|
26
27
|
props: {
|
27
28
|
'data-_gt': {
|
28
29
|
id: number;
|
29
|
-
|
30
|
-
|
30
|
+
transformation?: string;
|
31
|
+
b?: Record<string, JsxChildren>;
|
32
|
+
} & HtmlContentPropKeysRecord;
|
31
33
|
children?: TranslatedChildren;
|
32
34
|
};
|
33
35
|
};
|
34
36
|
type TranslatedChild = TranslatedElement | string | Variable;
|
35
37
|
type TranslatedChildren = TranslatedChild | TranslatedChild[];
|
36
|
-
type
|
37
|
-
|
38
|
-
state: 'error';
|
39
|
-
error: string;
|
40
|
-
code?: number;
|
38
|
+
type Translations = {
|
39
|
+
[hash: string]: TranslatedChildren;
|
41
40
|
};
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
|
50
|
-
|
41
|
+
/**
|
42
|
+
* Mapping of hashes to translation result status.
|
43
|
+
*/
|
44
|
+
type TranslationsStatus = {
|
45
|
+
[hash: string]: {
|
46
|
+
status: 'success' | 'loading';
|
47
|
+
} | {
|
48
|
+
status: 'error';
|
49
|
+
code?: number;
|
50
|
+
error?: string;
|
51
|
+
};
|
51
52
|
};
|
52
53
|
type CustomLoader = (locale: string) => Promise<any>;
|
53
54
|
type RenderMethod = 'skeleton' | 'replace' | 'default';
|
@@ -60,7 +61,7 @@ type InlineTranslationOptions = {
|
|
60
61
|
id?: string;
|
61
62
|
} & DictionaryTranslationOptions;
|
62
63
|
type VariableProps = {
|
63
|
-
variableType:
|
64
|
+
variableType: VariableTransformationSuffix;
|
64
65
|
variableValue: any;
|
65
66
|
variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
|
66
67
|
variableName: string;
|
@@ -69,26 +70,28 @@ type RenderVariable = ({ variableType, variableValue, variableOptions, locales,
|
|
69
70
|
locales: string[];
|
70
71
|
}) => React__default.JSX.Element;
|
71
72
|
|
72
|
-
type
|
73
|
-
source:
|
73
|
+
type TranslateIcuCallback = (params: {
|
74
|
+
source: string;
|
74
75
|
targetLocale: string;
|
75
76
|
metadata: {
|
76
77
|
hash: string;
|
77
78
|
context?: string;
|
78
79
|
} & Record<string, any>;
|
79
|
-
}) => Promise<
|
80
|
+
}) => Promise<TranslatedChildren>;
|
81
|
+
type TranslateI18nextCallback = TranslateIcuCallback;
|
80
82
|
type TranslateChildrenCallback = (params: {
|
81
|
-
source:
|
83
|
+
source: JsxChildren$1 | undefined;
|
82
84
|
targetLocale: string;
|
83
85
|
metadata: {
|
84
86
|
hash: string;
|
85
87
|
context?: string;
|
86
88
|
} & Record<string, any>;
|
87
|
-
}) => Promise<
|
89
|
+
}) => Promise<TranslatedChildren>;
|
88
90
|
|
89
91
|
type GTContextType = {
|
90
92
|
gt: GT;
|
91
|
-
|
93
|
+
registerI18nextForTranslation: TranslateI18nextCallback;
|
94
|
+
registerIcuForTranslation: TranslateIcuCallback;
|
92
95
|
registerJsxForTranslation: TranslateChildrenCallback;
|
93
96
|
_internalUseGTFunction: (string: string, options?: InlineTranslationOptions) => string;
|
94
97
|
_internalUseTranslationsFunction: (id: string, options?: DictionaryTranslationOptions) => string;
|
@@ -97,7 +100,8 @@ type GTContextType = {
|
|
97
100
|
locales: string[];
|
98
101
|
setLocale: (locale: string) => void;
|
99
102
|
defaultLocale: string;
|
100
|
-
translations:
|
103
|
+
translations: Translations | null;
|
104
|
+
translationsStatus: TranslationsStatus | null;
|
101
105
|
translationRequired: boolean;
|
102
106
|
dialectTranslationRequired: boolean;
|
103
107
|
renderSettings: {
|
@@ -109,7 +113,7 @@ type GTContextType = {
|
|
109
113
|
|
110
114
|
declare const GTContext: React$1.Context<GTContextType | undefined>;
|
111
115
|
|
112
|
-
declare function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, ...globalMetadata }: {
|
116
|
+
declare function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, setTranslationsStatus, ...globalMetadata }: {
|
113
117
|
projectId?: string;
|
114
118
|
devApiKey?: string;
|
115
119
|
locale: string;
|
@@ -120,10 +124,12 @@ declare function useRuntimeTranslation({ projectId, devApiKey, locale, versionId
|
|
120
124
|
method: RenderMethod;
|
121
125
|
timeout?: number;
|
122
126
|
};
|
123
|
-
setTranslations: React$1.Dispatch<React$1.SetStateAction<
|
127
|
+
setTranslations: React$1.Dispatch<React$1.SetStateAction<Translations | null>>;
|
128
|
+
setTranslationsStatus: React$1.Dispatch<React$1.SetStateAction<TranslationsStatus | null>>;
|
124
129
|
[key: string]: any;
|
125
130
|
}): {
|
126
|
-
|
131
|
+
registerI18nextForTranslation: TranslateI18nextCallback;
|
132
|
+
registerIcuForTranslation: TranslateIcuCallback;
|
127
133
|
registerJsxForTranslation: TranslateChildrenCallback;
|
128
134
|
runtimeTranslationEnabled: boolean;
|
129
135
|
};
|
@@ -164,7 +170,7 @@ type GTProviderProps = {
|
|
164
170
|
_versionId?: string;
|
165
171
|
ssr?: boolean;
|
166
172
|
localeCookieName?: string;
|
167
|
-
translations?:
|
173
|
+
translations?: Translations | null;
|
168
174
|
loadDictionary?: CustomLoader;
|
169
175
|
loadTranslations?: CustomLoader;
|
170
176
|
config?: GTConfig;
|
@@ -175,7 +181,7 @@ type GTProviderProps = {
|
|
175
181
|
type ClientProviderProps = {
|
176
182
|
children: any;
|
177
183
|
dictionary: Dictionary;
|
178
|
-
initialTranslations:
|
184
|
+
initialTranslations: Translations;
|
179
185
|
locale: string;
|
180
186
|
locales: string[];
|
181
187
|
_versionId?: string;
|
@@ -378,19 +384,19 @@ declare namespace T {
|
|
378
384
|
* </Currency>
|
379
385
|
* ```
|
380
386
|
*
|
381
|
-
* @param {
|
382
|
-
* @param {string} [currency] - The currency type (e.g., USD, EUR, etc.).
|
383
|
-
* @param {string[]} [locales] - Optional locales to use for currency formatting. If
|
384
|
-
* @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
|
387
|
+
* @param {number | string | null | undefined} children - Content to render inside the currency component.
|
388
|
+
* @param {string} [currency="USD"] - The currency type (e.g., USD, EUR, etc.).
|
389
|
+
* @param {string[]} [locales] - Optional locales to use for currency formatting. If wrapped in a `<GTProvider>`, the user's locale is used.
|
390
|
+
* @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options to customize how the currency is displayed.
|
385
391
|
* @returns {JSX.Element} The formatted currency component.
|
386
392
|
*/
|
387
|
-
declare function Currency({ children, currency,
|
388
|
-
children
|
393
|
+
declare function Currency({ children, currency, locales, options, }: {
|
394
|
+
children: number | string | null | undefined;
|
389
395
|
currency?: string;
|
390
396
|
name?: string;
|
391
397
|
locales?: string[];
|
392
398
|
options?: Intl.NumberFormatOptions;
|
393
|
-
}): React__default.JSX.Element;
|
399
|
+
}): React__default.JSX.Element | null;
|
394
400
|
declare namespace Currency {
|
395
401
|
var gtTransformation: string;
|
396
402
|
}
|
@@ -407,17 +413,16 @@ declare namespace Currency {
|
|
407
413
|
* </DateTime>
|
408
414
|
* ```
|
409
415
|
*
|
410
|
-
* @param {
|
411
|
-
* @param {string[]} [locales] - Optional locales to use for date formatting. If
|
416
|
+
* @param {Date} children - Content to render inside the date component.
|
417
|
+
* @param {string[]} [locales] - Optional locales to use for date formatting. If wrapped in a `<GTProvider>`, the user's locale is used.
|
412
418
|
* @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
|
413
419
|
* @returns {JSX.Element} The formatted date or time component.
|
414
420
|
*/
|
415
|
-
declare function DateTime({ children, locales,
|
416
|
-
children
|
421
|
+
declare function DateTime({ children, locales, options, }: {
|
422
|
+
children: Date | null | undefined;
|
417
423
|
locales?: string[];
|
418
|
-
name?: string;
|
419
424
|
options?: Intl.DateTimeFormatOptions;
|
420
|
-
}): React__default.JSX.Element;
|
425
|
+
}): React__default.JSX.Element | null;
|
421
426
|
declare namespace DateTime {
|
422
427
|
var gtTransformation: string;
|
423
428
|
}
|
@@ -436,16 +441,16 @@ declare namespace DateTime {
|
|
436
441
|
* </Num>
|
437
442
|
* ```
|
438
443
|
*
|
439
|
-
* @param {
|
444
|
+
* @param {number | string | null | undefined} children - Content to render inside the number component.
|
445
|
+
* @param {string[]} [locales] - Optional locales to use for number formatting. If wrapped in a `<GTProvider>`, the user's locale is used.
|
440
446
|
* @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
|
441
|
-
* @returns {JSX.Element} The formatted number component.
|
447
|
+
* @returns {React.JSX.Element} The formatted number component.
|
442
448
|
*/
|
443
|
-
declare function Num({ children,
|
444
|
-
children
|
449
|
+
declare function Num({ children, locales, options, }: {
|
450
|
+
children: number | string | null | undefined;
|
445
451
|
locales?: string[];
|
446
452
|
options?: Intl.NumberFormatOptions;
|
447
|
-
|
448
|
-
}): React__default.JSX.Element;
|
453
|
+
}): React__default.JSX.Element | null;
|
449
454
|
declare namespace Num {
|
450
455
|
var gtTransformation: string;
|
451
456
|
}
|
@@ -472,10 +477,9 @@ declare namespace Num {
|
|
472
477
|
* @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
|
473
478
|
* @returns {JSX.Element} The rendered variable component with either `children` or `value`.
|
474
479
|
*/
|
475
|
-
declare function Var({ children
|
480
|
+
declare function Var({ children }: {
|
476
481
|
children?: any;
|
477
|
-
|
478
|
-
}): React__default.JSX.Element;
|
482
|
+
}): React__default.JSX.Element | null;
|
479
483
|
declare namespace Var {
|
480
484
|
var gtTransformation: string;
|
481
485
|
}
|
@@ -511,7 +515,7 @@ declare function LocaleSelector({ locales: _locales, customNames, ...props }: {
|
|
511
515
|
* @param {object} [metadata] - Additional metadata to pass to the context.
|
512
516
|
* @param {boolean} [ssr=isSSREnabled()] - Whether to enable server-side rendering.
|
513
517
|
* @param {string} [localeCookieName=defaultLocaleCookieName] - The name of the cookie to store the locale.
|
514
|
-
* @param {
|
518
|
+
* @param {Translations | null} [translations=null] - The translations to use for the context.
|
515
519
|
* @param {React.ReactNode} [fallback = undefined] - Custom fallback to display while loading
|
516
520
|
*
|
517
521
|
* @returns {JSX.Element} The provider component for General Translation context.
|
@@ -542,23 +546,14 @@ declare function useSetLocale(): (locale: string) => void;
|
|
542
546
|
declare function useLocales(): string[];
|
543
547
|
|
544
548
|
/**
|
545
|
-
/**
|
546
549
|
* Gets the list of properties for using a locale selector.
|
547
|
-
* Provides locale management utilities for the application.
|
548
550
|
* @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.
|
549
|
-
*
|
550
|
-
*
|
551
|
-
* @returns {Object} An object containing locale-related utilities:
|
552
|
-
* @returns {string} return.locale - The currently selected locale.
|
553
|
-
* @returns {string[]} return.locales - The list of all available locales.
|
554
|
-
* @returns {(locale: string) => void} return.setLocale - Function to update the current locale.
|
555
|
-
* @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.
|
551
|
+
* @returns {object} The locale, locales, and setLocale function.
|
556
552
|
*/
|
557
553
|
declare function useLocaleSelector(locales?: string[]): {
|
558
554
|
locale: string;
|
559
555
|
locales: string[];
|
560
556
|
setLocale: (locale: string) => void;
|
561
|
-
getLocaleProperties: (locale: string) => generaltranslation_types.LocaleProperties;
|
562
557
|
};
|
563
558
|
|
564
559
|
/**
|
@@ -581,6 +576,6 @@ declare function useGTClass(): generaltranslation.GT;
|
|
581
576
|
* const localeProperties = useLocaleProperties('en-US');
|
582
577
|
* console.log(localeProperties);
|
583
578
|
*/
|
584
|
-
declare function useLocaleProperties(locale: string):
|
579
|
+
declare function useLocaleProperties(locale: string): generaltranslation_dist_locales_getLocaleProperties.LocaleProperties;
|
585
580
|
|
586
581
|
export { Branch, ClientProvider, Currency, DateTime, GTContext, GTProvider, LocaleSelector, Num, Plural, T, Var, renderVariable, useDefaultLocale, useTranslations as useDict, useGT, useGTClass, useLocale, useLocaleProperties, useLocaleSelector, useLocales, useRuntimeTranslation, useSetLocale, useTranslations };
|