@dialpad/i18n 1.22.3 → 1.24.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/bin/force-pull-translations.js +2 -0
- package/bin/pull-translations.js +2 -0
- package/bin/should-pull.js +2 -0
- package/bin/translate-dialpadistan.js +2 -0
- package/bin/translation-screenshots-check.js +2 -0
- package/bin/upload-translation-service.js +2 -0
- package/dist/i18n.cjs +883 -878
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.js +883 -878
- package/dist/i18n.js.map +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +1 -2
- package/{README.md → docs/README.md} +280 -84
- package/index.ts +18 -5
- package/package.json +50 -26
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -12
- package/.prettierignore +0 -3
- package/.rush/temp/chunked-rush-logs/i18n.build.chunks.jsonl +0 -22
- package/.rush/temp/chunked-rush-logs/i18n.format.chunks.jsonl +0 -19
- package/.rush/temp/chunked-rush-logs/i18n.lint.chunks.jsonl +0 -2
- package/.rush/temp/package-deps_build.json +0 -24
- package/.rush/temp/package-deps_format.json +0 -24
- package/.rush/temp/package-deps_lint.json +0 -24
- package/.rush/temp/shrinkwrap-deps.json +0 -12
- package/CHANGELOG.json +0 -63
- package/CHANGELOG.md +0 -30
- package/base-tsconfig.json +0 -19
- package/dialpad-i18n-1.22.2.tgz +0 -0
- package/dist/types/src/locale-manager.d.ts +0 -53
- package/dist/types/src/locale-manager.js +0 -146
- package/eslint-tsconfig.json +0 -5
- package/index.html +0 -11
- package/rush-logs/i18n.build.error.log +0 -0
- package/rush-logs/i18n.build.log +0 -22
- package/rush-logs/i18n.format.error.log +0 -0
- package/rush-logs/i18n.format.log +0 -19
- package/rush-logs/i18n.lint.error.log +0 -0
- package/rush-logs/i18n.lint.log +0 -2
- package/src/__test__/locale-manager.find.test.ts +0 -78
- package/src/__test__/locale-manager.formatters.test.ts +0 -139
- package/src/__test__/locale-manager.multiple.test.ts +0 -349
- package/src/__test__/locale-manager.test.ts +0 -511
- package/src/locale-manager.ts +0 -198
- package/tsconfig.json +0 -10
- package/vite.config.ts +0 -39
package/.prettierignore
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{"kind":"O","text":"Invoking: run-p build:* \n"}
|
|
2
|
-
{"kind":"O","text":"\n"}
|
|
3
|
-
{"kind":"O","text":"> @dialpad/i18n@1.22.1 build:types\n"}
|
|
4
|
-
{"kind":"O","text":"> rushx types:build\n"}
|
|
5
|
-
{"kind":"O","text":"\n"}
|
|
6
|
-
{"kind":"O","text":"\n"}
|
|
7
|
-
{"kind":"O","text":"> @dialpad/i18n@1.22.1 build:main\n"}
|
|
8
|
-
{"kind":"O","text":"> vite build --config vite.config.ts\n"}
|
|
9
|
-
{"kind":"O","text":"\n"}
|
|
10
|
-
{"kind":"O","text":"vite v5.4.19 building for production...\n"}
|
|
11
|
-
{"kind":"O","text":"transforming...\n"}
|
|
12
|
-
{"kind":"O","text":"Found configuration in /Users/daniellovero/src/wcf-sdk/rush.json\n"}
|
|
13
|
-
{"kind":"O","text":"\n"}
|
|
14
|
-
{"kind":"O","text":"\u001b[1mRush Multi-Project Build Tool 5.139.0\u001b[33m\u001b[39m\u001b[22m - Node.js 20.14.0 (LTS)\n"}
|
|
15
|
-
{"kind":"O","text":"> \"tsc\"\n"}
|
|
16
|
-
{"kind":"O","text":"\n"}
|
|
17
|
-
{"kind":"O","text":"✓ 30 modules transformed.\n"}
|
|
18
|
-
{"kind":"O","text":"rendering chunks...\n"}
|
|
19
|
-
{"kind":"O","text":"computing gzip size...\n"}
|
|
20
|
-
{"kind":"O","text":"dist/i18n.js 209.99 kB │ gzip: 49.06 kB │ map: 511.23 kB\n"}
|
|
21
|
-
{"kind":"O","text":"dist/i18n.cjs 210.17 kB │ gzip: 49.11 kB │ map: 511.47 kB\n"}
|
|
22
|
-
{"kind":"O","text":"✓ built in 806ms\n"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{"kind":"O","text":"Invoking: prettier ./ --write \n"}
|
|
2
|
-
{"kind":"O","text":".eslintrc.cjs 27ms\n"}
|
|
3
|
-
{"kind":"O","text":".rush/temp/package-deps_build.json 3ms\n"}
|
|
4
|
-
{"kind":"O","text":".rush/temp/package-deps_format.json 3ms\n"}
|
|
5
|
-
{"kind":"O","text":".rush/temp/shrinkwrap-deps.json 1ms\n"}
|
|
6
|
-
{"kind":"O","text":"base-tsconfig.json 4ms\n"}
|
|
7
|
-
{"kind":"O","text":"CHANGELOG.json 2ms\n"}
|
|
8
|
-
{"kind":"O","text":"eslint-tsconfig.json 1ms\n"}
|
|
9
|
-
{"kind":"O","text":"index.html 16ms\n"}
|
|
10
|
-
{"kind":"O","text":"index.ts 80ms\n"}
|
|
11
|
-
{"kind":"O","text":"package.json 4ms\n"}
|
|
12
|
-
{"kind":"O","text":"README.md 131ms\n"}
|
|
13
|
-
{"kind":"O","text":"src/__test__/locale-manager.find.test.ts 10ms\n"}
|
|
14
|
-
{"kind":"O","text":"src/__test__/locale-manager.formatters.test.ts 15ms\n"}
|
|
15
|
-
{"kind":"O","text":"src/__test__/locale-manager.multiple.test.ts 28ms\n"}
|
|
16
|
-
{"kind":"O","text":"src/__test__/locale-manager.test.ts 40ms\n"}
|
|
17
|
-
{"kind":"O","text":"src/locale-manager.ts 12ms\n"}
|
|
18
|
-
{"kind":"O","text":"tsconfig.json 2ms\n"}
|
|
19
|
-
{"kind":"O","text":"vite.config.ts 3ms\n"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/i18n/.eslintignore": "1521c8b7652b1eec8ed4fe50877aae880c758ee3",
|
|
4
|
-
"packages/i18n/.eslintrc.cjs": "1eca07632b4762f57e40cccd4b808bc18c884601",
|
|
5
|
-
"packages/i18n/.prettierignore": "f9bf3e12a0286559870c1b9dd351fced90e4453a",
|
|
6
|
-
"packages/i18n/.rush/temp/shrinkwrap-deps.json": "4d71ae7fe68e4292ec72b5f42fdbde7ebfa0f2ec",
|
|
7
|
-
"packages/i18n/CHANGELOG.json": "639da276884d23093f9215dd9df604f61ca7ea1a",
|
|
8
|
-
"packages/i18n/CHANGELOG.md": "e8be4693d4e354020ef8ce269e04bb2007d8d9ca",
|
|
9
|
-
"packages/i18n/README.md": "b59c69396aff68a5b98e872d9f4be9f44ae48886",
|
|
10
|
-
"packages/i18n/base-tsconfig.json": "e4ff7f322e6888e7347ef42d468b717928d9cf3d",
|
|
11
|
-
"packages/i18n/eslint-tsconfig.json": "689b2ed5a1dad17383d038ba1f7c434f6dfe2448",
|
|
12
|
-
"packages/i18n/index.html": "0ac726f481ef9093213d67a9e2176be12da9abc7",
|
|
13
|
-
"packages/i18n/index.ts": "e5271326e515dea0105fa4bc9aa4e3072fda8fa8",
|
|
14
|
-
"packages/i18n/package.json": "96f41052e895ce6fc5bfb06420a8d22a6daddacc",
|
|
15
|
-
"packages/i18n/src/__test__/locale-manager.find.test.ts": "700205de770e909c3b0b18854c1d460ec4dbb2c4",
|
|
16
|
-
"packages/i18n/src/__test__/locale-manager.formatters.test.ts": "47b3077e0441472c04ada1f3e82939b5c8dd77da",
|
|
17
|
-
"packages/i18n/src/__test__/locale-manager.multiple.test.ts": "3209b4134a45132ba045b0c8e04163f90abb00d1",
|
|
18
|
-
"packages/i18n/src/__test__/locale-manager.test.ts": "36a3ac02ce76c125ad546f6195f9949d017a9c2e",
|
|
19
|
-
"packages/i18n/src/locale-manager.ts": "4ae53527d22a23ad0af88e4813d9391ea6eb8adf",
|
|
20
|
-
"packages/i18n/tsconfig.json": "b0fc97224f5467ae8f83e9301e826eda5ef8b1c6",
|
|
21
|
-
"packages/i18n/vite.config.ts": "7f0701b5913cbec70bde2530c1d6bb0d1f17216d"
|
|
22
|
-
},
|
|
23
|
-
"arguments": "run-p build:* "
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/i18n/.eslintignore": "1521c8b7652b1eec8ed4fe50877aae880c758ee3",
|
|
4
|
-
"packages/i18n/.eslintrc.cjs": "1eca07632b4762f57e40cccd4b808bc18c884601",
|
|
5
|
-
"packages/i18n/.prettierignore": "f9bf3e12a0286559870c1b9dd351fced90e4453a",
|
|
6
|
-
"packages/i18n/.rush/temp/shrinkwrap-deps.json": "fe14fa042556f6d48e7eaa5525661ec58f77941b",
|
|
7
|
-
"packages/i18n/CHANGELOG.json": "639da276884d23093f9215dd9df604f61ca7ea1a",
|
|
8
|
-
"packages/i18n/CHANGELOG.md": "e8be4693d4e354020ef8ce269e04bb2007d8d9ca",
|
|
9
|
-
"packages/i18n/README.md": "ccab724d6b7c5304790e52bbed87b7415b4ad15f",
|
|
10
|
-
"packages/i18n/base-tsconfig.json": "e4ff7f322e6888e7347ef42d468b717928d9cf3d",
|
|
11
|
-
"packages/i18n/eslint-tsconfig.json": "689b2ed5a1dad17383d038ba1f7c434f6dfe2448",
|
|
12
|
-
"packages/i18n/index.html": "0ac726f481ef9093213d67a9e2176be12da9abc7",
|
|
13
|
-
"packages/i18n/index.ts": "e5271326e515dea0105fa4bc9aa4e3072fda8fa8",
|
|
14
|
-
"packages/i18n/package.json": "081673c47c47ed17646d4ea39fa0c3c105b7482c",
|
|
15
|
-
"packages/i18n/src/__test__/locale-manager.find.test.ts": "700205de770e909c3b0b18854c1d460ec4dbb2c4",
|
|
16
|
-
"packages/i18n/src/__test__/locale-manager.formatters.test.ts": "47b3077e0441472c04ada1f3e82939b5c8dd77da",
|
|
17
|
-
"packages/i18n/src/__test__/locale-manager.multiple.test.ts": "3209b4134a45132ba045b0c8e04163f90abb00d1",
|
|
18
|
-
"packages/i18n/src/__test__/locale-manager.test.ts": "36a3ac02ce76c125ad546f6195f9949d017a9c2e",
|
|
19
|
-
"packages/i18n/src/locale-manager.ts": "76d269964cb339af0609a5dd41a5dbf68376c26b",
|
|
20
|
-
"packages/i18n/tsconfig.json": "b0fc97224f5467ae8f83e9301e826eda5ef8b1c6",
|
|
21
|
-
"packages/i18n/vite.config.ts": "7f0701b5913cbec70bde2530c1d6bb0d1f17216d"
|
|
22
|
-
},
|
|
23
|
-
"arguments": "prettier ./ --write "
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/i18n/.eslintignore": "1521c8b7652b1eec8ed4fe50877aae880c758ee3",
|
|
4
|
-
"packages/i18n/.eslintrc.cjs": "1eca07632b4762f57e40cccd4b808bc18c884601",
|
|
5
|
-
"packages/i18n/.prettierignore": "f9bf3e12a0286559870c1b9dd351fced90e4453a",
|
|
6
|
-
"packages/i18n/.rush/temp/shrinkwrap-deps.json": "fe14fa042556f6d48e7eaa5525661ec58f77941b",
|
|
7
|
-
"packages/i18n/CHANGELOG.json": "07cfd686ea54acf3207a34c390d71453f582fa76",
|
|
8
|
-
"packages/i18n/CHANGELOG.md": "b53dc872100344d1b67d779d214bb943312b1d94",
|
|
9
|
-
"packages/i18n/README.md": "ccab724d6b7c5304790e52bbed87b7415b4ad15f",
|
|
10
|
-
"packages/i18n/base-tsconfig.json": "e4ff7f322e6888e7347ef42d468b717928d9cf3d",
|
|
11
|
-
"packages/i18n/eslint-tsconfig.json": "689b2ed5a1dad17383d038ba1f7c434f6dfe2448",
|
|
12
|
-
"packages/i18n/index.html": "0ac726f481ef9093213d67a9e2176be12da9abc7",
|
|
13
|
-
"packages/i18n/index.ts": "e5271326e515dea0105fa4bc9aa4e3072fda8fa8",
|
|
14
|
-
"packages/i18n/package.json": "03cb72e387e3699f03f60b09bb3930299280c1e8",
|
|
15
|
-
"packages/i18n/src/__test__/locale-manager.find.test.ts": "700205de770e909c3b0b18854c1d460ec4dbb2c4",
|
|
16
|
-
"packages/i18n/src/__test__/locale-manager.formatters.test.ts": "47b3077e0441472c04ada1f3e82939b5c8dd77da",
|
|
17
|
-
"packages/i18n/src/__test__/locale-manager.multiple.test.ts": "3209b4134a45132ba045b0c8e04163f90abb00d1",
|
|
18
|
-
"packages/i18n/src/__test__/locale-manager.test.ts": "36a3ac02ce76c125ad546f6195f9949d017a9c2e",
|
|
19
|
-
"packages/i18n/src/locale-manager.ts": "a4105f44026e7ea388d5335f72084729e73ca835",
|
|
20
|
-
"packages/i18n/tsconfig.json": "b0fc97224f5467ae8f83e9301e826eda5ef8b1c6",
|
|
21
|
-
"packages/i18n/vite.config.ts": "7f0701b5913cbec70bde2530c1d6bb0d1f17216d"
|
|
22
|
-
},
|
|
23
|
-
"arguments": "echo 'needs migration to use @dialpad/eslint-config' "
|
|
24
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"../../packages/i18n": "../../packages/i18n:xBqNbzBtZNhESpaPNxV2/iJMZoT8+3/v6QegKZ0mfU8=:",
|
|
3
|
-
"/@vitejs/plugin-vue@5.1.5(vite@5.4.19(@types/node@24.3.0))(vue@3.5.20(typescript@5.6.3))": "Missing shrinkwrap entry!",
|
|
4
|
-
"/eslint@9.13.0": "Missing shrinkwrap entry!",
|
|
5
|
-
"/npm-run-all@4.1.5": "Missing shrinkwrap entry!",
|
|
6
|
-
"/prettier@2.8.8": "Missing shrinkwrap entry!",
|
|
7
|
-
"/typescript@5.6.3": "Missing shrinkwrap entry!",
|
|
8
|
-
"/vite@5.4.19(@types/node@24.3.0)": "Missing shrinkwrap entry!",
|
|
9
|
-
"/vitest@2.1.9(@types/node@24.3.0)(jsdom@21.1.1)": "Missing shrinkwrap entry!",
|
|
10
|
-
"/vue-tsc@1.8.8(typescript@5.6.3)": "Missing shrinkwrap entry!",
|
|
11
|
-
"/vue@3.5.20(typescript@5.6.3)": "Missing shrinkwrap entry!"
|
|
12
|
-
}
|
package/CHANGELOG.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dialpad/i18n",
|
|
3
|
-
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"version": "1.22.1",
|
|
6
|
-
"tag": "@dialpad/i18n_v1.22.1",
|
|
7
|
-
"date": "Wed, 19 Nov 2025 19:38:28 GMT",
|
|
8
|
-
"comments": {
|
|
9
|
-
"patch": [
|
|
10
|
-
{
|
|
11
|
-
"comment": "expose missing types to keep backward compatibiliy"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"version": "1.22.0",
|
|
18
|
-
"tag": "@dialpad/i18n_v1.22.0",
|
|
19
|
-
"date": "Mon, 17 Nov 2025 14:44:58 GMT",
|
|
20
|
-
"comments": {
|
|
21
|
-
"minor": [
|
|
22
|
-
{
|
|
23
|
-
"comment": "enhance useI18N function for non vue components"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"dependency": [
|
|
27
|
-
{
|
|
28
|
-
"comment": "Updating dependency \"@dialpad/i18n-services\" to `1.11.0`"
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"version": "1.20.1",
|
|
35
|
-
"tag": "@dialpad/i18n_v1.20.1",
|
|
36
|
-
"date": "Fri, 29 Aug 2025 20:24:21 GMT",
|
|
37
|
-
"comments": {
|
|
38
|
-
"dependency": [
|
|
39
|
-
{
|
|
40
|
-
"comment": "Updating dependency \"@dialpad/eslint-config\" to `2.1.0`"
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"version": "1.20.0",
|
|
47
|
-
"tag": "@dialpad/i18n_v1.20.0",
|
|
48
|
-
"date": "Tue, 26 Aug 2025 04:07:36 GMT",
|
|
49
|
-
"comments": {
|
|
50
|
-
"minor": [
|
|
51
|
-
{
|
|
52
|
-
"comment": "migrated i18n package"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"dependency": [
|
|
56
|
-
{
|
|
57
|
-
"comment": "Updating dependency \"@dialpad/i18n-services\" to `1.9.0`"
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Change Log - @dialpad/i18n
|
|
2
|
-
|
|
3
|
-
This log was last generated on Wed, 19 Nov 2025 19:38:28 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
## 1.22.1
|
|
6
|
-
Wed, 19 Nov 2025 19:38:28 GMT
|
|
7
|
-
|
|
8
|
-
### Patches
|
|
9
|
-
|
|
10
|
-
- expose missing types to keep backward compatibiliy
|
|
11
|
-
|
|
12
|
-
## 1.22.0
|
|
13
|
-
Mon, 17 Nov 2025 14:44:58 GMT
|
|
14
|
-
|
|
15
|
-
### Minor changes
|
|
16
|
-
|
|
17
|
-
- enhance useI18N function for non vue components
|
|
18
|
-
|
|
19
|
-
## 1.20.1
|
|
20
|
-
Fri, 29 Aug 2025 20:24:21 GMT
|
|
21
|
-
|
|
22
|
-
_Version update only_
|
|
23
|
-
|
|
24
|
-
## 1.20.0
|
|
25
|
-
Tue, 26 Aug 2025 04:07:36 GMT
|
|
26
|
-
|
|
27
|
-
### Minor changes
|
|
28
|
-
|
|
29
|
-
- migrated i18n package
|
|
30
|
-
|
package/base-tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noEmit": false,
|
|
8
|
-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
9
|
-
"experimentalDecorators": true,
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"jsx": "preserve",
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"types": ["vite/client", "vitest/globals"],
|
|
16
|
-
"noPropertyAccessFromIndexSignature": false,
|
|
17
|
-
"verbatimModuleSyntax": true
|
|
18
|
-
}
|
|
19
|
-
}
|
package/dialpad-i18n-1.22.2.tgz
DELETED
|
Binary file
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
2
|
-
import type { LocaleManagerParams, SetLocaleParams, UseI18N } from '@dialpad/i18n-services/locale-manager';
|
|
3
|
-
import type { Ref } from 'vue';
|
|
4
|
-
import { BaseLocaleManager } from '@dialpad/i18n-services/locale-manager';
|
|
5
|
-
export declare const INJECTION_KEY_PREFIX = "GLOBAL_LOCALE_MANAGER";
|
|
6
|
-
/**
|
|
7
|
-
* This is a backup storage for LocaleManagers in order to solve
|
|
8
|
-
* the constraint of having to call useI18N() inside a <script setup>.
|
|
9
|
-
*
|
|
10
|
-
* This is kinda hackish (I tried to keep it simple as well) but otherwise we're forcing consumers
|
|
11
|
-
* (i.e. Dialtone) to potentially modify their whole database
|
|
12
|
-
* and set the <script> for each components to <script setup>
|
|
13
|
-
*
|
|
14
|
-
* (I haven't found a way to do this only relying on Vue 3 capabilities T_T)
|
|
15
|
-
*/
|
|
16
|
-
export declare const globalLocaleManagers: Map<string, LocaleManager>;
|
|
17
|
-
export declare class LocaleManager extends BaseLocaleManager {
|
|
18
|
-
currentLocaleProp: Ref<string | null>;
|
|
19
|
-
app: App | null;
|
|
20
|
-
constructor(params: LocaleManagerParams);
|
|
21
|
-
protected setCurrentLocaleProp(locale: string): void;
|
|
22
|
-
/**
|
|
23
|
-
* Registers this LocaleManager with the Vue instance so that it can
|
|
24
|
-
* be used by the {@link useI18N} hook.
|
|
25
|
-
*
|
|
26
|
-
* @param app - The Vue app to register with.
|
|
27
|
-
* @param namespace - The namespace to install the LocaleManager under.
|
|
28
|
-
* Defaults to 'default'
|
|
29
|
-
*/
|
|
30
|
-
install(app: App, namespace?: string): void;
|
|
31
|
-
private addToVue;
|
|
32
|
-
/**
|
|
33
|
-
* Changes the locale of the {@link LocaleManager} that is currently active in
|
|
34
|
-
* the app, or the one specified by the namespace.
|
|
35
|
-
*
|
|
36
|
-
* @param args - Optional parameters to pass to the underlying
|
|
37
|
-
* {@link BaseLocaleManager#updateLocaleSettings} method.
|
|
38
|
-
* @param namespace - Optional namespace to change the locale of. If not
|
|
39
|
-
* provided, all LocaleManagers will be changed.
|
|
40
|
-
*/
|
|
41
|
-
changeLocale(args?: Partial<SetLocaleParams>, namespace?: string): void;
|
|
42
|
-
private getLocaleManagerByNamespace;
|
|
43
|
-
private findLocaleManagerInProvides;
|
|
44
|
-
private getAllLocaleManagers;
|
|
45
|
-
private findLocaleManagersByKeyFilter;
|
|
46
|
-
useI18N(namespace?: string): UseI18N;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Use i18n functionality without requiring to depend only on Vue's inject
|
|
50
|
-
* @param namespace - The namespace of the locale manager to use, defaults to 'default'
|
|
51
|
-
*/
|
|
52
|
-
export declare function findLocaleManager(namespace: string): LocaleManager | undefined;
|
|
53
|
-
export declare function useI18N(namespace?: string): UseI18N;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { computed, ref, inject } from 'vue';
|
|
2
|
-
import { BaseLocaleManager } from '@dialpad/i18n-services/locale-manager';
|
|
3
|
-
export const INJECTION_KEY_PREFIX = 'GLOBAL_LOCALE_MANAGER';
|
|
4
|
-
/**
|
|
5
|
-
* This is a backup storage for LocaleManagers in order to solve
|
|
6
|
-
* the constraint of having to call useI18N() inside a <script setup>.
|
|
7
|
-
*
|
|
8
|
-
* This is kinda hackish (I tried to keep it simple as well) but otherwise we're forcing consumers
|
|
9
|
-
* (i.e. Dialtone) to potentially modify their whole database
|
|
10
|
-
* and set the <script> for each components to <script setup>
|
|
11
|
-
*
|
|
12
|
-
* (I haven't found a way to do this only relying on Vue 3 capabilities T_T)
|
|
13
|
-
*/
|
|
14
|
-
export const globalLocaleManagers = new Map();
|
|
15
|
-
export class LocaleManager extends BaseLocaleManager {
|
|
16
|
-
currentLocaleProp = ref(null);
|
|
17
|
-
app = null;
|
|
18
|
-
constructor(params) {
|
|
19
|
-
super(params);
|
|
20
|
-
this.setCurrentLocaleProp(this.determineLocale({
|
|
21
|
-
preferredLocale: params.preferredLocale,
|
|
22
|
-
allowedLocales: params.allowedLocales,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
setCurrentLocaleProp(locale) {
|
|
26
|
-
this.currentLocaleProp = ref(locale);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Registers this LocaleManager with the Vue instance so that it can
|
|
30
|
-
* be used by the {@link useI18N} hook.
|
|
31
|
-
*
|
|
32
|
-
* @param app - The Vue app to register with.
|
|
33
|
-
* @param namespace - The namespace to install the LocaleManager under.
|
|
34
|
-
* Defaults to 'default'
|
|
35
|
-
*/
|
|
36
|
-
install(app, namespace = 'default') {
|
|
37
|
-
// initializes fluent if not initialized
|
|
38
|
-
this.initFluent();
|
|
39
|
-
this.addToVue(app, namespace);
|
|
40
|
-
}
|
|
41
|
-
addToVue(app, namespace) {
|
|
42
|
-
if (!this.fluent) {
|
|
43
|
-
throw new Error('fluent not ready, you probably want to call install(...) first');
|
|
44
|
-
}
|
|
45
|
-
this.app = app;
|
|
46
|
-
// Only install fluent plugin if not already installed
|
|
47
|
-
// This prevents "component i18n has already been registered" warnings
|
|
48
|
-
const isFluentInstalled = app.component('i18n') !== undefined;
|
|
49
|
-
if (!isFluentInstalled) {
|
|
50
|
-
app.use(this.fluent);
|
|
51
|
-
}
|
|
52
|
-
// Always register this LocaleManager for injection, regardless of plugin installation
|
|
53
|
-
app.provide(parseInjectionName(namespace), this);
|
|
54
|
-
globalLocaleManagers.set(parseInjectionName(namespace), this);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Changes the locale of the {@link LocaleManager} that is currently active in
|
|
58
|
-
* the app, or the one specified by the namespace.
|
|
59
|
-
*
|
|
60
|
-
* @param args - Optional parameters to pass to the underlying
|
|
61
|
-
* {@link BaseLocaleManager#updateLocaleSettings} method.
|
|
62
|
-
* @param namespace - Optional namespace to change the locale of. If not
|
|
63
|
-
* provided, all LocaleManagers will be changed.
|
|
64
|
-
*/
|
|
65
|
-
changeLocale(args, namespace) {
|
|
66
|
-
const localeManagers = namespace
|
|
67
|
-
? this.getLocaleManagerByNamespace(namespace)
|
|
68
|
-
: this.getAllLocaleManagers();
|
|
69
|
-
for (const localeManager of localeManagers) {
|
|
70
|
-
localeManager.updateLocaleSettings(args);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
getLocaleManagerByNamespace(namespace) {
|
|
74
|
-
const localeManager = this.findLocaleManagerInProvides(namespace) ??
|
|
75
|
-
findLocaleManager(namespace);
|
|
76
|
-
if (!localeManager) {
|
|
77
|
-
throw new Error('LocaleManager not found!');
|
|
78
|
-
}
|
|
79
|
-
return [localeManager];
|
|
80
|
-
}
|
|
81
|
-
// This method mostly focuses on remain backward compatible and reduce risks when implementing new instance providing mechanisms
|
|
82
|
-
findLocaleManagerInProvides(namespace) {
|
|
83
|
-
const providedValues = this.app?._context.provides;
|
|
84
|
-
if (!providedValues) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const targetKey = parseInjectionName(namespace);
|
|
88
|
-
return this.findLocaleManagersByKeyFilter(providedValues, (key) => key === targetKey)[0];
|
|
89
|
-
}
|
|
90
|
-
getAllLocaleManagers() {
|
|
91
|
-
const providedValues = this.app?._context.provides;
|
|
92
|
-
if (!providedValues) {
|
|
93
|
-
throw new Error('No locale managers are set up yet!');
|
|
94
|
-
}
|
|
95
|
-
return this.findLocaleManagersByKeyFilter(providedValues, (key) => key.startsWith(INJECTION_KEY_PREFIX.toString()));
|
|
96
|
-
}
|
|
97
|
-
findLocaleManagersByKeyFilter(providedValues, keyFilter) {
|
|
98
|
-
const localeManagers = [];
|
|
99
|
-
Object.entries(providedValues).forEach(([key, value]) => {
|
|
100
|
-
if (typeof key === 'string' &&
|
|
101
|
-
keyFilter(key) &&
|
|
102
|
-
value instanceof LocaleManager) {
|
|
103
|
-
localeManagers.push(value);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
return localeManagers;
|
|
107
|
-
}
|
|
108
|
-
useI18N(namespace = 'default') {
|
|
109
|
-
this.initFluent();
|
|
110
|
-
const l = this;
|
|
111
|
-
return {
|
|
112
|
-
currentLocale: computed(() => this.currentLocaleProp.value),
|
|
113
|
-
setI18N: (args, namespace) => {
|
|
114
|
-
l.changeLocale(args, namespace);
|
|
115
|
-
},
|
|
116
|
-
get $t() {
|
|
117
|
-
return l.fluentFormat;
|
|
118
|
-
},
|
|
119
|
-
get $ta() {
|
|
120
|
-
return l.fluentFormatAttrs;
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Use i18n functionality without requiring to depend only on Vue's inject
|
|
127
|
-
* @param namespace - The namespace of the locale manager to use, defaults to 'default'
|
|
128
|
-
*/
|
|
129
|
-
export function findLocaleManager(namespace) {
|
|
130
|
-
const injectionKey = parseInjectionName(namespace);
|
|
131
|
-
// Use null as default to suppress Vue injection warning when key is not found
|
|
132
|
-
const injected = inject(injectionKey, null);
|
|
133
|
-
return injected ?? globalLocaleManagers.get(injectionKey);
|
|
134
|
-
}
|
|
135
|
-
// TODO - allow custom injection key or whatever???
|
|
136
|
-
// TODO - also maybe just use getCurrentApp + the app's global config? idk.
|
|
137
|
-
export function useI18N(namespace = 'default') {
|
|
138
|
-
const localeManager = findLocaleManager(namespace);
|
|
139
|
-
if (!localeManager) {
|
|
140
|
-
throw new Error(`locale manager doesn't exist using ${namespace}. Make sure your locale manager was set up correctly`);
|
|
141
|
-
}
|
|
142
|
-
return localeManager.useI18N(namespace);
|
|
143
|
-
}
|
|
144
|
-
function parseInjectionName(namespace) {
|
|
145
|
-
return `${INJECTION_KEY_PREFIX}.${namespace}`;
|
|
146
|
-
}
|
package/eslint-tsconfig.json
DELETED
package/index.html
DELETED
|
File without changes
|
package/rush-logs/i18n.build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Invoking: run-p build:*
|
|
2
|
-
|
|
3
|
-
> @dialpad/i18n@1.22.1 build:types
|
|
4
|
-
> rushx types:build
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> @dialpad/i18n@1.22.1 build:main
|
|
8
|
-
> vite build --config vite.config.ts
|
|
9
|
-
|
|
10
|
-
vite v5.4.19 building for production...
|
|
11
|
-
transforming...
|
|
12
|
-
Found configuration in /Users/daniellovero/src/wcf-sdk/rush.json
|
|
13
|
-
|
|
14
|
-
Rush Multi-Project Build Tool 5.139.0 - Node.js 20.14.0 (LTS)
|
|
15
|
-
> "tsc"
|
|
16
|
-
|
|
17
|
-
✓ 30 modules transformed.
|
|
18
|
-
rendering chunks...
|
|
19
|
-
computing gzip size...
|
|
20
|
-
dist/i18n.js 209.99 kB │ gzip: 49.06 kB │ map: 511.23 kB
|
|
21
|
-
dist/i18n.cjs 210.17 kB │ gzip: 49.11 kB │ map: 511.47 kB
|
|
22
|
-
✓ built in 806ms
|
|
File without changes
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Invoking: prettier ./ --write
|
|
2
|
-
.eslintrc.cjs 27ms
|
|
3
|
-
.rush/temp/package-deps_build.json 3ms
|
|
4
|
-
.rush/temp/package-deps_format.json 3ms
|
|
5
|
-
.rush/temp/shrinkwrap-deps.json 1ms
|
|
6
|
-
base-tsconfig.json 4ms
|
|
7
|
-
CHANGELOG.json 2ms
|
|
8
|
-
eslint-tsconfig.json 1ms
|
|
9
|
-
index.html 16ms
|
|
10
|
-
index.ts 80ms
|
|
11
|
-
package.json 4ms
|
|
12
|
-
README.md 131ms
|
|
13
|
-
src/__test__/locale-manager.find.test.ts 10ms
|
|
14
|
-
src/__test__/locale-manager.formatters.test.ts 15ms
|
|
15
|
-
src/__test__/locale-manager.multiple.test.ts 28ms
|
|
16
|
-
src/__test__/locale-manager.test.ts 40ms
|
|
17
|
-
src/locale-manager.ts 12ms
|
|
18
|
-
tsconfig.json 2ms
|
|
19
|
-
vite.config.ts 3ms
|
|
File without changes
|
package/rush-logs/i18n.lint.log
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { describe, beforeEach, vi, afterEach, it, expect } from 'vitest';
|
|
2
|
-
import type { LocaleManager } from '../locale-manager';
|
|
3
|
-
import {
|
|
4
|
-
globalLocaleManagers,
|
|
5
|
-
INJECTION_KEY_PREFIX,
|
|
6
|
-
findLocaleManager,
|
|
7
|
-
} from '../locale-manager';
|
|
8
|
-
import * as vue from 'vue';
|
|
9
|
-
|
|
10
|
-
vi.mock('vue', () => ({
|
|
11
|
-
inject: vi.fn(),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
describe('findLocaleManager', () => {
|
|
15
|
-
// Reset mocks and clear data before each test
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.clearAllMocks();
|
|
18
|
-
globalLocaleManagers.clear();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
vi.restoreAllMocks();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return locale manager from Vue inject if available', () => {
|
|
26
|
-
const namespace = 'test-namespace';
|
|
27
|
-
const injectionKey = `${INJECTION_KEY_PREFIX}.${namespace}`;
|
|
28
|
-
const mockLocaleManager = {
|
|
29
|
-
id: 'injected-manager',
|
|
30
|
-
} as unknown as LocaleManager;
|
|
31
|
-
|
|
32
|
-
vi.mocked(vue.inject).mockReturnValue(mockLocaleManager);
|
|
33
|
-
|
|
34
|
-
const result = findLocaleManager(namespace);
|
|
35
|
-
|
|
36
|
-
expect(vue.inject).toHaveBeenCalledWith(injectionKey, null);
|
|
37
|
-
expect(result).toBe(mockLocaleManager);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should return locale manager from globalLocaleManagers if not available in inject', () => {
|
|
41
|
-
const namespace = 'test-namespace';
|
|
42
|
-
const injectionKey = `${INJECTION_KEY_PREFIX}.${namespace}`;
|
|
43
|
-
const mockLocaleManager = {
|
|
44
|
-
id: 'global-manager',
|
|
45
|
-
} as unknown as LocaleManager;
|
|
46
|
-
|
|
47
|
-
vi.mocked(vue.inject).mockReturnValue(null);
|
|
48
|
-
globalLocaleManagers.set(injectionKey, mockLocaleManager);
|
|
49
|
-
|
|
50
|
-
const result = findLocaleManager(namespace);
|
|
51
|
-
|
|
52
|
-
expect(vue.inject).toHaveBeenCalledWith(injectionKey, null);
|
|
53
|
-
expect(result).toBe(mockLocaleManager);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should return undefined if locale manager is not found anywhere', () => {
|
|
57
|
-
const namespace = 'nonexistent-namespace';
|
|
58
|
-
const injectionKey = `${INJECTION_KEY_PREFIX}.${namespace}`;
|
|
59
|
-
|
|
60
|
-
vi.mocked(vue.inject).mockReturnValue(null);
|
|
61
|
-
|
|
62
|
-
const result = findLocaleManager(namespace);
|
|
63
|
-
|
|
64
|
-
expect(vue.inject).toHaveBeenCalledWith(injectionKey, null);
|
|
65
|
-
expect(result).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should use the correct injection key format', () => {
|
|
69
|
-
const namespace = 'custom-namespace';
|
|
70
|
-
const injectionKey = `${INJECTION_KEY_PREFIX}.${namespace}`;
|
|
71
|
-
|
|
72
|
-
vi.mocked(vue.inject).mockReturnValue(null);
|
|
73
|
-
|
|
74
|
-
findLocaleManager(namespace);
|
|
75
|
-
|
|
76
|
-
expect(vue.inject).toHaveBeenCalledWith(injectionKey, null);
|
|
77
|
-
});
|
|
78
|
-
});
|