@urbicon-ui/i18n 6.19.0 → 6.19.2
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.
|
@@ -58,17 +58,17 @@ export function createPackageI18n(packageName, translations, options) {
|
|
|
58
58
|
ensureRegistered();
|
|
59
59
|
const state = useI18nState();
|
|
60
60
|
const registry = getRegistry();
|
|
61
|
-
return ((key, params,
|
|
61
|
+
return ((key, params, callOptions) => registry.translate(key, state?.locale ?? BASE_LOCALE, state?.fallbackLocale ?? BASE_LOCALE, params, { packageName, ...callOptions }));
|
|
62
62
|
};
|
|
63
63
|
// Non-hook `t` for non-component use (tests, server utilities). Resolves
|
|
64
64
|
// against the base locale — there is no request-scoped state outside a
|
|
65
65
|
// component. Components use `useTranslate` for the reactive, provider-scoped
|
|
66
66
|
// locale.
|
|
67
|
-
const t = ((key, params,
|
|
67
|
+
const t = ((key, params, callOptions) => {
|
|
68
68
|
ensureRegistered();
|
|
69
69
|
return getRegistry().translate(key, BASE_LOCALE, BASE_LOCALE, params, {
|
|
70
70
|
packageName,
|
|
71
|
-
...
|
|
71
|
+
...callOptions
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
const exists = (key) => {
|
|
@@ -26,13 +26,11 @@ export class I18nRegistry {
|
|
|
26
26
|
loadedLocales = new SvelteSet();
|
|
27
27
|
loadingLocales = new SvelteSet();
|
|
28
28
|
// Non-reactive per-instance cache; SvelteMap is unnecessary here.
|
|
29
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
30
29
|
translationLoaders = new Map();
|
|
31
30
|
// Per-package lazy loaders (WP4 code-splitting), keyed `${packageName}::${locale}`.
|
|
32
31
|
// Registered at module-eval, read in setLocale/loadLocale (not in a $derived), so
|
|
33
32
|
// a plain Map suffices. The *loaded data* lands in the reactive packageTranslations,
|
|
34
33
|
// which is what re-resolves `$derived` reads when a chunk arrives.
|
|
35
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
36
34
|
packageLoaders = new Map();
|
|
37
35
|
// Reactive: `isLoading` derives from its size.
|
|
38
36
|
loadingPackageLocales = new SvelteSet();
|
|
@@ -40,9 +38,7 @@ export class I18nRegistry {
|
|
|
40
38
|
// on every `new`; caching by locale avoids that cost when plural()/formatNumber
|
|
41
39
|
// run inside a large {#each}. Keyed by locale only (options-bearing calls skip
|
|
42
40
|
// the cache — they are rare and varied).
|
|
43
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
44
41
|
pluralRulesCache = new Map();
|
|
45
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
46
42
|
numberFormatCache = new Map();
|
|
47
43
|
/**
|
|
48
44
|
* Optional error sink. Set once by the app (e.g. via the provider) so loader
|
|
@@ -391,7 +387,6 @@ export class I18nRegistry {
|
|
|
391
387
|
// --- introspection ---
|
|
392
388
|
getAvailableLocales() {
|
|
393
389
|
// Local accumulator — not reactive state.
|
|
394
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
395
390
|
const allLocales = new Set();
|
|
396
391
|
Object.keys(this.translations).forEach((locale) => {
|
|
397
392
|
allLocales.add(locale);
|
|
@@ -412,7 +407,6 @@ export class I18nRegistry {
|
|
|
412
407
|
}
|
|
413
408
|
getPackageLocales(packageName) {
|
|
414
409
|
// Eager/loaded locales plus any registered lazy loaders for the package.
|
|
415
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
416
410
|
const locales = new Set(Object.keys(this.packageTranslations.get(packageName) ?? {}));
|
|
417
411
|
const prefix = `${packageName}::`;
|
|
418
412
|
this.packageLoaders.forEach((_, key) => {
|
|
@@ -453,7 +447,6 @@ export class I18nRegistry {
|
|
|
453
447
|
}
|
|
454
448
|
formatTimeAgo(date, locale, fallbackLocale) {
|
|
455
449
|
// Local timestamp — not reactive state.
|
|
456
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
457
450
|
const now = new Date();
|
|
458
451
|
const seconds = Math.round((now.getTime() - date.getTime()) / 1000);
|
|
459
452
|
const minutes = Math.round(seconds / 60);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@urbicon-ui/i18n",
|
|
3
|
-
"version": "6.19.
|
|
3
|
+
"version": "6.19.2",
|
|
4
4
|
"description": "Runes-based localization for Svelte 5 apps and the Urbicon UI design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@sveltejs/package": "^2.5.8",
|
|
25
25
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
26
26
|
"@types/node": "^25.9.4",
|
|
27
|
-
"@urbicon-ui/shared-types": "6.19.
|
|
27
|
+
"@urbicon-ui/shared-types": "6.19.2",
|
|
28
28
|
"prettier": "^3.8.4",
|
|
29
29
|
"prettier-plugin-svelte": "^4.1.1",
|
|
30
30
|
"prettier-plugin-tailwindcss": "^0.8.0",
|