@sheet-i18n/react-client 1.0.5 → 1.0.7
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/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +47 -17
- package/dist/index.mjs +47 -17
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -5,10 +5,11 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams$1<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type $TParams$1 = Partial<UseIntlParams$1>;
|
|
7
7
|
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
|
|
8
|
-
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
8
|
+
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
9
9
|
} & {
|
|
10
10
|
t: {
|
|
11
|
-
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
11
|
+
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
12
|
+
promise: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams$1<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type $TParams$1 = Partial<UseIntlParams$1>;
|
|
7
7
|
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
|
|
8
|
-
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
8
|
+
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
9
9
|
} & {
|
|
10
10
|
t: {
|
|
11
|
-
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
11
|
+
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
12
|
+
promise: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,7 @@ function IntlProvider({
|
|
|
57
57
|
}) {
|
|
58
58
|
var _a;
|
|
59
59
|
const locale = (_a = currentLocale != null ? currentLocale : detectClientLanguage(i18nStore)) != null ? _a : i18nStore.defaultLocale;
|
|
60
|
+
i18nStore.setCurrentLocale(locale);
|
|
60
61
|
(0, import_react.useEffect)(() => {
|
|
61
62
|
i18nStore.setCurrentLocale(locale);
|
|
62
63
|
}, [locale]);
|
|
@@ -183,35 +184,48 @@ function getTranslation({
|
|
|
183
184
|
sheetTitle,
|
|
184
185
|
i18nStore
|
|
185
186
|
}) {
|
|
186
|
-
const intlInitPromise = new Promise((resolve) => {
|
|
187
|
-
setTimeout(() => {
|
|
188
|
-
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
189
|
-
sheetTitle,
|
|
190
|
-
i18nStore,
|
|
191
|
-
"server"
|
|
192
|
-
);
|
|
193
|
-
resolve(intlInstance);
|
|
194
|
-
}, 1);
|
|
195
|
-
});
|
|
196
187
|
const t = (id, values, opts, _descriptor) => {
|
|
197
|
-
var _a;
|
|
188
|
+
var _a, _b, _c, _d;
|
|
198
189
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
199
190
|
id,
|
|
200
191
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
201
192
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
193
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
194
|
+
sheetTitle,
|
|
195
|
+
i18nStore,
|
|
196
|
+
"server"
|
|
197
|
+
);
|
|
198
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
208
199
|
};
|
|
209
200
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
201
|
+
var _a, _b, _c, _d;
|
|
202
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
203
|
+
id,
|
|
204
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
205
|
+
});
|
|
206
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
207
|
+
sheetTitle,
|
|
208
|
+
i18nStore,
|
|
209
|
+
"server"
|
|
210
|
+
);
|
|
211
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
212
|
+
};
|
|
213
|
+
t.promise = (id, values, opts, _descriptor) => {
|
|
210
214
|
var _a;
|
|
211
215
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
212
216
|
id,
|
|
213
217
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
214
218
|
});
|
|
219
|
+
const intlInitPromise = new Promise((resolve) => {
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
222
|
+
sheetTitle,
|
|
223
|
+
i18nStore,
|
|
224
|
+
"server"
|
|
225
|
+
);
|
|
226
|
+
resolve(intlInstance);
|
|
227
|
+
}, 1);
|
|
228
|
+
});
|
|
215
229
|
return new Promise((resolve) => {
|
|
216
230
|
intlInitPromise.then((intlInstance) => {
|
|
217
231
|
var _a2, _b, _c;
|
|
@@ -219,6 +233,22 @@ function getTranslation({
|
|
|
219
233
|
});
|
|
220
234
|
});
|
|
221
235
|
};
|
|
236
|
+
t.lazy = (id, values, opts, _descriptor) => {
|
|
237
|
+
var _a;
|
|
238
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
239
|
+
id,
|
|
240
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
241
|
+
});
|
|
242
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
243
|
+
sheetTitle,
|
|
244
|
+
i18nStore,
|
|
245
|
+
"server"
|
|
246
|
+
);
|
|
247
|
+
return () => {
|
|
248
|
+
var _a2, _b, _c;
|
|
249
|
+
return (_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "";
|
|
250
|
+
};
|
|
251
|
+
};
|
|
222
252
|
return { t };
|
|
223
253
|
}
|
|
224
254
|
|
package/dist/index.mjs
CHANGED
|
@@ -34,6 +34,7 @@ function IntlProvider({
|
|
|
34
34
|
}) {
|
|
35
35
|
var _a;
|
|
36
36
|
const locale = (_a = currentLocale != null ? currentLocale : detectClientLanguage(i18nStore)) != null ? _a : i18nStore.defaultLocale;
|
|
37
|
+
i18nStore.setCurrentLocale(locale);
|
|
37
38
|
useEffect(() => {
|
|
38
39
|
i18nStore.setCurrentLocale(locale);
|
|
39
40
|
}, [locale]);
|
|
@@ -160,35 +161,48 @@ function getTranslation({
|
|
|
160
161
|
sheetTitle,
|
|
161
162
|
i18nStore
|
|
162
163
|
}) {
|
|
163
|
-
const intlInitPromise = new Promise((resolve) => {
|
|
164
|
-
setTimeout(() => {
|
|
165
|
-
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
166
|
-
sheetTitle,
|
|
167
|
-
i18nStore,
|
|
168
|
-
"server"
|
|
169
|
-
);
|
|
170
|
-
resolve(intlInstance);
|
|
171
|
-
}, 1);
|
|
172
|
-
});
|
|
173
164
|
const t = (id, values, opts, _descriptor) => {
|
|
174
|
-
var _a;
|
|
165
|
+
var _a, _b, _c, _d;
|
|
175
166
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
176
167
|
id,
|
|
177
168
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
178
169
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
170
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
171
|
+
sheetTitle,
|
|
172
|
+
i18nStore,
|
|
173
|
+
"server"
|
|
174
|
+
);
|
|
175
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
185
176
|
};
|
|
186
177
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
178
|
+
var _a, _b, _c, _d;
|
|
179
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
180
|
+
id,
|
|
181
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
182
|
+
});
|
|
183
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
184
|
+
sheetTitle,
|
|
185
|
+
i18nStore,
|
|
186
|
+
"server"
|
|
187
|
+
);
|
|
188
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
189
|
+
};
|
|
190
|
+
t.promise = (id, values, opts, _descriptor) => {
|
|
187
191
|
var _a;
|
|
188
192
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
189
193
|
id,
|
|
190
194
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
191
195
|
});
|
|
196
|
+
const intlInitPromise = new Promise((resolve) => {
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
199
|
+
sheetTitle,
|
|
200
|
+
i18nStore,
|
|
201
|
+
"server"
|
|
202
|
+
);
|
|
203
|
+
resolve(intlInstance);
|
|
204
|
+
}, 1);
|
|
205
|
+
});
|
|
192
206
|
return new Promise((resolve) => {
|
|
193
207
|
intlInitPromise.then((intlInstance) => {
|
|
194
208
|
var _a2, _b, _c;
|
|
@@ -196,6 +210,22 @@ function getTranslation({
|
|
|
196
210
|
});
|
|
197
211
|
});
|
|
198
212
|
};
|
|
213
|
+
t.lazy = (id, values, opts, _descriptor) => {
|
|
214
|
+
var _a;
|
|
215
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
216
|
+
id,
|
|
217
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
218
|
+
});
|
|
219
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
220
|
+
sheetTitle,
|
|
221
|
+
i18nStore,
|
|
222
|
+
"server"
|
|
223
|
+
);
|
|
224
|
+
return () => {
|
|
225
|
+
var _a2, _b, _c;
|
|
226
|
+
return (_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "";
|
|
227
|
+
};
|
|
228
|
+
};
|
|
199
229
|
return { t };
|
|
200
230
|
}
|
|
201
231
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheet-i18n/react-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "a client package for react modules used by sheet-i18n",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"react": "^18.2.0",
|
|
29
29
|
"react-intl": "^7.0.4",
|
|
30
|
-
"@sheet-i18n/
|
|
31
|
-
"@sheet-i18n/
|
|
32
|
-
"@sheet-i18n/react-core": "1.0.
|
|
30
|
+
"@sheet-i18n/errors": "1.3.7",
|
|
31
|
+
"@sheet-i18n/shared-utils": "1.3.7",
|
|
32
|
+
"@sheet-i18n/react-core": "1.0.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^19.0.2",
|
|
36
36
|
"@types/react-dom": "^19.0.2",
|
|
37
|
-
"@sheet-i18n/typescript-config": "1.3.
|
|
37
|
+
"@sheet-i18n/typescript-config": "1.3.7"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|