@empathyco/x-archetype-utils 1.1.0-alpha.2 → 2.0.0-alpha.2
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/cjs/build/rollup/rollup.config.js +1 -1
- package/dist/cjs/i18n/i18n.plugin.js +10 -8
- package/dist/esm/build/rollup/rollup.config.js +1 -1
- package/dist/esm/i18n/i18n.plugin.js +10 -8
- package/dist/types/build/rollup/rollup.config.d.ts +1 -1
- package/dist/types/i18n/i18n.plugin.d.ts +3 -3
- package/dist/types/i18n/i18n.types.d.ts +1 -1
- package/package.json +7 -7
- package/dist/types/__tests__/css-injector.spec.d.ts +0 -1
- package/dist/types/__tests__/i18n.plugin.spec.d.ts +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const rollupCssInjectorConfig = {
|
|
4
4
|
replace: {
|
|
5
5
|
// Replace X CSS injector by our custom one.
|
|
6
|
-
'
|
|
6
|
+
'export default injectCss;': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
|
|
7
7
|
delimiters: ['', '']
|
|
8
8
|
},
|
|
9
9
|
styles: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var xUtils = require('@empathyco/x-utils');
|
|
4
|
-
var
|
|
4
|
+
var vueI18n = require('vue-i18n');
|
|
5
5
|
var xDeepMerge = require('@empathyco/x-deep-merge');
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -39,16 +39,17 @@ class I18n {
|
|
|
39
39
|
* @param vue - The Vue instance.
|
|
40
40
|
*/
|
|
41
41
|
install(vue) {
|
|
42
|
-
|
|
43
|
-
this.vueI18n = new VueI18n({
|
|
42
|
+
this.vueI18n = vueI18n.createI18n({
|
|
44
43
|
locale: this.locale,
|
|
45
|
-
messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
|
|
46
44
|
silentFallbackWarn: true,
|
|
47
|
-
|
|
45
|
+
messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
|
|
46
|
+
missing: (_, key) => {
|
|
48
47
|
var _a;
|
|
49
|
-
return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${locale}'`);
|
|
48
|
+
return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${this.locale}'`);
|
|
50
49
|
}
|
|
51
50
|
});
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
52
|
+
vue.use(this.vueI18n);
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Tries to get a value from the messages object accessing it key by key.
|
|
@@ -81,7 +82,7 @@ class I18n {
|
|
|
81
82
|
if (this.locale !== newLocale) {
|
|
82
83
|
this.locale = newLocale;
|
|
83
84
|
await this.changeMessages();
|
|
84
|
-
this.vueI18n.locale = this.locale;
|
|
85
|
+
this.vueI18n.global.locale = this.locale;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
@@ -102,7 +103,8 @@ class I18n {
|
|
|
102
103
|
*/
|
|
103
104
|
async changeMessages() {
|
|
104
105
|
this.currentMessages = await this.getCurrentMessages();
|
|
105
|
-
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
107
|
+
this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages);
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
108
110
|
* Retrieves the corresponding messages for the set locale and device.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const rollupCssInjectorConfig = {
|
|
2
2
|
replace: {
|
|
3
3
|
// Replace X CSS injector by our custom one.
|
|
4
|
-
'
|
|
4
|
+
'export default injectCss;': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
|
|
5
5
|
delimiters: ['', '']
|
|
6
6
|
},
|
|
7
7
|
styles: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from '@empathyco/x-utils';
|
|
2
|
-
import
|
|
2
|
+
import { createI18n } from 'vue-i18n';
|
|
3
3
|
import { deepMerge } from '@empathyco/x-deep-merge';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -37,16 +37,17 @@ class I18n {
|
|
|
37
37
|
* @param vue - The Vue instance.
|
|
38
38
|
*/
|
|
39
39
|
install(vue) {
|
|
40
|
-
|
|
41
|
-
this.vueI18n = new VueI18n({
|
|
40
|
+
this.vueI18n = createI18n({
|
|
42
41
|
locale: this.locale,
|
|
43
|
-
messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
|
|
44
42
|
silentFallbackWarn: true,
|
|
45
|
-
|
|
43
|
+
messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
|
|
44
|
+
missing: (_, key) => {
|
|
46
45
|
var _a;
|
|
47
|
-
return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${locale}'`);
|
|
46
|
+
return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${this.locale}'`);
|
|
48
47
|
}
|
|
49
48
|
});
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
50
|
+
vue.use(this.vueI18n);
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Tries to get a value from the messages object accessing it key by key.
|
|
@@ -79,7 +80,7 @@ class I18n {
|
|
|
79
80
|
if (this.locale !== newLocale) {
|
|
80
81
|
this.locale = newLocale;
|
|
81
82
|
await this.changeMessages();
|
|
82
|
-
this.vueI18n.locale = this.locale;
|
|
83
|
+
this.vueI18n.global.locale = this.locale;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
@@ -100,7 +101,8 @@ class I18n {
|
|
|
100
101
|
*/
|
|
101
102
|
async changeMessages() {
|
|
102
103
|
this.currentMessages = await this.getCurrentMessages();
|
|
103
|
-
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
105
|
+
this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages);
|
|
104
106
|
}
|
|
105
107
|
/**
|
|
106
108
|
* Retrieves the corresponding messages for the set locale and device.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n';
|
|
3
3
|
import { AnyMessages, Device, I18nOptions, Locale } from './i18n.types';
|
|
4
4
|
/**
|
|
5
5
|
* I18n settings manager.
|
|
@@ -32,7 +32,7 @@ export declare class I18n<SomeMessages> {
|
|
|
32
32
|
*
|
|
33
33
|
* @param vue - The Vue instance.
|
|
34
34
|
*/
|
|
35
|
-
install(vue:
|
|
35
|
+
install(vue: App): void;
|
|
36
36
|
/**
|
|
37
37
|
* Tries to get a value from the messages object accessing it key by key.
|
|
38
38
|
* When a key fails, takes the remaining key parts and tries to access the message
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-archetype-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "Utilities for x-archetype",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@empathyco/x-deep-merge": "^2.0.3-alpha.1",
|
|
40
40
|
"@empathyco/x-utils": "^1.0.3-alpha.1",
|
|
41
41
|
"tslib": "~2.6.0",
|
|
42
|
-
"vue-i18n": "~
|
|
42
|
+
"vue-i18n": "~9.14.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/jest": "~27.5.0",
|
|
46
46
|
"@types/node": "~18.19.0",
|
|
47
|
-
"@vue/test-utils": "~
|
|
47
|
+
"@vue/test-utils": "~2.4.6",
|
|
48
48
|
"jest": "~27.5.0",
|
|
49
49
|
"rimraf": "~3.0.2",
|
|
50
50
|
"rollup": "~4.9.1",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"rollup-plugin-typescript2": "~0.36.0",
|
|
54
54
|
"ts-jest": "~27.1.0",
|
|
55
55
|
"typescript": "~4.9.4",
|
|
56
|
-
"vue": "~
|
|
56
|
+
"vue": "~3.4.31"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"vue": "^
|
|
60
|
-
"vue-i18n": "^
|
|
59
|
+
"vue": "^3.4.31",
|
|
60
|
+
"vue-i18n": "^9.14.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "d08f39adb09013b148fc99452757436547fba363"
|
|
66
66
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|