gt-react 10.2.1 → 10.2.2-alpha.1
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/dist/client.cjs.min.cjs +3 -3
- package/dist/client.d.ts +25 -30
- package/dist/client.esm.min.mjs +3 -3
- package/dist/errors/createErrors.d.ts +2 -0
- package/dist/errors/createErrors.d.ts.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal.cjs.min.cjs +3 -3
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.esm.min.mjs +3 -3
- package/dist/promises/dangerouslyUsable.d.ts +37 -0
- package/dist/promises/dangerouslyUsable.d.ts.map +1 -0
- package/dist/promises/reactHasUse.d.ts +2 -0
- package/dist/promises/reactHasUse.d.ts.map +1 -0
- package/dist/provider/ClientProvider.d.ts +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/helpers/validateString.d.ts +6 -0
- package/dist/provider/helpers/validateString.d.ts.map +1 -0
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts +15 -4
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts +2 -2
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useLoadTranslations.d.ts +1 -3
- package/dist/provider/hooks/useLoadTranslations.d.ts.map +1 -1
- package/dist/provider/hooks/useRuntimeTranslation.d.ts +5 -6
- package/dist/provider/hooks/useRuntimeTranslation.d.ts.map +1 -1
- package/dist/translation/hooks/useGT.d.ts +3 -1
- package/dist/translation/hooks/useGT.d.ts.map +1 -1
- package/dist/translation/inline/T.d.ts +3 -2
- package/dist/translation/inline/T.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context.d.ts +7 -7
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/types.d.ts +9 -13
- package/dist/types/types.d.ts.map +1 -1
- package/dist/ui/RegionSelector.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -29,19 +29,7 @@ type TranslatedElement = {
|
|
|
29
29
|
type TranslatedChild = TranslatedElement | string | Variable;
|
|
30
30
|
type TranslatedChildren = TranslatedChild | TranslatedChild[];
|
|
31
31
|
type Translations = {
|
|
32
|
-
[hash: string]: TranslatedChildren;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Mapping of hashes to translation result status.
|
|
36
|
-
*/
|
|
37
|
-
type TranslationsStatus = {
|
|
38
|
-
[hash: string]: {
|
|
39
|
-
status: 'success' | 'loading';
|
|
40
|
-
} | {
|
|
41
|
-
status: 'error';
|
|
42
|
-
code?: number;
|
|
43
|
-
error?: string;
|
|
44
|
-
};
|
|
32
|
+
[hash: string]: TranslatedChildren | null;
|
|
45
33
|
};
|
|
46
34
|
type CustomLoader = (locale: string) => Promise<any>;
|
|
47
35
|
type RenderMethod = 'skeleton' | 'replace' | 'default';
|
|
@@ -49,6 +37,7 @@ type DictionaryTranslationOptions = Record<string, any>;
|
|
|
49
37
|
type InlineTranslationOptions = DictionaryTranslationOptions & {
|
|
50
38
|
$context?: string;
|
|
51
39
|
$id?: string;
|
|
40
|
+
$_hash?: string;
|
|
52
41
|
};
|
|
53
42
|
type VariableProps = {
|
|
54
43
|
variableType: VariableType;
|
|
@@ -59,6 +48,13 @@ type VariableProps = {
|
|
|
59
48
|
type RenderVariable = ({ variableType, variableValue, variableOptions, locales, }: Omit<VariableProps, 'variableName'> & {
|
|
60
49
|
locales: string[];
|
|
61
50
|
}) => React__default.JSX.Element;
|
|
51
|
+
type _Message = {
|
|
52
|
+
message: string;
|
|
53
|
+
$id?: string;
|
|
54
|
+
$context?: string;
|
|
55
|
+
$_hash?: string;
|
|
56
|
+
};
|
|
57
|
+
type _Messages = _Message[];
|
|
62
58
|
|
|
63
59
|
type TranslateIcuCallback = (params: {
|
|
64
60
|
source: string;
|
|
@@ -68,7 +64,6 @@ type TranslateIcuCallback = (params: {
|
|
|
68
64
|
context?: string;
|
|
69
65
|
} & Record<string, any>;
|
|
70
66
|
}) => Promise<TranslatedChildren>;
|
|
71
|
-
type TranslateI18nextCallback = TranslateIcuCallback;
|
|
72
67
|
type TranslateChildrenCallback = (params: {
|
|
73
68
|
source: JsxChildren | undefined;
|
|
74
69
|
targetLocale: string;
|
|
@@ -80,12 +75,13 @@ type TranslateChildrenCallback = (params: {
|
|
|
80
75
|
|
|
81
76
|
type GTContextType = {
|
|
82
77
|
gt: GT;
|
|
83
|
-
registerI18nextForTranslation: TranslateI18nextCallback;
|
|
84
78
|
registerIcuForTranslation: TranslateIcuCallback;
|
|
85
79
|
registerJsxForTranslation: TranslateChildrenCallback;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
_tFunction: (message: string, options?: InlineTranslationOptions, preloadedTranslations?: Translations) => string;
|
|
81
|
+
_filterMessagesForPreload: (_messages: _Messages) => _Messages;
|
|
82
|
+
_preloadMessages: (_messages: _Messages) => Promise<Translations>;
|
|
83
|
+
_dictionaryFunction: (id: string, options?: DictionaryTranslationOptions) => string;
|
|
84
|
+
developmentApiEnabled: boolean;
|
|
89
85
|
locale: string;
|
|
90
86
|
locales: string[];
|
|
91
87
|
setLocale: (locale: string) => void;
|
|
@@ -93,7 +89,6 @@ type GTContextType = {
|
|
|
93
89
|
region: string | undefined;
|
|
94
90
|
setRegion: (region: string | undefined) => void;
|
|
95
91
|
translations: Translations | null;
|
|
96
|
-
translationsStatus: TranslationsStatus | null;
|
|
97
92
|
translationRequired: boolean;
|
|
98
93
|
dialectTranslationRequired: boolean;
|
|
99
94
|
renderSettings: {
|
|
@@ -105,7 +100,8 @@ type GTContextType = {
|
|
|
105
100
|
|
|
106
101
|
declare const GTContext: React$1.Context<GTContextType | undefined>;
|
|
107
102
|
|
|
108
|
-
declare function useRuntimeTranslation({ gt, locale, versionId,
|
|
103
|
+
declare function useRuntimeTranslation({ gt, locale, versionId, // kept for API compatibility (not used)
|
|
104
|
+
defaultLocale, runtimeUrl, renderSettings, setTranslations, ...additionalMetadata }: {
|
|
109
105
|
gt: GT;
|
|
110
106
|
locale: string;
|
|
111
107
|
versionId?: string;
|
|
@@ -116,13 +112,11 @@ declare function useRuntimeTranslation({ gt, locale, versionId, defaultLocale, r
|
|
|
116
112
|
timeout?: number;
|
|
117
113
|
};
|
|
118
114
|
setTranslations: React$1.Dispatch<React$1.SetStateAction<Translations | null>>;
|
|
119
|
-
setTranslationsStatus: React$1.Dispatch<React$1.SetStateAction<TranslationsStatus | null>>;
|
|
120
115
|
[key: string]: any;
|
|
121
116
|
}): {
|
|
122
|
-
registerI18nextForTranslation: TranslateI18nextCallback;
|
|
123
117
|
registerIcuForTranslation: TranslateIcuCallback;
|
|
124
118
|
registerJsxForTranslation: TranslateChildrenCallback;
|
|
125
|
-
|
|
119
|
+
developmentApiEnabled: boolean;
|
|
126
120
|
};
|
|
127
121
|
|
|
128
122
|
declare const renderVariable: RenderVariable;
|
|
@@ -175,8 +169,7 @@ type GTProviderProps = {
|
|
|
175
169
|
type ClientProviderProps = {
|
|
176
170
|
children: any;
|
|
177
171
|
dictionary: Dictionary;
|
|
178
|
-
|
|
179
|
-
initialTranslationsStatus: TranslationsStatus;
|
|
172
|
+
translations: Translations;
|
|
180
173
|
locale: string;
|
|
181
174
|
locales: string[];
|
|
182
175
|
region?: string;
|
|
@@ -189,7 +182,7 @@ type ClientProviderProps = {
|
|
|
189
182
|
method: RenderMethod;
|
|
190
183
|
timeout?: number;
|
|
191
184
|
};
|
|
192
|
-
|
|
185
|
+
developmentApiEnabled: boolean;
|
|
193
186
|
projectId?: string;
|
|
194
187
|
devApiKey?: string;
|
|
195
188
|
runtimeUrl?: string | null;
|
|
@@ -200,7 +193,7 @@ type ClientProviderProps = {
|
|
|
200
193
|
customMapping?: CustomMapping;
|
|
201
194
|
};
|
|
202
195
|
|
|
203
|
-
declare function ClientProvider({ children, dictionary,
|
|
196
|
+
declare function ClientProvider({ children, dictionary, translations: _translations, locale: _locale, region: _region, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, renderSettings, projectId, devApiKey, runtimeUrl, developmentApiEnabled, resetLocaleCookieName, localeCookieName, regionCookieName, customMapping, }: ClientProviderProps): React$1.JSX.Element;
|
|
204
197
|
|
|
205
198
|
/**
|
|
206
199
|
* The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
|
|
@@ -290,9 +283,10 @@ declare namespace Plural {
|
|
|
290
283
|
* </>);
|
|
291
284
|
*
|
|
292
285
|
*/
|
|
293
|
-
declare function useGT(): (string: string, options?: Record<string, any> & {
|
|
286
|
+
declare function useGT(_messages?: _Messages): (string: string, options?: Record<string, any> & {
|
|
294
287
|
$id?: string;
|
|
295
288
|
$context?: string;
|
|
289
|
+
$_hash?: string;
|
|
296
290
|
}) => string;
|
|
297
291
|
|
|
298
292
|
/**
|
|
@@ -363,12 +357,13 @@ declare function useLocale(): string;
|
|
|
363
357
|
*
|
|
364
358
|
* @throws {Error} If a plural translation is requested but the `n` option is not provided.
|
|
365
359
|
*/
|
|
366
|
-
declare function T({ children, id, context, ...options }: {
|
|
360
|
+
declare function T({ children, id, context, _hash, ...options }: {
|
|
367
361
|
children: any;
|
|
368
362
|
id?: string;
|
|
369
363
|
context?: string;
|
|
364
|
+
_hash?: string;
|
|
370
365
|
[key: string]: any;
|
|
371
|
-
}): React__default.JSX.Element |
|
|
366
|
+
}): React__default.JSX.Element | undefined;
|
|
372
367
|
declare namespace T {
|
|
373
368
|
var _gtt: string;
|
|
374
369
|
}
|