@urbicon-ui/i18n 6.2.0 → 6.3.3
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/components/I18nProvider.svelte.d.ts +1 -1
- package/dist/components/T.svelte.d.ts +1 -1
- package/dist/i18n/context.svelte.d.ts +1 -1
- package/dist/i18n/context.svelte.js +2 -2
- package/dist/i18n/package-integration.d.ts +1 -1
- package/dist/i18n/package-integration.js +3 -3
- package/dist/i18n/registry.svelte.d.ts +2 -2
- package/dist/i18n/registry.svelte.js +2 -2
- package/dist/i18n/resolve-locale.d.ts +1 -1
- package/dist/i18n/resolve-locale.js +2 -2
- package/dist/i18n/types.d.ts +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +6 -6
- package/package.json +5 -4
- package/dist/i18n/__fixtures__/SetLocaleChild.svelte +0 -20
- package/dist/i18n/__fixtures__/SetLocaleChild.svelte.d.ts +0 -18
- package/dist/i18n/__fixtures__/SetLocaleHarness.svelte +0 -14
- package/dist/i18n/__fixtures__/SetLocaleHarness.svelte.d.ts +0 -6
- package/dist/i18n/__fixtures__/SsrChild.svelte +0 -7
- package/dist/i18n/__fixtures__/SsrChild.svelte.d.ts +0 -18
- package/dist/i18n/__fixtures__/SsrHarness.svelte +0 -15
- package/dist/i18n/__fixtures__/SsrHarness.svelte.d.ts +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { I18nError, Locale, PluralParams, TranslationOptions, TranslationParams } from './types';
|
|
1
|
+
import type { I18nError, Locale, PluralParams, TranslationOptions, TranslationParams } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The constant base locale used for read-tolerant resolution when no
|
|
4
4
|
* `<I18nProvider>` is mounted. A constant — never global mutable state — so a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContext, hasContext, setContext, untrack } from 'svelte';
|
|
2
|
-
import { getRegistry } from './registry.svelte';
|
|
3
|
-
import { isLocaleSupported } from './types';
|
|
2
|
+
import { getRegistry } from './registry.svelte.js';
|
|
3
|
+
import { isLocaleSupported } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The constant base locale used for read-tolerant resolution when no
|
|
6
6
|
* `<I18nProvider>` is mounted. A constant — never global mutable state — so a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreatePackageTypes, Locale, PackageI18n, PackageTranslations, TranslationParams, TranslationSchema, Translations, TypedTranslationFunction } from './types';
|
|
1
|
+
import type { CreatePackageTypes, Locale, PackageI18n, PackageTranslations, TranslationParams, TranslationSchema, Translations, TypedTranslationFunction } from './types.js';
|
|
2
2
|
export interface CreatePackageI18nOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Per-locale lazy loaders (WP4 code-splitting). Each returns the package's
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { collectDeepKeys } from '../utils/deep-keys';
|
|
2
|
-
import { BASE_LOCALE, useI18nState } from './context.svelte';
|
|
3
|
-
import { getRegistry } from './registry.svelte';
|
|
1
|
+
import { collectDeepKeys } from '../utils/deep-keys.js';
|
|
2
|
+
import { BASE_LOCALE, useI18nState } from './context.svelte.js';
|
|
3
|
+
import { getRegistry } from './registry.svelte.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a standardized i18n integration for a package.
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { I18nError, Locale, PackageTranslations, PluralParams, TranslationLoader, TranslationOptions, TranslationParams, Translations } from './types';
|
|
2
|
-
import { isLocaleSupported } from './types';
|
|
1
|
+
import type { I18nError, Locale, PackageTranslations, PluralParams, TranslationLoader, TranslationOptions, TranslationParams, Translations } from './types.js';
|
|
2
|
+
import { isLocaleSupported } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Module-global translation **registry** — the static, request-identical half of
|
|
5
5
|
* the old `I18nService`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
2
|
-
import { getDeepValue } from '../utils/deep-keys';
|
|
3
|
-
import { isLocaleSupported } from './types';
|
|
2
|
+
import { getDeepValue } from '../utils/deep-keys.js';
|
|
3
|
+
import { isLocaleSupported } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Module-global translation **registry** — the static, request-identical half of
|
|
6
6
|
* the old `I18nService`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getRegistry } from './registry.svelte';
|
|
2
|
-
import { SUPPORTED_LOCALES } from './types';
|
|
1
|
+
import { getRegistry } from './registry.svelte.js';
|
|
2
|
+
import { SUPPORTED_LOCALES } from './types.js';
|
|
3
3
|
function readHeaders(source) {
|
|
4
4
|
if (typeof Request !== 'undefined' && source instanceof Request) {
|
|
5
5
|
return {
|
package/dist/i18n/types.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { I18nProvider, T } from './components';
|
|
2
|
-
export type { I18nApi, I18nConfigureOptions } from './i18n/context.svelte';
|
|
3
|
-
export { BASE_LOCALE, configureI18n, provideI18n, useI18n } from './i18n/context.svelte';
|
|
4
|
-
export type { CreatePackageI18nOptions } from './i18n/package-integration';
|
|
5
|
-
export { createComponentI18n, createPackageI18n, createPackageTranslations, createTypedPackage, registerPackages, registerTranslationLoaders, validatePackageTranslations } from './i18n/package-integration';
|
|
6
|
-
export type { LocaleSource, ResolveLocaleOptions } from './i18n/resolve-locale';
|
|
7
|
-
export { resolveLocale } from './i18n/resolve-locale';
|
|
8
|
-
export type { CreatePackageTypes, I18nComponentProps, I18nConfig, I18nError, I18nStore, Locale, PackageI18n, PackageTranslations, PluralParams, PluralRules, TranslationFunction, TranslationLoader, TranslationOptions, TranslationParams, Translations, TypedTranslationFunction } from './i18n/types';
|
|
9
|
-
export { isLocaleSupported, SUPPORTED_LOCALES } from './i18n/types';
|
|
10
|
-
export type { DeepKeys, DeepValue } from './utils/deep-keys';
|
|
11
|
-
export { collectDeepKeys, getDeepValue, hasDeepKey } from './utils/deep-keys';
|
|
1
|
+
export { I18nProvider, T } from './components/index.js';
|
|
2
|
+
export type { I18nApi, I18nConfigureOptions } from './i18n/context.svelte.js';
|
|
3
|
+
export { BASE_LOCALE, configureI18n, provideI18n, useI18n } from './i18n/context.svelte.js';
|
|
4
|
+
export type { CreatePackageI18nOptions } from './i18n/package-integration.js';
|
|
5
|
+
export { createComponentI18n, createPackageI18n, createPackageTranslations, createTypedPackage, registerPackages, registerTranslationLoaders, validatePackageTranslations } from './i18n/package-integration.js';
|
|
6
|
+
export type { LocaleSource, ResolveLocaleOptions } from './i18n/resolve-locale.js';
|
|
7
|
+
export { resolveLocale } from './i18n/resolve-locale.js';
|
|
8
|
+
export type { CreatePackageTypes, I18nComponentProps, I18nConfig, I18nError, I18nStore, Locale, PackageI18n, PackageTranslations, PluralParams, PluralRules, TranslationFunction, TranslationLoader, TranslationOptions, TranslationParams, Translations, TypedTranslationFunction } from './i18n/types.js';
|
|
9
|
+
export { isLocaleSupported, SUPPORTED_LOCALES } from './i18n/types.js';
|
|
10
|
+
export type { DeepKeys, DeepValue } from './utils/deep-keys.js';
|
|
11
|
+
export { collectDeepKeys, getDeepValue, hasDeepKey } from './utils/deep-keys.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// --- Request-scoped i18n (WP2: SSR-correct, Context-based) ---
|
|
2
2
|
// Provider + general hook: mount one <I18nProvider> at the app root, read locale
|
|
3
3
|
// control and locale-aware formatting via useI18n() inside components.
|
|
4
|
-
export { I18nProvider, T } from './components';
|
|
5
|
-
export { BASE_LOCALE, configureI18n, provideI18n, useI18n } from './i18n/context.svelte';
|
|
4
|
+
export { I18nProvider, T } from './components/index.js';
|
|
5
|
+
export { BASE_LOCALE, configureI18n, provideI18n, useI18n } from './i18n/context.svelte.js';
|
|
6
6
|
// Package integration utilities
|
|
7
|
-
export { createComponentI18n, createPackageI18n, createPackageTranslations, createTypedPackage, registerPackages, registerTranslationLoaders, validatePackageTranslations } from './i18n/package-integration';
|
|
7
|
+
export { createComponentI18n, createPackageI18n, createPackageTranslations, createTypedPackage, registerPackages, registerTranslationLoaders, validatePackageTranslations } from './i18n/package-integration.js';
|
|
8
8
|
// Server-side initial-locale resolution (cookie + Accept-Language) for the
|
|
9
9
|
// provider's `locale` prop. SSR/hydration-stable.
|
|
10
|
-
export { resolveLocale } from './i18n/resolve-locale';
|
|
10
|
+
export { resolveLocale } from './i18n/resolve-locale.js';
|
|
11
11
|
// Supported-locale list + runtime guard — single source of truth; `Locale` derives from it.
|
|
12
|
-
export { isLocaleSupported, SUPPORTED_LOCALES } from './i18n/types';
|
|
13
|
-
export { collectDeepKeys, getDeepValue, hasDeepKey } from './utils/deep-keys';
|
|
12
|
+
export { isLocaleSupported, SUPPORTED_LOCALES } from './i18n/types.js';
|
|
13
|
+
export { collectDeepKeys, getDeepValue, hasDeepKey } from './utils/deep-keys.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@urbicon-ui/i18n",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.3",
|
|
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.3",
|
|
27
|
-
"@urbicon-ui/shared-types": "6.
|
|
27
|
+
"@urbicon-ui/shared-types": "6.3.3",
|
|
28
28
|
"prettier": "^3.8.4",
|
|
29
29
|
"prettier-plugin-svelte": "^4.1.1",
|
|
30
30
|
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dist",
|
|
46
46
|
"!dist/**/*.test.*",
|
|
47
47
|
"!dist/**/*.spec.*",
|
|
48
|
+
"!dist/**/__fixtures__/**",
|
|
48
49
|
"README.md"
|
|
49
50
|
],
|
|
50
51
|
"main": "dist/index.js",
|
|
@@ -56,10 +57,10 @@
|
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
59
|
"dev": "svelte-package --watch",
|
|
59
|
-
"build": "svelte-kit sync && svelte-package",
|
|
60
|
+
"build": "svelte-kit sync && svelte-package && bun ../../scripts/complete-esm-specifiers.ts dist",
|
|
60
61
|
"clean": "rm -rf dist .svelte-kit",
|
|
61
62
|
"clean-all": "bun --bun run clean && rm -rf node_modules",
|
|
62
|
-
"package": "svelte-kit sync && svelte-package",
|
|
63
|
+
"package": "svelte-kit sync && svelte-package && bun ../../scripts/complete-esm-specifiers.ts dist",
|
|
63
64
|
"preview": "vite preview",
|
|
64
65
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
65
66
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useI18n } from '../context.svelte';
|
|
3
|
-
|
|
4
|
-
// Attempt an in-place switch during init and render the outcome. Referencing
|
|
5
|
-
// `outcome` in the markup forces the instance script to run under SSR; the IIFE
|
|
6
|
-
// keeps it a single const assignment (no reactive-update warning).
|
|
7
|
-
const i18n = useI18n();
|
|
8
|
-
const outcome = (() => {
|
|
9
|
-
try {
|
|
10
|
-
i18n.setLocale('de');
|
|
11
|
-
return 'no-error';
|
|
12
|
-
} catch (err) {
|
|
13
|
-
return err instanceof Error && /I18nProvider/.test(err.message)
|
|
14
|
-
? 'needs-provider'
|
|
15
|
-
: 'other-error';
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<span>{outcome}</span>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const SetLocaleChild: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type SetLocaleChild = InstanceType<typeof SetLocaleChild>;
|
|
18
|
-
export default SetLocaleChild;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import I18nProvider from '../../components/I18nProvider.svelte';
|
|
3
|
-
import SetLocaleChild from './SetLocaleChild.svelte';
|
|
4
|
-
|
|
5
|
-
let { provide }: { provide?: boolean } = $props();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
{#if provide}
|
|
9
|
-
<I18nProvider locale="en">
|
|
10
|
-
<SetLocaleChild />
|
|
11
|
-
</I18nProvider>
|
|
12
|
-
{:else}
|
|
13
|
-
<SetLocaleChild />
|
|
14
|
-
{/if}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const SsrChild: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type SsrChild = InstanceType<typeof SsrChild>;
|
|
18
|
-
export default SsrChild;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import I18nProvider from '../../components/I18nProvider.svelte';
|
|
3
|
-
import SsrChild from './SsrChild.svelte';
|
|
4
|
-
import type { Locale } from '../types';
|
|
5
|
-
|
|
6
|
-
let { locale }: { locale?: Locale } = $props();
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
{#if locale}
|
|
10
|
-
<I18nProvider {locale}>
|
|
11
|
-
<SsrChild />
|
|
12
|
-
</I18nProvider>
|
|
13
|
-
{:else}
|
|
14
|
-
<SsrChild />
|
|
15
|
-
{/if}
|