@modern-js/plugin-i18n 1.2.8-alpha.0 → 1.16.0

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,12 +1,39 @@
1
1
  # @modern-js/plugin-i18n
2
2
 
3
- ## 1.2.8-alpha.0
3
+ ## 1.16.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [9cd364e06]
8
- - Updated dependencies [a90bc96bd]
9
- - @modern-js/utils@1.7.9-alpha.0
7
+ - Updated dependencies [641592f52]
8
+ - Updated dependencies [3904b30a5]
9
+ - Updated dependencies [1100dd58c]
10
+ - Updated dependencies [e04e6e76a]
11
+ - Updated dependencies [81c66e4a4]
12
+ - Updated dependencies [2c305b6f5]
13
+ - @modern-js/utils@1.16.0
14
+
15
+ ## 1.15.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [8658a78]
20
+ - Updated dependencies [05d4a4f]
21
+ - Updated dependencies [ad05af9]
22
+ - Updated dependencies [5d53d1c]
23
+ - Updated dependencies [37cd159]
24
+ - @modern-js/utils@1.15.0
25
+
26
+ ## 1.3.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 33cebd2: chore(plugin-i18n): merge `@modern-js/i18n-cli-language-detector` to `@modern-js/plugin-i18n`
31
+
32
+ chore(plugin-i18n): 合并 `@modern-js/i18n-cli-language-detector` 包到 `@modern-js/plugin-i18n` 包作为子路径
33
+
34
+ ### Patch Changes
35
+
36
+ - @modern-js/utils@1.7.12
10
37
 
11
38
  ## 1.2.7
12
39
 
@@ -0,0 +1,30 @@
1
+ class I18CLILanguageDetector {
2
+ formatShellLocale(rawLC) {
3
+ if (!rawLC) {
4
+ return '';
5
+ } // Get array of available languages
6
+
7
+
8
+ const LCs = rawLC.split(':');
9
+ const LC = LCs[0] // Get `en_US` part from `en_US.UTF-8`
10
+ .split('.')[0] // Slice en_US to en
11
+ .split('_')[0] // slice en-US to en
12
+ .split('-')[0];
13
+
14
+ if (LC === 'C') {
15
+ return '';
16
+ }
17
+
18
+ return LC;
19
+ }
20
+
21
+ detect() {
22
+ var _ref, _ref2, _ref3, _process$env$LC_ALL;
23
+
24
+ const shellLocale = (_ref = (_ref2 = (_ref3 = (_process$env$LC_ALL = process.env.LC_ALL) !== null && _process$env$LC_ALL !== void 0 ? _process$env$LC_ALL : process.env.LC_MESSAGES) !== null && _ref3 !== void 0 ? _ref3 : process.env.LANG) !== null && _ref2 !== void 0 ? _ref2 : process.env.LANGUAGE) !== null && _ref !== void 0 ? _ref : Intl.DateTimeFormat().resolvedOptions().locale;
25
+ return this.formatShellLocale(shellLocale);
26
+ }
27
+
28
+ }
29
+
30
+ export { I18CLILanguageDetector };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.I18CLILanguageDetector = void 0;
7
+
8
+ class I18CLILanguageDetector {
9
+ formatShellLocale(rawLC) {
10
+ if (!rawLC) {
11
+ return '';
12
+ } // Get array of available languages
13
+
14
+
15
+ const LCs = rawLC.split(':');
16
+ const LC = LCs[0] // Get `en_US` part from `en_US.UTF-8`
17
+ .split('.')[0] // Slice en_US to en
18
+ .split('_')[0] // slice en-US to en
19
+ .split('-')[0];
20
+
21
+ if (LC === 'C') {
22
+ return '';
23
+ }
24
+
25
+ return LC;
26
+ }
27
+
28
+ detect() {
29
+ var _ref, _ref2, _ref3, _process$env$LC_ALL;
30
+
31
+ const shellLocale = (_ref = (_ref2 = (_ref3 = (_process$env$LC_ALL = process.env.LC_ALL) !== null && _process$env$LC_ALL !== void 0 ? _process$env$LC_ALL : process.env.LC_MESSAGES) !== null && _ref3 !== void 0 ? _ref3 : process.env.LANG) !== null && _ref2 !== void 0 ? _ref2 : process.env.LANGUAGE) !== null && _ref !== void 0 ? _ref : Intl.DateTimeFormat().resolvedOptions().locale;
32
+ return this.formatShellLocale(shellLocale);
33
+ }
34
+
35
+ }
36
+
37
+ exports.I18CLILanguageDetector = I18CLILanguageDetector;
@@ -0,0 +1,42 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+
4
+ var I18CLILanguageDetector = /*#__PURE__*/function () {
5
+ function I18CLILanguageDetector() {
6
+ _classCallCheck(this, I18CLILanguageDetector);
7
+ }
8
+
9
+ _createClass(I18CLILanguageDetector, [{
10
+ key: "formatShellLocale",
11
+ value: function formatShellLocale(rawLC) {
12
+ if (!rawLC) {
13
+ return '';
14
+ } // Get array of available languages
15
+
16
+
17
+ var LCs = rawLC.split(':');
18
+ var LC = LCs[0] // Get `en_US` part from `en_US.UTF-8`
19
+ .split('.')[0] // Slice en_US to en
20
+ .split('_')[0] // slice en-US to en
21
+ .split('-')[0];
22
+
23
+ if (LC === 'C') {
24
+ return '';
25
+ }
26
+
27
+ return LC;
28
+ }
29
+ }, {
30
+ key: "detect",
31
+ value: function detect() {
32
+ var _ref, _ref2, _ref3, _process$env$LC_ALL;
33
+
34
+ var shellLocale = (_ref = (_ref2 = (_ref3 = (_process$env$LC_ALL = process.env.LC_ALL) !== null && _process$env$LC_ALL !== void 0 ? _process$env$LC_ALL : process.env.LC_MESSAGES) !== null && _ref3 !== void 0 ? _ref3 : process.env.LANG) !== null && _ref2 !== void 0 ? _ref2 : process.env.LANGUAGE) !== null && _ref !== void 0 ? _ref : Intl.DateTimeFormat().resolvedOptions().locale;
35
+ return this.formatShellLocale(shellLocale);
36
+ }
37
+ }]);
38
+
39
+ return I18CLILanguageDetector;
40
+ }();
41
+
42
+ export { I18CLILanguageDetector };
@@ -0,0 +1,6 @@
1
+ declare class I18CLILanguageDetector {
2
+ private formatShellLocale;
3
+ detect(): string;
4
+ }
5
+
6
+ export { I18CLILanguageDetector };
package/package.json CHANGED
@@ -11,12 +11,19 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.8-alpha.0",
14
+ "version": "1.16.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
18
18
  "module": "./dist/js/treeshaking/index.js",
19
19
  "jsnext:modern": "./dist/js/modern/index.js",
20
+ "typesVersions": {
21
+ "*": {
22
+ "language-detector": [
23
+ "./dist/types/language-detector.d.ts"
24
+ ]
25
+ }
26
+ },
20
27
  "exports": {
21
28
  ".": {
22
29
  "node": {
@@ -24,19 +31,26 @@
24
31
  "require": "./dist/js/node/index.js"
25
32
  },
26
33
  "default": "./dist/js/treeshaking/index.js"
34
+ },
35
+ "./language-detector": {
36
+ "node": {
37
+ "import": "./dist/js/modern/language-detector.js",
38
+ "require": "./dist/js/node/language-detector.js"
39
+ },
40
+ "default": "./dist/js/treeshaking/language-detector.js"
27
41
  }
28
42
  },
29
43
  "dependencies": {
30
44
  "@babel/runtime": "^7.18.0",
31
- "@modern-js/utils": "^1.7.9-alpha.0"
45
+ "@modern-js/utils": "1.16.0"
32
46
  },
33
47
  "devDependencies": {
34
48
  "@types/jest": "^27",
35
49
  "@types/node": "^14",
36
50
  "typescript": "^4",
37
- "@scripts/build": "0.0.0",
51
+ "@scripts/build": "1.15.0",
38
52
  "jest": "^27",
39
- "@scripts/jest-config": "0.0.0"
53
+ "@scripts/jest-config": "1.15.0"
40
54
  },
41
55
  "sideEffects": false,
42
56
  "modernConfig": {},