@cloudbase/cli 2.9.11 → 2.9.13
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/standalone/cli.js +3001 -1716
- package/lib/i18n/index.js +7 -15
- package/locales/index.js +5 -0
- package/package.json +1 -1
- package/tsconfig.json +2 -1
package/lib/i18n/index.js
CHANGED
|
@@ -4,19 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isIntl = exports.getLanguage = exports.t = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
7
|
const os_locale_1 = __importDefault(require("os-locale"));
|
|
10
8
|
const db_1 = require("../utils/store/db");
|
|
9
|
+
const locales_1 = require("../../locales");
|
|
11
10
|
let i18n;
|
|
11
|
+
const LANG_DATA = {
|
|
12
|
+
zh: locales_1.zh,
|
|
13
|
+
en: locales_1.en
|
|
14
|
+
};
|
|
12
15
|
const configDB = (0, db_1.getSyncDB)('config');
|
|
13
16
|
const AVAILABLE_LANGS = ['zh', 'en'];
|
|
14
17
|
class I18n {
|
|
15
18
|
constructor() {
|
|
16
19
|
this.lang = getLanguage();
|
|
20
|
+
this.mapping = locales_1.mappingData;
|
|
17
21
|
if (this.lang !== 'zh') {
|
|
18
|
-
this.
|
|
19
|
-
this.loadMapping();
|
|
22
|
+
this.data = LANG_DATA[this.lang];
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
t(key, options) {
|
|
@@ -29,11 +32,6 @@ class I18n {
|
|
|
29
32
|
}
|
|
30
33
|
return key;
|
|
31
34
|
}
|
|
32
|
-
loadLanguage() {
|
|
33
|
-
const langPath = path_1.default.resolve(I18n.langDir, `${this.lang}.json`);
|
|
34
|
-
const langData = fs_1.default.readFileSync(langPath, 'utf-8');
|
|
35
|
-
this.data = JSON.parse(langData);
|
|
36
|
-
}
|
|
37
35
|
replaceVars(str, vars) {
|
|
38
36
|
let result = str;
|
|
39
37
|
if (!vars) {
|
|
@@ -44,13 +42,7 @@ class I18n {
|
|
|
44
42
|
});
|
|
45
43
|
return result;
|
|
46
44
|
}
|
|
47
|
-
loadMapping() {
|
|
48
|
-
const mappingPath = path_1.default.resolve(__dirname, '../../locales/mapping.json');
|
|
49
|
-
const mappingStr = fs_1.default.readFileSync(mappingPath, 'utf-8');
|
|
50
|
-
this.mapping = JSON.parse(mappingStr);
|
|
51
|
-
}
|
|
52
45
|
}
|
|
53
|
-
I18n.langDir = path_1.default.resolve(__dirname, '../../locales/langs');
|
|
54
46
|
function t(key, options) {
|
|
55
47
|
if (!i18n) {
|
|
56
48
|
i18n = new I18n();
|
package/locales/index.js
ADDED
package/package.json
CHANGED
package/tsconfig.json
CHANGED