@dialpad/i18n 1.20.4 → 1.22.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/.rush/temp/chunked-rush-logs/i18n.build.chunks.jsonl +6 -6
- package/.rush/temp/chunked-rush-logs/i18n.format.chunks.jsonl +19 -0
- package/.rush/temp/package-deps_build.json +3 -4
- package/.rush/temp/package-deps_format.json +24 -0
- package/.rush/temp/shrinkwrap-deps.json +3 -1
- package/CHANGELOG.json +29 -0
- package/CHANGELOG.md +15 -1
- package/README.md +0 -2
- package/dist/i18n.cjs +19 -12
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.js +19 -12
- package/dist/i18n.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/src/locale-manager.d.ts +4 -8
- package/dist/types/src/locale-manager.js +19 -11
- package/index.ts +1 -0
- package/package.json +23 -18
- package/rush-logs/i18n.build.log +6 -6
- package/rush-logs/i18n.format.error.log +0 -0
- package/rush-logs/i18n.format.log +19 -0
- package/src/locale-manager.ts +23 -23
- package/dialpad-i18n-1.20.1.tgz +0 -0
- package/dialpad-i18n-1.20.2.tgz +0 -0
- package/dialpad-i18n-1.20.3.tgz +0 -0
- package/package/package.json +0 -51
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LocaleCode, NamespaceCode, ResourceKey, LocaleManagerParams, SetLocaleParams, } from '@dialpad/i18n-services/locale-manager';
|
|
1
|
+
export type { LocaleCode, NamespaceCode, ResourceKey, LocaleManagerParams, SetLocaleParams, UseI18N, } from '@dialpad/i18n-services/locale-manager';
|
|
2
2
|
export type { BundleSource } from '@dialpad/i18n-services/bundle-source';
|
|
3
3
|
export { LocaleManager, useI18N, INJECTION_KEY_PREFIX, } from './src/locale-manager';
|
|
4
4
|
export { HTTPBundleSource, RawBundleSource, } from '@dialpad/i18n-services/bundle-source';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { App
|
|
2
|
-
import type {
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import type { LocaleManagerParams, SetLocaleParams, UseI18N } from '@dialpad/i18n-services/locale-manager';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
3
4
|
import { BaseLocaleManager } from '@dialpad/i18n-services/locale-manager';
|
|
4
5
|
export declare const INJECTION_KEY_PREFIX = "GLOBAL_LOCALE_MANAGER";
|
|
5
6
|
/**
|
|
@@ -13,12 +14,6 @@ export declare const INJECTION_KEY_PREFIX = "GLOBAL_LOCALE_MANAGER";
|
|
|
13
14
|
* (I haven't found a way to do this only relying on Vue 3 capabilities T_T)
|
|
14
15
|
*/
|
|
15
16
|
export declare const globalLocaleManagers: Map<string, LocaleManager>;
|
|
16
|
-
export interface UseI18N {
|
|
17
|
-
currentLocale: Ref<string | null>;
|
|
18
|
-
setI18N: (args?: Partial<SetLocaleParams>, namespace?: string) => void;
|
|
19
|
-
$t: FluentFormat;
|
|
20
|
-
$ta: FluentFormatAttrs;
|
|
21
|
-
}
|
|
22
17
|
export declare class LocaleManager extends BaseLocaleManager {
|
|
23
18
|
currentLocaleProp: Ref<string | null>;
|
|
24
19
|
app: App | null;
|
|
@@ -48,6 +43,7 @@ export declare class LocaleManager extends BaseLocaleManager {
|
|
|
48
43
|
private findLocaleManagerInProvides;
|
|
49
44
|
private getAllLocaleManagers;
|
|
50
45
|
private findLocaleManagersByKeyFilter;
|
|
46
|
+
useI18N(namespace?: string): UseI18N;
|
|
51
47
|
}
|
|
52
48
|
/**
|
|
53
49
|
* Use i18n functionality without requiring to depend only on Vue's inject
|
|
@@ -34,9 +34,8 @@ export class LocaleManager extends BaseLocaleManager {
|
|
|
34
34
|
* Defaults to 'default'
|
|
35
35
|
*/
|
|
36
36
|
install(app, namespace = 'default') {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
37
|
+
// initializes fluent if not initialized
|
|
38
|
+
this.initFluent();
|
|
40
39
|
this.addToVue(app, namespace);
|
|
41
40
|
}
|
|
42
41
|
addToVue(app, namespace) {
|
|
@@ -106,6 +105,22 @@ export class LocaleManager extends BaseLocaleManager {
|
|
|
106
105
|
});
|
|
107
106
|
return localeManagers;
|
|
108
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
|
+
}
|
|
109
124
|
}
|
|
110
125
|
/**
|
|
111
126
|
* Use i18n functionality without requiring to depend only on Vue's inject
|
|
@@ -124,14 +139,7 @@ export function useI18N(namespace = 'default') {
|
|
|
124
139
|
if (!localeManager) {
|
|
125
140
|
throw new Error(`locale manager doesn't exist using ${namespace}. Make sure your locale manager was set up correctly`);
|
|
126
141
|
}
|
|
127
|
-
return
|
|
128
|
-
currentLocale: computed(() => localeManager.currentLocaleProp.value),
|
|
129
|
-
setI18N: (args, namespace) => {
|
|
130
|
-
localeManager.changeLocale(args, namespace);
|
|
131
|
-
},
|
|
132
|
-
$t: localeManager.fluentFormat,
|
|
133
|
-
$ta: localeManager.fluentFormatAttrs,
|
|
134
|
-
};
|
|
142
|
+
return localeManager.useI18N(namespace);
|
|
135
143
|
}
|
|
136
144
|
function parseInjectionName(namespace) {
|
|
137
145
|
return `${INJECTION_KEY_PREFIX}.${namespace}`;
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dialpad/i18n",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Dialpad's internationalization library",
|
|
6
6
|
"author": "Dialpad",
|
|
7
7
|
"license": "UNLICENSED",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"typecheck": "rushx types:check",
|
|
11
|
+
"typecheck:ci": "rushx typecheck",
|
|
12
|
+
"lint": "echo 'needs migration to use @dialpad/eslint-config'",
|
|
13
|
+
"lint:ci": "echo 'needs migration to use @dialpad/eslint-config'",
|
|
14
|
+
"format": "prettier ./ --write",
|
|
15
|
+
"format:ci": "prettier ./ --check",
|
|
16
|
+
"test": "vitest",
|
|
17
|
+
"test:ci": "rushx test 2>&1",
|
|
18
|
+
"coverage": "vitest run --coverage --passWithNoTests",
|
|
19
|
+
"coverage:open": "rushx coverage && open coverage/index.html",
|
|
20
|
+
"build": "run-p build:*",
|
|
21
|
+
"build:main": "vite build --config vite.config.ts",
|
|
22
|
+
"build:types": "rushx types:build",
|
|
23
|
+
"types:build": "tsc",
|
|
24
|
+
"types:check": "tsc --noEmit"
|
|
25
|
+
},
|
|
9
26
|
"dependencies": {
|
|
10
|
-
"@dialpad/i18n-services": "
|
|
27
|
+
"@dialpad/i18n-services": "workspace:*"
|
|
11
28
|
},
|
|
12
29
|
"devDependencies": {
|
|
30
|
+
"@dialpad/eslint-config": "workspace:*",
|
|
13
31
|
"@vitejs/plugin-vue": "~5.1.4",
|
|
14
32
|
"npm-run-all": "4.1.5",
|
|
33
|
+
"prettier": "~2.8.8",
|
|
15
34
|
"typescript": "~5.6.3",
|
|
16
35
|
"vite": "~5.4.10",
|
|
17
36
|
"vue": "~3.5.12",
|
|
18
37
|
"vue-tsc": "1.8.8",
|
|
19
38
|
"vitest": "~2.1.4",
|
|
20
|
-
"
|
|
39
|
+
"eslint": "~9.13.0"
|
|
21
40
|
},
|
|
22
41
|
"exports": {
|
|
23
42
|
"import": "./dist/i18n.js",
|
|
@@ -33,19 +52,5 @@
|
|
|
33
52
|
"repository": {
|
|
34
53
|
"type": "git",
|
|
35
54
|
"url": "https://github.com/dialpad/web-clients.git"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"lint": "eslint ./ --fix",
|
|
39
|
-
"lint:ci": "eslint ./ --output-file eslint_report.json --format json",
|
|
40
|
-
"format": "prettier ./ --write",
|
|
41
|
-
"format:ci": "prettier ./ --check",
|
|
42
|
-
"test": "vitest",
|
|
43
|
-
"coverage": "vitest run --coverage --passWithNoTests",
|
|
44
|
-
"coverage:open": "rushx coverage && open coverage/index.html",
|
|
45
|
-
"build": "run-p build:*",
|
|
46
|
-
"build:main": "vite build --config vite.config.ts",
|
|
47
|
-
"build:types": "rushx types:build",
|
|
48
|
-
"types:build": "tsc",
|
|
49
|
-
"types:check": "tsc --noEmit"
|
|
50
55
|
}
|
|
51
|
-
}
|
|
56
|
+
}
|
package/rush-logs/i18n.build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
Invoking: run-p build:*
|
|
2
2
|
|
|
3
|
-
> @dialpad/i18n@1.
|
|
3
|
+
> @dialpad/i18n@1.22.1 build:types
|
|
4
4
|
> rushx types:build
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @dialpad/i18n@1.
|
|
7
|
+
> @dialpad/i18n@1.22.1 build:main
|
|
8
8
|
> vite build --config vite.config.ts
|
|
9
9
|
|
|
10
10
|
vite v5.4.19 building for production...
|
|
11
|
+
transforming...
|
|
11
12
|
Found configuration in /Users/daniellovero/src/wcf-sdk/rush.json
|
|
12
13
|
|
|
13
|
-
transforming...
|
|
14
14
|
Rush Multi-Project Build Tool 5.139.0 - Node.js 20.14.0 (LTS)
|
|
15
15
|
> "tsc"
|
|
16
16
|
|
|
17
17
|
✓ 30 modules transformed.
|
|
18
18
|
rendering chunks...
|
|
19
19
|
computing gzip size...
|
|
20
|
-
dist/i18n.js 209.
|
|
21
|
-
dist/i18n.cjs 210.
|
|
22
|
-
✓ built in
|
|
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
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
package/src/locale-manager.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { App
|
|
1
|
+
import type { App } from 'vue';
|
|
2
2
|
import type {
|
|
3
|
-
FluentFormat,
|
|
4
|
-
FluentFormatAttrs,
|
|
5
3
|
LocaleManagerParams,
|
|
6
4
|
SetLocaleParams,
|
|
5
|
+
UseI18N,
|
|
7
6
|
} from '@dialpad/i18n-services/locale-manager';
|
|
8
|
-
|
|
9
7
|
import { computed, ref, inject } from 'vue';
|
|
8
|
+
import type { Ref } from 'vue';
|
|
10
9
|
import { BaseLocaleManager } from '@dialpad/i18n-services/locale-manager';
|
|
11
10
|
|
|
12
11
|
export const INJECTION_KEY_PREFIX = 'GLOBAL_LOCALE_MANAGER';
|
|
@@ -23,13 +22,6 @@ export const INJECTION_KEY_PREFIX = 'GLOBAL_LOCALE_MANAGER';
|
|
|
23
22
|
*/
|
|
24
23
|
export const globalLocaleManagers = new Map<string, LocaleManager>();
|
|
25
24
|
|
|
26
|
-
export interface UseI18N {
|
|
27
|
-
currentLocale: Ref<string | null>;
|
|
28
|
-
setI18N: (args?: Partial<SetLocaleParams>, namespace?: string) => void;
|
|
29
|
-
$t: FluentFormat;
|
|
30
|
-
$ta: FluentFormatAttrs;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
export class LocaleManager extends BaseLocaleManager {
|
|
34
26
|
currentLocaleProp: Ref<string | null> = ref<string | null>(null);
|
|
35
27
|
app: App | null = null;
|
|
@@ -57,10 +49,8 @@ export class LocaleManager extends BaseLocaleManager {
|
|
|
57
49
|
* Defaults to 'default'
|
|
58
50
|
*/
|
|
59
51
|
install(app: App, namespace = 'default'): void {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
52
|
+
// initializes fluent if not initialized
|
|
53
|
+
this.initFluent();
|
|
64
54
|
this.addToVue(app, namespace);
|
|
65
55
|
}
|
|
66
56
|
|
|
@@ -157,6 +147,23 @@ export class LocaleManager extends BaseLocaleManager {
|
|
|
157
147
|
|
|
158
148
|
return localeManagers;
|
|
159
149
|
}
|
|
150
|
+
|
|
151
|
+
useI18N(namespace = 'default'): UseI18N {
|
|
152
|
+
this.initFluent();
|
|
153
|
+
const l = this;
|
|
154
|
+
return {
|
|
155
|
+
currentLocale: computed(() => this.currentLocaleProp.value),
|
|
156
|
+
setI18N: (args?: Partial<SetLocaleParams>, namespace?: string) => {
|
|
157
|
+
l.changeLocale(args, namespace);
|
|
158
|
+
},
|
|
159
|
+
get $t() {
|
|
160
|
+
return l.fluentFormat;
|
|
161
|
+
},
|
|
162
|
+
get $ta() {
|
|
163
|
+
return l.fluentFormatAttrs;
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
/**
|
|
@@ -183,14 +190,7 @@ export function useI18N(namespace = 'default'): UseI18N {
|
|
|
183
190
|
);
|
|
184
191
|
}
|
|
185
192
|
|
|
186
|
-
return
|
|
187
|
-
currentLocale: computed(() => localeManager.currentLocaleProp.value),
|
|
188
|
-
setI18N: (args?: Partial<SetLocaleParams>, namespace?: string) => {
|
|
189
|
-
localeManager.changeLocale(args, namespace);
|
|
190
|
-
},
|
|
191
|
-
$t: localeManager.fluentFormat,
|
|
192
|
-
$ta: localeManager.fluentFormatAttrs,
|
|
193
|
-
};
|
|
193
|
+
return localeManager.useI18N(namespace);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function parseInjectionName(namespace: string): string {
|
package/dialpad-i18n-1.20.1.tgz
DELETED
|
Binary file
|
package/dialpad-i18n-1.20.2.tgz
DELETED
|
Binary file
|
package/dialpad-i18n-1.20.3.tgz
DELETED
|
Binary file
|
package/package/package.json
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dialpad/i18n",
|
|
3
|
-
"version": "1.20.3",
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "Dialpad's internationalization library",
|
|
6
|
-
"author": "Dialpad",
|
|
7
|
-
"license": "UNLICENSED",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"lint": "eslint ./ --fix",
|
|
11
|
-
"lint:ci": "eslint ./ --output-file eslint_report.json --format json",
|
|
12
|
-
"format": "prettier ./ --write",
|
|
13
|
-
"format:ci": "prettier ./ --check",
|
|
14
|
-
"test": "vitest",
|
|
15
|
-
"coverage": "vitest run --coverage --passWithNoTests",
|
|
16
|
-
"coverage:open": "rushx coverage && open coverage/index.html",
|
|
17
|
-
"build": "run-p build:*",
|
|
18
|
-
"build:main": "vite build --config vite.config.ts",
|
|
19
|
-
"build:types": "rushx types:build",
|
|
20
|
-
"types:build": "tsc",
|
|
21
|
-
"types:check": "tsc --noEmit"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@dialpad/i18n-services": "workspace:*"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@dialpad/eslint-config": "workspace:*",
|
|
28
|
-
"@vitejs/plugin-vue": "~5.1.4",
|
|
29
|
-
"npm-run-all": "4.1.5",
|
|
30
|
-
"typescript": "~5.6.3",
|
|
31
|
-
"vite": "~5.4.10",
|
|
32
|
-
"vue": "~3.5.12",
|
|
33
|
-
"vue-tsc": "1.8.8",
|
|
34
|
-
"vitest": "~2.1.4"
|
|
35
|
-
},
|
|
36
|
-
"exports": {
|
|
37
|
-
"import": "./dist/i18n.js",
|
|
38
|
-
"types": "./dist/types/index.d.ts",
|
|
39
|
-
"require": "./dist/i18n.cjs"
|
|
40
|
-
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"vue": "^3.0.0"
|
|
43
|
-
},
|
|
44
|
-
"dp": {
|
|
45
|
-
"nodpend": true
|
|
46
|
-
},
|
|
47
|
-
"repository": {
|
|
48
|
-
"type": "git",
|
|
49
|
-
"url": "https://github.com/dialpad/web-clients.git"
|
|
50
|
-
}
|
|
51
|
-
}
|