@modern-js/plugin-i18n 1.2.3 → 1.2.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @modern-js/plugin-i18n
2
2
 
3
+ ## 1.2.6
4
+
5
+ ### Patch Changes
6
+
7
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
8
+ - Updated dependencies [d32f35134]
9
+ - Updated dependencies [6ae4a34ae]
10
+ - Updated dependencies [b80229c79]
11
+ - Updated dependencies [948cc4436]
12
+ - @modern-js/utils@1.7.3
13
+
14
+ ## 1.2.5
15
+
16
+ ### Patch Changes
17
+
18
+ - 69a728375: fix: remove exports.jsnext:source after publish
19
+ - Updated dependencies [cd7346b0d]
20
+ - Updated dependencies [69a728375]
21
+ - @modern-js/utils@1.7.2
22
+
23
+ ## 1.2.4
24
+
25
+ ### Patch Changes
26
+
27
+ - 6cffe99d: chore:
28
+ remove react eslint rules for `modern-js` rule set.
29
+ add .eslintrc for each package to speed up linting
30
+ - 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
31
+ - 60f7d8bf: feat: add tests dir to npmignore
32
+ - Updated dependencies [b8599d09]
33
+ - Updated dependencies [60f7d8bf]
34
+ - Updated dependencies [3bf4f8b0]
35
+ - @modern-js/utils@1.5.0
36
+
3
37
  ## 1.2.3
4
38
 
5
39
  ### Patch Changes
@@ -1,10 +1,13 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
1
3
  import { get } from '@modern-js/utils/lodash';
2
4
  import { getObjKeyMap } from "./utils";
3
5
 
4
6
  class I18n {
5
7
  constructor() {
6
- this.language = 'en';
7
- this.languageMap = {};
8
+ _defineProperty(this, "language", 'en');
9
+
10
+ _defineProperty(this, "languageMap", {});
8
11
  }
9
12
 
10
13
  format(msg, vars) {
@@ -9,10 +9,13 @@ var _lodash = require("@modern-js/utils/lodash");
9
9
 
10
10
  var _utils = require("./utils");
11
11
 
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
12
14
  class I18n {
13
15
  constructor() {
14
- this.language = 'en';
15
- this.languageMap = {};
16
+ _defineProperty(this, "language", 'en');
17
+
18
+ _defineProperty(this, "languageMap", {});
16
19
  }
17
20
 
18
21
  format(msg, vars) {
@@ -1,9 +1,6 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
-
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
-
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
4
  import { get } from '@modern-js/utils/lodash';
8
5
  import { getObjKeyMap } from "./utils";
9
6
 
@@ -11,8 +8,9 @@ var I18n = /*#__PURE__*/function () {
11
8
  function I18n() {
12
9
  _classCallCheck(this, I18n);
13
10
 
14
- this.language = 'en';
15
- this.languageMap = {};
11
+ _defineProperty(this, "language", 'en');
12
+
13
+ _defineProperty(this, "languageMap", {});
16
14
  }
17
15
 
18
16
  _createClass(I18n, [{
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.3",
14
+ "version": "1.2.6",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7",
31
- "@modern-js/utils": "^1.4.0"
31
+ "@modern-js/utils": "^1.7.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/jest": "^26",
34
+ "@types/jest": "^27",
35
35
  "@types/node": "^14",
36
36
  "typescript": "^4",
37
37
  "@scripts/build": "0.0.0",
@@ -44,10 +44,32 @@
44
44
  "registry": "https://registry.npmjs.org/",
45
45
  "access": "public"
46
46
  },
47
+ "wireit": {
48
+ "build": {
49
+ "command": "modern build",
50
+ "files": [
51
+ "src/**/*",
52
+ "tsconfig.json",
53
+ "package.json"
54
+ ],
55
+ "output": [
56
+ "dist/**/*"
57
+ ]
58
+ },
59
+ "test": {
60
+ "command": "jest --passWithNoTests",
61
+ "files": [
62
+ "src/**/*",
63
+ "tsconfig.json",
64
+ "package.json"
65
+ ],
66
+ "output": []
67
+ }
68
+ },
47
69
  "scripts": {
48
70
  "new": "modern new",
49
- "build": "modern build",
50
- "test": "jest --passWithNoTests"
71
+ "build": "wireit",
72
+ "test": "wireit"
51
73
  },
52
74
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
53
75
  }
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/modern.config.js DELETED
@@ -1,2 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,83 +0,0 @@
1
- import { I18n } from '../src';
2
-
3
- describe('i18n test', () => {
4
- test('Init Default language', () => {
5
- const i18n = new I18n();
6
- const EN_LANGUAGE = {
7
- lib_name: 'Library',
8
- test_name: 'test {name}',
9
- };
10
-
11
- const ZH_LANGUAGE = {
12
- lib_name: '工具库',
13
- test_name: '测试 {name}',
14
- };
15
- const languageKeys = i18n.init('en', { en: EN_LANGUAGE, zh: ZH_LANGUAGE });
16
- expect(i18n.t(languageKeys.lib_name)).toBe(EN_LANGUAGE.lib_name);
17
- expect(i18n.t(languageKeys.test_name, { name: 'library' })).toBe(
18
- 'test library',
19
- );
20
- });
21
- test('Change language', () => {
22
- const i18n = new I18n();
23
- const EN_LANGUAGE = {
24
- lib_name: 'Library',
25
- test_name: 'test {name}',
26
- };
27
-
28
- const ZH_LANGUAGE = {
29
- lib_name: '工具库',
30
- test_name: '测试 {name}',
31
- };
32
- const languageKeys = i18n.init('en', { en: EN_LANGUAGE, zh: ZH_LANGUAGE });
33
- i18n.changeLanguage({
34
- locale: 'zh',
35
- });
36
- expect(i18n.t(languageKeys.lib_name)).toBe(ZH_LANGUAGE.lib_name);
37
- expect(i18n.t(languageKeys.test_name, { name: 'library' })).toBe(
38
- '测试 library',
39
- );
40
- });
41
- test('Use object in language resource', () => {
42
- const i18n = new I18n();
43
- const EN_LANGUAGE = {
44
- name: {
45
- lib_name: 'Library',
46
- test_name: 'test {name}',
47
- },
48
- };
49
-
50
- const ZH_LANGUAGE = {
51
- name: {
52
- lib_name: '工具库',
53
- test_name: '测试 {name}',
54
- },
55
- };
56
- const languageKeys = i18n.init('en', { en: EN_LANGUAGE, zh: ZH_LANGUAGE });
57
- i18n.changeLanguage({
58
- locale: 'zh',
59
- });
60
- expect(i18n.t(languageKeys.name.lib_name)).toBe(ZH_LANGUAGE.name.lib_name);
61
- expect(i18n.t(languageKeys.name.test_name, { name: 'library' })).toBe(
62
- '测试 library',
63
- );
64
- });
65
- test('Get language real time', () => {
66
- const i18n = new I18n();
67
- const EN_LANGUAGE = {
68
- name: {
69
- lib_name: 'Library',
70
- test_name: 'test {name}',
71
- },
72
- };
73
-
74
- const ZH_LANGUAGE = {
75
- name: {
76
- lib_name: '工具库',
77
- test_name: '测试 {name}',
78
- },
79
- };
80
- const keys = i18n.init('en', { en: EN_LANGUAGE, zh: ZH_LANGUAGE });
81
- expect(i18n.lang('zh').t(keys.name.lib_name)).toBe('工具库');
82
- });
83
- });
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- }
10
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- },
10
- "include": ["src"]
11
- }