gt-react 9.1.0 → 9.2.0-alpha.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.
- package/dist/client.cjs.min.cjs +3 -3
- package/dist/client.d.ts +41 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.esm.min.mjs +3 -3
- package/dist/hooks/internal/useDetermineLocale.d.ts.map +1 -0
- package/dist/{provider/runtime → hooks/internal}/useRuntimeTranslation.d.ts +2 -1
- package/dist/hooks/internal/useRuntimeTranslation.d.ts.map +1 -0
- package/dist/hooks/internal/useTranslateContent.d.ts +3 -0
- package/dist/hooks/internal/useTranslateContent.d.ts.map +1 -0
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/messages/createMessages.d.ts +1 -0
- package/dist/messages/createMessages.d.ts.map +1 -1
- package/dist/provider/ClientProvider.d.ts +2 -2
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTContext.d.ts +1 -1
- package/dist/provider/GTContext.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/translation/hooks/useDict.d.ts +17 -0
- package/dist/translation/hooks/useDict.d.ts.map +1 -0
- package/dist/translation/hooks/useGT.d.ts +20 -0
- package/dist/translation/hooks/useGT.d.ts.map +1 -0
- package/dist/translation/inline/T.d.ts.map +1 -0
- package/dist/types/providers.d.ts +46 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/runtime.d.ts +18 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/types.d.ts +5 -57
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/useDetermineLocale.d.ts.map +0 -1
- package/dist/hooks/useGT.d.ts +0 -16
- package/dist/hooks/useGT.d.ts.map +0 -1
- package/dist/inline/T.d.ts.map +0 -1
- package/dist/provider/runtime/useRuntimeTranslation.d.ts.map +0 -1
- /package/dist/hooks/{useDetermineLocale.d.ts → internal/useDetermineLocale.d.ts} +0 -0
- /package/dist/{inline → translation/inline}/T.d.ts +0 -0
package/dist/client.d.ts
CHANGED
@@ -69,6 +69,13 @@ type TranslationsObject = {
|
|
69
69
|
[key: string]: TranslationSuccess | TranslationLoading | TranslationError;
|
70
70
|
};
|
71
71
|
type RenderMethod = 'skeleton' | 'replace' | 'default';
|
72
|
+
type TranslationOptions = {
|
73
|
+
context?: string;
|
74
|
+
variables?: Record<string, any>;
|
75
|
+
variableOptions?: Record<string, Intl.NumberFormatOptions | Intl.DateTimeFormatOptions>;
|
76
|
+
[key: string]: any;
|
77
|
+
};
|
78
|
+
|
72
79
|
type TranslateContentCallback = (params: {
|
73
80
|
source: any;
|
74
81
|
targetLocale: string;
|
@@ -76,7 +83,7 @@ type TranslateContentCallback = (params: {
|
|
76
83
|
hash: string;
|
77
84
|
context?: string;
|
78
85
|
} & Record<string, any>;
|
79
|
-
}) => Promise<
|
86
|
+
}) => Promise<TranslationSuccess | TranslationLoading | TranslationError>;
|
80
87
|
type TranslateChildrenCallback = (params: {
|
81
88
|
source: any;
|
82
89
|
targetLocale: string;
|
@@ -84,12 +91,14 @@ type TranslateChildrenCallback = (params: {
|
|
84
91
|
hash: string;
|
85
92
|
context?: string;
|
86
93
|
} & Record<string, any>;
|
87
|
-
}) => Promise<
|
94
|
+
}) => Promise<TranslationSuccess | TranslationLoading | TranslationError>;
|
95
|
+
|
88
96
|
type GTContextType = {
|
89
|
-
translateDictionaryEntry: (id: string, options?: Record<string, any>) => React__default.ReactNode;
|
90
97
|
registerContentForTranslation: TranslateContentCallback;
|
91
98
|
registerJsxForTranslation: TranslateChildrenCallback;
|
92
|
-
|
99
|
+
translateContent: (content: string, options: TranslationOptions) => string;
|
100
|
+
getDictionaryEntryTranslation: (id: string, options?: TranslationOptions) => React.ReactNode;
|
101
|
+
runtimeTranslationEnabled: boolean;
|
93
102
|
locale: string;
|
94
103
|
locales: string[];
|
95
104
|
setLocale: (locale: string) => void;
|
@@ -120,7 +129,7 @@ type ClientProviderProps = {
|
|
120
129
|
method: RenderMethod;
|
121
130
|
timeout?: number;
|
122
131
|
};
|
123
|
-
|
132
|
+
runtimeTranslationEnabled: boolean;
|
124
133
|
projectId?: string;
|
125
134
|
devApiKey?: string;
|
126
135
|
runtimeUrl?: string | null;
|
@@ -157,7 +166,7 @@ declare function renderVariable({ variableType, variableName, variableValue, var
|
|
157
166
|
locales: string[];
|
158
167
|
}): React.JSX.Element;
|
159
168
|
|
160
|
-
declare function ClientProvider({ children, dictionary, initialTranslations, translationPromises, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, requiredPrefix, renderSettings, projectId, devApiKey, runtimeUrl,
|
169
|
+
declare function ClientProvider({ children, dictionary, initialTranslations, translationPromises, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, requiredPrefix, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslationEnabled, onLocaleChange, cookieName, }: ClientProviderProps): React__default.JSX.Element;
|
161
170
|
|
162
171
|
/**
|
163
172
|
* The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
|
@@ -222,6 +231,25 @@ declare namespace Plural {
|
|
222
231
|
var gtTransformation: string;
|
223
232
|
}
|
224
233
|
|
234
|
+
/**
|
235
|
+
* Gets the translation function `t` provided by `<GTProvider>`.
|
236
|
+
*
|
237
|
+
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
238
|
+
*
|
239
|
+
* @example
|
240
|
+
* const t = useGT();
|
241
|
+
* console.log(t('To be or not to be...'));
|
242
|
+
*
|
243
|
+
* const t = useGT();
|
244
|
+
* return (<>
|
245
|
+
* {
|
246
|
+
* t('My name is {customName}', { variables: { customName: "Brian" } } )
|
247
|
+
* }
|
248
|
+
* </>);
|
249
|
+
*
|
250
|
+
*/
|
251
|
+
declare function useGT(): (content?: string, options?: TranslationOptions) => string;
|
252
|
+
|
225
253
|
/**
|
226
254
|
* Retrieves the application's default locale from the `<GTProvider>` context.
|
227
255
|
*
|
@@ -236,19 +264,19 @@ declare namespace Plural {
|
|
236
264
|
declare function useDefaultLocale(): string;
|
237
265
|
|
238
266
|
/**
|
239
|
-
* Gets the
|
267
|
+
* Gets the dictionary access function `d` provided by `<GTProvider>`.
|
240
268
|
*
|
241
269
|
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
242
270
|
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
243
271
|
*
|
244
272
|
* @example
|
245
|
-
* const
|
246
|
-
* console.log(
|
273
|
+
* const d = useDict('user');
|
274
|
+
* console.log(d('name')); // Translates item 'user.name'
|
247
275
|
*
|
248
|
-
* const
|
249
|
-
* console.log(
|
276
|
+
* const d = useDict();
|
277
|
+
* console.log(d('hello')); // Translates item 'hello'
|
250
278
|
*/
|
251
|
-
declare function
|
279
|
+
declare function useDict(id?: string): (id: string, options?: TranslationOptions) => React__default.ReactNode;
|
252
280
|
|
253
281
|
/**
|
254
282
|
* Retrieves the user's locale from the `<GTProvider>` context.
|
@@ -500,4 +528,4 @@ declare function GTProvider({ children, projectId: _projectId, devApiKey: _devAp
|
|
500
528
|
[key: string]: any;
|
501
529
|
}): React__default.JSX.Element;
|
502
530
|
|
503
|
-
export { Branch, ClientProvider, Currency, DateTime, GTContext, GTProvider, LocaleSelector, Num, Plural, T, Var, renderVariable, useDefaultLocale, useGT, useLocale, useRuntimeTranslation };
|
531
|
+
export { Branch, ClientProvider, Currency, DateTime, GTContext, GTProvider, LocaleSelector, Num, Plural, T, Var, renderVariable, useDefaultLocale, useDict, useGT, useLocale, useRuntimeTranslation };
|
package/dist/client.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,qBAAqB,MAAM,
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,qBAAqB,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,KAAK,MAAM,2BAA2B,CAAC;AAC9C,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,CAAC,MAAM,wBAAwB,CAAC;AACvC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,CAAC,EACD,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,cAAc,GACf,CAAC"}
|