astro-intl 2.0.3 → 2.2.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.
- package/README.md +701 -701
- package/dist/__tests__/config-messages.test.js +42 -2
- package/dist/__tests__/core.test.js +90 -2
- package/dist/__tests__/fallback-routes.test.d.ts +1 -0
- package/dist/__tests__/fallback-routes.test.js +42 -0
- package/dist/__tests__/integration.test.js +14 -3
- package/dist/components/AutoRedirect.astro +31 -0
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +43 -2
- package/dist/middleware.js +3 -1
- package/dist/store.d.ts +3 -1
- package/dist/store.js +91 -50
- package/dist/translations.d.ts +1 -0
- package/dist/translations.js +4 -1
- package/dist/types/index.d.ts +10 -0
- package/package.json +102 -99
package/dist/translations.js
CHANGED
|
@@ -9,6 +9,9 @@ export function getTranslations(namespace) {
|
|
|
9
9
|
const str = typeof value === "string" ? value : key;
|
|
10
10
|
return interpolateValues(str, values);
|
|
11
11
|
}
|
|
12
|
+
function raw(key) {
|
|
13
|
+
return getNestedValue(messages, key);
|
|
14
|
+
}
|
|
12
15
|
const markup = function (key, options) {
|
|
13
16
|
const isOptionsObject = "tags" in options && typeof options.tags === "object";
|
|
14
17
|
const tags = isOptionsObject
|
|
@@ -28,6 +31,6 @@ export function getTranslations(namespace) {
|
|
|
28
31
|
str = sanitizeHtml(str);
|
|
29
32
|
return str;
|
|
30
33
|
};
|
|
31
|
-
Object.assign(t, { markup });
|
|
34
|
+
Object.assign(t, { markup, raw });
|
|
32
35
|
return t;
|
|
33
36
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export type GetRequestConfigFn = (locale: string) => Promise<RequestConfig> | Re
|
|
|
7
7
|
export type MessagesConfig = Record<string, Record<string, unknown> | (() => Promise<{
|
|
8
8
|
default: Record<string, unknown>;
|
|
9
9
|
} | Record<string, unknown>>)>;
|
|
10
|
+
export type MessagesDirConfig = {
|
|
11
|
+
/** Directory path containing locale JSON files (e.g., "./src/i18n/messages") */
|
|
12
|
+
dir: string;
|
|
13
|
+
};
|
|
10
14
|
export type RoutesMap = {
|
|
11
15
|
[routeKey: string]: {
|
|
12
16
|
[locale: string]: string;
|
|
@@ -14,8 +18,14 @@ export type RoutesMap = {
|
|
|
14
18
|
};
|
|
15
19
|
export type ExtractParams<T extends string> = T extends `${string}[${infer P}]${infer Rest}` ? P | ExtractParams<Rest> : never;
|
|
16
20
|
export type ParamsForRoute<Template extends string> = [ExtractParams<Template>] extends [never] ? Record<string, never> : Record<ExtractParams<Template>, string>;
|
|
21
|
+
export type FallbackRouteInfo = {
|
|
22
|
+
pattern: string;
|
|
23
|
+
pathname?: string;
|
|
24
|
+
locale: string;
|
|
25
|
+
};
|
|
17
26
|
export type IntlConfig = {
|
|
18
27
|
defaultLocale: string;
|
|
19
28
|
locales: string[];
|
|
20
29
|
routes?: RoutesMap;
|
|
30
|
+
fallbackRoutes?: FallbackRouteInfo[];
|
|
21
31
|
};
|
package/package.json
CHANGED
|
@@ -1,99 +1,102 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "astro-intl",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "
|
|
6
|
-
"keywords": [
|
|
7
|
-
"astro",
|
|
8
|
-
"astro-integration",
|
|
9
|
-
"astro-component",
|
|
10
|
-
"withastro",
|
|
11
|
-
"i18n",
|
|
12
|
-
"internationalization",
|
|
13
|
-
"intl",
|
|
14
|
-
"translations",
|
|
15
|
-
"typescript",
|
|
16
|
-
"accessibility",
|
|
17
|
-
"a11y"
|
|
18
|
-
],
|
|
19
|
-
"author": "Erick Cruz <erickj.cruzs@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest",
|
|
24
|
-
"test:ui": "vitest --ui",
|
|
25
|
-
"test:coverage": "vitest run --coverage",
|
|
26
|
-
"build": "tsc -p tsconfig.json",
|
|
27
|
-
"dev": "tsc -p tsconfig.json --watch",
|
|
28
|
-
"lint": "eslint . --max-warnings 0",
|
|
29
|
-
"lint:fix": "eslint . --fix",
|
|
30
|
-
"format": "prettier --write .",
|
|
31
|
-
"format:check": "prettier --check ."
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
],
|
|
36
|
-
"main": "./dist/index.js",
|
|
37
|
-
"types": "./dist/index.d.ts",
|
|
38
|
-
"exports": {
|
|
39
|
-
".": {
|
|
40
|
-
"types": "./dist/index.d.ts",
|
|
41
|
-
"import": "./dist/index.js"
|
|
42
|
-
},
|
|
43
|
-
"./middleware": {
|
|
44
|
-
"types": "./dist/middleware.d.ts",
|
|
45
|
-
"import": "./dist/middleware.js"
|
|
46
|
-
},
|
|
47
|
-
"./react": {
|
|
48
|
-
"types": "./dist/adapters/react.d.ts",
|
|
49
|
-
"import": "./dist/adapters/react.js"
|
|
50
|
-
},
|
|
51
|
-
"./svelte": {
|
|
52
|
-
"types": "./dist/adapters/svelte.d.ts",
|
|
53
|
-
"import": "./dist/adapters/svelte.js"
|
|
54
|
-
},
|
|
55
|
-
"./routing": {
|
|
56
|
-
"types": "./dist/routing.d.ts",
|
|
57
|
-
"import": "./dist/routing.js"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"optional": true
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"url": "https://github.com/ErickCSS/astro-intl
|
|
77
|
-
},
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"@
|
|
87
|
-
"@
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "astro-intl",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Sistema de internacionalización simple y type-safe para Astro.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"astro",
|
|
8
|
+
"astro-integration",
|
|
9
|
+
"astro-component",
|
|
10
|
+
"withastro",
|
|
11
|
+
"i18n",
|
|
12
|
+
"internationalization",
|
|
13
|
+
"intl",
|
|
14
|
+
"translations",
|
|
15
|
+
"typescript",
|
|
16
|
+
"accessibility",
|
|
17
|
+
"a11y"
|
|
18
|
+
],
|
|
19
|
+
"author": "Erick Cruz <erickj.cruzs@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"test:ui": "vitest --ui",
|
|
25
|
+
"test:coverage": "vitest run --coverage",
|
|
26
|
+
"build": "tsc -p tsconfig.json",
|
|
27
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
28
|
+
"lint": "eslint . --max-warnings 0",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"format": "prettier --write .",
|
|
31
|
+
"format:check": "prettier --check ."
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./middleware": {
|
|
44
|
+
"types": "./dist/middleware.d.ts",
|
|
45
|
+
"import": "./dist/middleware.js"
|
|
46
|
+
},
|
|
47
|
+
"./react": {
|
|
48
|
+
"types": "./dist/adapters/react.d.ts",
|
|
49
|
+
"import": "./dist/adapters/react.js"
|
|
50
|
+
},
|
|
51
|
+
"./svelte": {
|
|
52
|
+
"types": "./dist/adapters/svelte.d.ts",
|
|
53
|
+
"import": "./dist/adapters/svelte.js"
|
|
54
|
+
},
|
|
55
|
+
"./routing": {
|
|
56
|
+
"types": "./dist/routing.d.ts",
|
|
57
|
+
"import": "./dist/routing.js"
|
|
58
|
+
},
|
|
59
|
+
"./components": {
|
|
60
|
+
"import": "./dist/components/AutoRedirect.astro"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"astro": "^4 || ^5 || ^6"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"react": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"svelte": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"repository": {
|
|
75
|
+
"type": "git",
|
|
76
|
+
"url": "https://github.com/ErickCSS/astro-intl"
|
|
77
|
+
},
|
|
78
|
+
"bugs": {
|
|
79
|
+
"url": "https://github.com/ErickCSS/astro-intl/issues"
|
|
80
|
+
},
|
|
81
|
+
"homepage": "https://github.com/ErickCSS/astro-intl#readme",
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@eslint/js": "^9.39.4",
|
|
87
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
88
|
+
"@testing-library/react": "^16.3.2",
|
|
89
|
+
"@types/react": "^18.3.28",
|
|
90
|
+
"@vitest/ui": "^4.1.2",
|
|
91
|
+
"astro": "^6.1.2",
|
|
92
|
+
"eslint": "^9.39.4",
|
|
93
|
+
"happy-dom": "^20.8.9",
|
|
94
|
+
"prettier": "^3.8.1",
|
|
95
|
+
"react": "^19.2.4",
|
|
96
|
+
"react-dom": "^19.2.4",
|
|
97
|
+
"svelte": "^5.55.1",
|
|
98
|
+
"typescript": "^5.9.3",
|
|
99
|
+
"typescript-eslint": "^8.58.0",
|
|
100
|
+
"vitest": "^4.1.2"
|
|
101
|
+
}
|
|
102
|
+
}
|