@r2digisolutions/ui 0.5.0 → 0.6.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.
@@ -10,8 +10,8 @@ export class StoreI18n {
10
10
  this.#translations;
11
11
  return (key, params = {}) => {
12
12
  const translations = this.#translations[this.#language];
13
- const translation = translations[key];
14
- if (!translation) {
13
+ const translation = this.#getTranslationValue(translations, key);
14
+ if (!translation || typeof translation !== "string") {
15
15
  return `--${key}--`;
16
16
  }
17
17
  return Object.entries(params).reduce((acc, [key, value]) => {
@@ -23,6 +23,13 @@ export class StoreI18n {
23
23
  this.#language = language;
24
24
  this.#translations = translations;
25
25
  }
26
+ #getTranslationValue(translations, key) {
27
+ // Intentar primero como clave plana
28
+ if (translations[key])
29
+ return translations[key];
30
+ // Si no existe como clave plana, intentar lookup recursivo
31
+ return key.split('.').reduce((acc, part) => acc?.[part], translations);
32
+ }
26
33
  get language() {
27
34
  return this.#language;
28
35
  }
@@ -1 +1,4 @@
1
- export type I18nTranslationType = Record<string, Record<string, string>>;
1
+ export type NestedTranslations = string | {
2
+ [key: string]: NestedTranslations;
3
+ };
4
+ export type I18nTranslationType = Record<string, NestedTranslations>;
package/package.json CHANGED
@@ -1,89 +1,92 @@
1
1
  {
2
- "name": "@r2digisolutions/ui",
3
- "version": "0.5.0",
4
- "private": false,
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "files": [
9
- "dist",
10
- "!dist/**/*.test.*",
11
- "!dist/**/*.spec.*"
12
- ],
13
- "sideEffects": [
14
- "**/*.css"
15
- ],
16
- "svelte": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
18
- "type": "module",
19
- "exports": {
20
- ".": {
21
- "types": "./dist/index.d.ts",
22
- "svelte": "./dist/index.js"
23
- }
24
- },
25
- "peerDependencies": {
26
- "svelte": "^5.0.0"
27
- },
28
- "devDependencies": {
29
- "@changesets/cli": "^2.29.4",
30
- "@chromatic-com/storybook": "^3.2.6",
31
- "@eslint/compat": "^1.2.9",
32
- "@playwright/test": "^1.52.0",
33
- "@storybook/addon-essentials": "^8.6.14",
34
- "@storybook/addon-interactions": "^8.6.14",
35
- "@storybook/addon-svelte-csf": "5.0.0",
36
- "@storybook/blocks": "^8.6.14",
37
- "@storybook/svelte": "^8.6.14",
38
- "@storybook/sveltekit": "^8.6.14",
39
- "@storybook/test": "^8.6.14",
40
- "@sveltejs/adapter-static": "^3.0.8",
41
- "@sveltejs/kit": "^2.21.0",
42
- "@sveltejs/package": "^2.3.11",
43
- "@sveltejs/vite-plugin-svelte": "^5.0.3",
44
- "@tailwindcss/postcss": "^4.1.7",
45
- "@vitest/browser": "^3.1.3",
46
- "changeset": "^0.2.6",
47
- "eslint": "^9.27.0",
48
- "eslint-config-prettier": "^10.1.5",
49
- "eslint-plugin-svelte": "^3.8.0",
50
- "globals": "^16.1.0",
51
- "jsdom": "^26.1.0",
52
- "prettier": "^3.5.3",
53
- "prettier-plugin-svelte": "^3.4.0",
54
- "prettier-plugin-tailwindcss": "^0.6.11",
55
- "publint": "^0.3.12",
56
- "storybook": "^8.6.14",
57
- "svelte": "^5.30.1",
58
- "svelte-check": "^4.2.1",
59
- "tailwindcss": "^4.1.7",
60
- "typescript": "^5.8.3",
61
- "typescript-eslint": "^8.32.1",
62
- "vite": "^6.3.5",
63
- "vitest": "^3.1.3"
64
- },
65
- "dependencies": {
66
- "@tailwindcss/container-queries": "^0.1.1",
67
- "@tailwindcss/forms": "^0.5.10",
68
- "@tailwindcss/typography": "^0.5.16"
69
- },
70
- "scripts": {
71
- "dev": "vite dev",
72
- "build": "vite build && npm run package",
73
- "preview": "vite preview",
74
- "package": "svelte-kit sync && svelte-package && publint",
75
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
76
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
77
- "format": "prettier --write .",
78
- "lint": "prettier --check . && eslint .",
79
- "test:unit": "vitest",
80
- "test": "npm run test:unit -- --run && npm run test:e2e",
81
- "test:e2e": "playwright test",
82
- "storybook": "storybook dev -p 6006",
83
- "build-storybook": "storybook build",
84
- "changeset": "changeset",
85
- "changeset:publish": "changeset publish",
86
- "changeset:version": "changeset version",
87
- "ci:publish": "changeset:publish && npm publish"
88
- }
89
- }
2
+ "name": "@r2digisolutions/ui",
3
+ "version": "0.6.0",
4
+ "private": false,
5
+ "packageManager": "bun@1.2.8",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "dev": "vite dev",
11
+ "build": "vite build && npm run package",
12
+ "preview": "vite preview",
13
+ "package": "svelte-kit sync && svelte-package && publint",
14
+ "prepublishOnly": "npm run package",
15
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
16
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
17
+ "format": "prettier --write .",
18
+ "lint": "prettier --check . && eslint .",
19
+ "test:unit": "vitest",
20
+ "test": "npm run test:unit -- --run && npm run test:e2e",
21
+ "test:e2e": "playwright test",
22
+ "storybook": "storybook dev -p 6006",
23
+ "build-storybook": "storybook build",
24
+ "changeset": "changeset",
25
+ "changeset:publish": "changeset publish",
26
+ "changeset:version": "changeset version",
27
+ "ci:publish": "changeset:publish && npm publish"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "!dist/**/*.test.*",
32
+ "!dist/**/*.spec.*"
33
+ ],
34
+ "sideEffects": [
35
+ "**/*.css"
36
+ ],
37
+ "svelte": "./dist/index.js",
38
+ "types": "./dist/index.d.ts",
39
+ "type": "module",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "svelte": "./dist/index.js"
44
+ }
45
+ },
46
+ "peerDependencies": {
47
+ "svelte": "^5.0.0"
48
+ },
49
+ "devDependencies": {
50
+ "@changesets/cli": "^2.29.4",
51
+ "@chromatic-com/storybook": "^3.2.6",
52
+ "@eslint/compat": "^1.2.9",
53
+ "@playwright/test": "^1.52.0",
54
+ "@storybook/addon-essentials": "^8.6.14",
55
+ "@storybook/addon-interactions": "^8.6.14",
56
+ "@storybook/addon-svelte-csf": "5.0.0",
57
+ "@storybook/blocks": "^8.6.14",
58
+ "@storybook/svelte": "^8.6.14",
59
+ "@storybook/sveltekit": "^8.6.14",
60
+ "@storybook/test": "^8.6.14",
61
+ "@sveltejs/adapter-static": "^3.0.8",
62
+ "@sveltejs/kit": "^2.21.0",
63
+ "@sveltejs/package": "^2.3.11",
64
+ "@sveltejs/vite-plugin-svelte": "^5.0.3",
65
+ "@tailwindcss/postcss": "^4.1.7",
66
+ "@vitest/browser": "^3.1.3",
67
+ "changeset": "^0.2.6",
68
+ "eslint": "^9.27.0",
69
+ "eslint-config-prettier": "^10.1.5",
70
+ "eslint-plugin-svelte": "^3.8.0",
71
+ "globals": "^16.1.0",
72
+ "jsdom": "^26.1.0",
73
+ "lucide-svelte": "^0.511.0",
74
+ "prettier": "^3.5.3",
75
+ "prettier-plugin-svelte": "^3.4.0",
76
+ "prettier-plugin-tailwindcss": "^0.6.11",
77
+ "publint": "^0.3.12",
78
+ "storybook": "^8.6.14",
79
+ "svelte": "^5.30.1",
80
+ "svelte-check": "^4.2.1",
81
+ "tailwindcss": "^4.1.7",
82
+ "typescript": "^5.8.3",
83
+ "typescript-eslint": "^8.32.1",
84
+ "vite": "^6.3.5",
85
+ "vitest": "^3.1.3"
86
+ },
87
+ "dependencies": {
88
+ "@tailwindcss/container-queries": "^0.1.1",
89
+ "@tailwindcss/forms": "^0.5.10",
90
+ "@tailwindcss/typography": "^0.5.16"
91
+ }
92
+ }