@sveltia/ui 0.41.5 → 0.42.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/components/util/app-shell.svelte +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -4
- package/dist/services/i18n.d.ts +6 -0
- package/dist/services/i18n.js +19 -14
- package/package.json +20 -20
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
import { onMount } from 'svelte';
|
|
9
|
+
import { initLocales } from '../../services/i18n';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @import { Snippet } from 'svelte';
|
|
@@ -38,6 +39,10 @@
|
|
|
38
39
|
|
|
39
40
|
let fontLoaded = $state(false);
|
|
40
41
|
|
|
42
|
+
$effect.pre(() => {
|
|
43
|
+
initLocales();
|
|
44
|
+
});
|
|
45
|
+
|
|
41
46
|
onMount(() => {
|
|
42
47
|
const mediaQuery = globalThis.matchMedia('(prefers-color-scheme: dark)');
|
|
43
48
|
const { dataset } = document.documentElement;
|
package/dist/index.d.ts
CHANGED
|
@@ -78,3 +78,4 @@ export { default as EmptyState } from "./components/util/empty-state.svelte";
|
|
|
78
78
|
export { default as Group } from "./components/util/group.svelte";
|
|
79
79
|
export { default as Modal } from "./components/util/modal.svelte";
|
|
80
80
|
export * from "./typedefs.js";
|
|
81
|
+
export { initLocales, resources } from "./services/i18n.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { initLocales } from './services/i18n.js';
|
|
2
|
-
|
|
3
|
-
initLocales();
|
|
4
|
-
|
|
5
1
|
export { default as Alert } from './components/alert/alert.svelte';
|
|
6
2
|
export { default as Infobar } from './components/alert/infobar.svelte';
|
|
7
3
|
export { default as BottomNavigation } from './components/bottom-navigation/bottom-navigation.svelte';
|
|
@@ -81,6 +77,7 @@ export { default as AppShell } from './components/util/app-shell.svelte';
|
|
|
81
77
|
export { default as EmptyState } from './components/util/empty-state.svelte';
|
|
82
78
|
export { default as Group } from './components/util/group.svelte';
|
|
83
79
|
export { default as Modal } from './components/util/modal.svelte';
|
|
80
|
+
export { initLocales, resources } from './services/i18n.js';
|
|
84
81
|
|
|
85
82
|
// eslint-disable-next-line import/export
|
|
86
83
|
export * from './typedefs.js';
|
package/dist/services/i18n.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object containing all the locale resources, with the locale names as keys and the corresponding
|
|
3
|
+
* strings as values.
|
|
4
|
+
* @type {Record<string, Record<string, string>>}
|
|
5
|
+
*/
|
|
6
|
+
export const resources: Record<string, Record<string, string>>;
|
|
1
7
|
export function initLocales({ fallbackLocale, initialLocale }?: {
|
|
2
8
|
fallbackLocale?: string | undefined;
|
|
3
9
|
initialLocale?: string | undefined;
|
package/dist/services/i18n.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { addMessages, init } from '@sveltia/i18n';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const rawResources = import.meta.glob('../locales/*.yaml', { eager: true, import: 'default' });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Object containing all the locale resources, with the locale names as keys and the corresponding
|
|
7
|
+
* strings as values.
|
|
8
|
+
* @type {Record<string, Record<string, string>>}
|
|
9
|
+
*/
|
|
10
|
+
export const resources = Object.fromEntries(
|
|
11
|
+
Object.entries(rawResources).map(([path, resource]) => [
|
|
12
|
+
/** @type {string} */ (path.match(/.+\/(?<locale>.+?)\.yaml$/)?.groups?.locale),
|
|
13
|
+
/** @type {Record<string, string>} */ (resource),
|
|
14
|
+
]),
|
|
15
|
+
);
|
|
3
16
|
|
|
4
17
|
/**
|
|
5
|
-
* Load strings and initialize the locales.
|
|
18
|
+
* Load strings and initialize the locales. Consumers can use this function to load the localized
|
|
19
|
+
* strings for their application. If `<AppShell>` is used, this function is called automatically.
|
|
6
20
|
* @param {object} [init] Initialize options.
|
|
7
21
|
* @param {string} [init.fallbackLocale] Fallback locale.
|
|
8
22
|
* @param {string} [init.initialLocale] Initial locale.
|
|
@@ -10,18 +24,9 @@ import { parse as parseYaml } from 'yaml';
|
|
|
10
24
|
* @see https://vitejs.dev/guide/features.html#glob-import
|
|
11
25
|
*/
|
|
12
26
|
export const initLocales = ({ fallbackLocale = 'en', initialLocale = 'en' } = {}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import: 'default',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.entries(resources).forEach(([path, resource]) => {
|
|
20
|
-
addMessages(
|
|
21
|
-
/** @type {string} */ (path.match(/.+\/(?<locale>.+?)\.yaml$/)?.groups?.locale),
|
|
22
|
-
// Add `_sui` suffix to avoid collision with app localization
|
|
23
|
-
{ _sui: parseYaml(/** @type {string} */ (resource)) },
|
|
24
|
-
);
|
|
27
|
+
Object.entries(resources).forEach(([locale, resource]) => {
|
|
28
|
+
// Add `_sui` suffix to avoid collision with app localization
|
|
29
|
+
addMessages(locale, { _sui: resource });
|
|
25
30
|
});
|
|
26
31
|
|
|
27
32
|
init({ fallbackLocale, initialLocale });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "A collection of Svelte components and utilities for building user interfaces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,36 +33,36 @@
|
|
|
33
33
|
"!dist/**/*.test.*"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lexical/code": "^0.
|
|
37
|
-
"@lexical/code-prism": "^0.
|
|
38
|
-
"@lexical/dragon": "^0.
|
|
39
|
-
"@lexical/extension": "^0.
|
|
40
|
-
"@lexical/history": "^0.
|
|
41
|
-
"@lexical/link": "^0.
|
|
42
|
-
"@lexical/list": "^0.
|
|
43
|
-
"@lexical/markdown": "^0.
|
|
44
|
-
"@lexical/rich-text": "^0.
|
|
45
|
-
"@lexical/selection": "^0.
|
|
46
|
-
"@lexical/table": "^0.
|
|
47
|
-
"@lexical/utils": "^0.
|
|
36
|
+
"@lexical/code": "^0.47.0",
|
|
37
|
+
"@lexical/code-prism": "^0.47.0",
|
|
38
|
+
"@lexical/dragon": "^0.47.0",
|
|
39
|
+
"@lexical/extension": "^0.47.0",
|
|
40
|
+
"@lexical/history": "^0.47.0",
|
|
41
|
+
"@lexical/link": "^0.47.0",
|
|
42
|
+
"@lexical/list": "^0.47.0",
|
|
43
|
+
"@lexical/markdown": "^0.47.0",
|
|
44
|
+
"@lexical/rich-text": "^0.47.0",
|
|
45
|
+
"@lexical/selection": "^0.47.0",
|
|
46
|
+
"@lexical/table": "^0.47.0",
|
|
47
|
+
"@lexical/utils": "^0.47.0",
|
|
48
48
|
"@sveltia/i18n": "^1.1.2",
|
|
49
49
|
"@sveltia/utils": "^0.10.7",
|
|
50
|
-
"lexical": "^0.
|
|
51
|
-
"prismjs": "^1.30.0"
|
|
52
|
-
"yaml": "^2.9.0"
|
|
50
|
+
"lexical": "^0.47.0",
|
|
51
|
+
"prismjs": "^1.30.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
54
|
+
"@rollup/plugin-yaml": "^5.0.0",
|
|
55
55
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
56
56
|
"@sveltejs/kit": "^2.69.2",
|
|
57
57
|
"@sveltejs/package": "^2.5.8",
|
|
58
58
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
59
59
|
"@vitest/coverage-v8": "^4.1.10",
|
|
60
60
|
"cspell": "^10.0.1",
|
|
61
|
-
"eslint": "^9.39.
|
|
61
|
+
"eslint": "^9.39.5",
|
|
62
62
|
"eslint-config-airbnb-extended": "^3.1.0",
|
|
63
63
|
"eslint-config-prettier": "^10.1.8",
|
|
64
64
|
"eslint-plugin-import": "^2.32.0",
|
|
65
|
-
"eslint-plugin-jsdoc": "^63.0.
|
|
65
|
+
"eslint-plugin-jsdoc": "^63.0.13",
|
|
66
66
|
"eslint-plugin-package-json": "^1.5.0",
|
|
67
67
|
"eslint-plugin-svelte": "^3.20.0",
|
|
68
68
|
"globals": "^17.7.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"oxlint": "^1.73.0",
|
|
71
71
|
"postcss": "^8.5.16",
|
|
72
72
|
"postcss-html": "^1.8.1",
|
|
73
|
-
"prettier": "^3.9.
|
|
73
|
+
"prettier": "^3.9.5",
|
|
74
74
|
"prettier-plugin-svelte": "^4.1.1",
|
|
75
75
|
"sass": "^1.101.0",
|
|
76
76
|
"stylelint": "^17.14.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"svelte-check": "^4.7.2",
|
|
81
81
|
"svelte-preprocess": "^6.0.5",
|
|
82
82
|
"tslib": "^2.8.1",
|
|
83
|
-
"vite": "^8.1.
|
|
83
|
+
"vite": "^8.1.4",
|
|
84
84
|
"vitest": "^4.1.10"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|