@prezly/theme-kit-intl 9.6.0 → 10.0.1-alpha.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/build/dictionary.cjs +1 -1
- package/build/dictionary.mjs +0 -1
- package/build/formatting/messages/types.cjs +19 -3
- package/build/formatting/messages/types.mjs +19 -3
- package/build/locales/Locale.cjs +2 -4
- package/build/locales/Locale.mjs +2 -4
- package/build/locales/pickSuportedLocale.test.cjs +1 -2
- package/build/locales/pickSuportedLocale.test.mjs +0 -1
- package/package.json +6 -6
package/build/dictionary.cjs
CHANGED
|
@@ -13,7 +13,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
16
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
16
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
17
17
|
function importDictionary(_x) {
|
|
18
18
|
return _importDictionary.apply(this, arguments);
|
|
19
19
|
}
|
package/build/dictionary.mjs
CHANGED
|
@@ -5,7 +5,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
5
5
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
6
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
7
7
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
9
8
|
import { pickSupportedLocale } from "./locales/index.mjs";
|
|
10
9
|
export function importDictionary(_x) {
|
|
11
10
|
return _importDictionary.apply(this, arguments);
|
|
@@ -4,15 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.IntlMessageFormat = void 0;
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
8
7
|
var IntlMessageFormat;
|
|
9
8
|
(function (_IntlMessageFormat) {
|
|
10
9
|
var Type = /*#__PURE__*/function (Type) {
|
|
10
|
+
/**
|
|
11
|
+
* Raw text
|
|
12
|
+
*/
|
|
11
13
|
Type[Type["LITERAL"] = 0] = "LITERAL";
|
|
14
|
+
/**
|
|
15
|
+
* Variable without any format, e.g. `var` in `this is a {var}`
|
|
16
|
+
*/
|
|
12
17
|
Type[Type["ARGUMENT"] = 1] = "ARGUMENT";
|
|
18
|
+
// NUMBER = 2, // Not implemented
|
|
19
|
+
// DATE = 3, // Not implemented
|
|
20
|
+
// TIME = 4, // Not implemented
|
|
21
|
+
// SELECT = 5, // Not implemented
|
|
22
|
+
/**
|
|
23
|
+
* Variable with plural format
|
|
24
|
+
*/
|
|
13
25
|
Type[Type["PLURAL"] = 6] = "PLURAL";
|
|
14
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Only possible within plural argument.
|
|
28
|
+
* This is the `#` symbol that will be substituted with the count.
|
|
29
|
+
*/
|
|
30
|
+
Type[Type["POUND"] = 7] = "POUND"; // TAG = 8, // Not implemented
|
|
15
31
|
return Type;
|
|
16
|
-
}({});
|
|
32
|
+
}({});
|
|
17
33
|
_IntlMessageFormat.Type = Type;
|
|
18
34
|
})(IntlMessageFormat || (exports.IntlMessageFormat = IntlMessageFormat = {}));
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
1
|
export var IntlMessageFormat;
|
|
3
2
|
(function (_IntlMessageFormat) {
|
|
4
3
|
var Type = /*#__PURE__*/function (Type) {
|
|
4
|
+
/**
|
|
5
|
+
* Raw text
|
|
6
|
+
*/
|
|
5
7
|
Type[Type["LITERAL"] = 0] = "LITERAL";
|
|
8
|
+
/**
|
|
9
|
+
* Variable without any format, e.g. `var` in `this is a {var}`
|
|
10
|
+
*/
|
|
6
11
|
Type[Type["ARGUMENT"] = 1] = "ARGUMENT";
|
|
12
|
+
// NUMBER = 2, // Not implemented
|
|
13
|
+
// DATE = 3, // Not implemented
|
|
14
|
+
// TIME = 4, // Not implemented
|
|
15
|
+
// SELECT = 5, // Not implemented
|
|
16
|
+
/**
|
|
17
|
+
* Variable with plural format
|
|
18
|
+
*/
|
|
7
19
|
Type[Type["PLURAL"] = 6] = "PLURAL";
|
|
8
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Only possible within plural argument.
|
|
22
|
+
* This is the `#` symbol that will be substituted with the count.
|
|
23
|
+
*/
|
|
24
|
+
Type[Type["POUND"] = 7] = "POUND"; // TAG = 8, // Not implemented
|
|
9
25
|
return Type;
|
|
10
|
-
}({});
|
|
26
|
+
}({});
|
|
11
27
|
_IntlMessageFormat.Type = Type;
|
|
12
28
|
})(IntlMessageFormat || (IntlMessageFormat = {}));
|
package/build/locales/Locale.cjs
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Locale = void 0;
|
|
7
7
|
var _isNotUndefined = require("@technically/is-not-undefined");
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
9
|
-
|
|
10
8
|
var KNOWN_SCRIPTS = ['hant', 'hans'];
|
|
11
9
|
var KNOWN_RTL_LANGUAGES = ['ar', 'he', 'ur'];
|
|
12
10
|
var LANG_CODE_REGEX = /^[a-z]{2,3}$/;
|
|
@@ -39,8 +37,8 @@ var Locale;
|
|
|
39
37
|
if (regions.length > 1) {
|
|
40
38
|
throw new Error("Unable to parse the provided locale code: \"".concat(locale, "\". Multiple region codes detected."));
|
|
41
39
|
}
|
|
42
|
-
var scriptCode = scripts
|
|
43
|
-
var regionCode = regions
|
|
40
|
+
var [scriptCode] = scripts;
|
|
41
|
+
var [regionCode] = regions;
|
|
44
42
|
var code = [lang.toLowerCase(), regionCode, scriptCode ? toPascalCase(scriptCode) : undefined].filter(_isNotUndefined.isNotUndefined).join('_');
|
|
45
43
|
var isoCode = code.replace('_', '-');
|
|
46
44
|
var obj = {
|
package/build/locales/Locale.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
|
-
|
|
3
1
|
import { isNotUndefined } from '@technically/is-not-undefined';
|
|
4
2
|
var KNOWN_SCRIPTS = ['hant', 'hans'];
|
|
5
3
|
var KNOWN_RTL_LANGUAGES = ['ar', 'he', 'ur'];
|
|
@@ -33,8 +31,8 @@ export var Locale;
|
|
|
33
31
|
if (regions.length > 1) {
|
|
34
32
|
throw new Error("Unable to parse the provided locale code: \"".concat(locale, "\". Multiple region codes detected."));
|
|
35
33
|
}
|
|
36
|
-
var scriptCode = scripts
|
|
37
|
-
var regionCode = regions
|
|
34
|
+
var [scriptCode] = scripts;
|
|
35
|
+
var [regionCode] = regions;
|
|
38
36
|
var code = [lang.toLowerCase(), regionCode, scriptCode ? toPascalCase(scriptCode) : undefined].filter(isNotUndefined).join('_');
|
|
39
37
|
var isoCode = code.replace('_', '-');
|
|
40
38
|
var obj = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _globals = require("@jest/globals");
|
|
4
3
|
var _constants = require("./constants.cjs");
|
|
5
4
|
var _pickSuportedLocale = require("./pickSuportedLocale.cjs");
|
|
6
5
|
describe('pickSupportedLocale', () => {
|
|
@@ -19,7 +18,7 @@ describe('pickSupportedLocale', () => {
|
|
|
19
18
|
expect((0, _pickSuportedLocale.pickSupportedLocale)('zh_HK')).toBe('zh-CN');
|
|
20
19
|
});
|
|
21
20
|
it('returns default locale code for unsupported languages', () => {
|
|
22
|
-
var consoleSpy =
|
|
21
|
+
var consoleSpy = jest.spyOn(console, 'warn');
|
|
23
22
|
expect((0, _pickSuportedLocale.pickSupportedLocale)('aa')).toBe(_constants.DEFAULT_LOCALE);
|
|
24
23
|
expect(consoleSpy).toHaveBeenCalledWith('Unsupported locale provided: "aa".');
|
|
25
24
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-intl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1-alpha.0",
|
|
4
4
|
"description": "Translations for Prezly themes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.mjs",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"clean": "rimraf build/* *.tsbuildinfo",
|
|
31
|
-
"prebuild": "
|
|
32
|
-
"build": "
|
|
31
|
+
"prebuild": "pnpm clean && pnpm build:locales && pnpm prettier:check",
|
|
32
|
+
"build": "pnpm intl:compile && pnpm build:types && pnpm build:esm && pnpm build:cjs",
|
|
33
33
|
"build:locales": "node ./build-locales.cjs > src/locales/supportedLocales.ts && prettier --write ./src/locales/supportedLocales.ts",
|
|
34
34
|
"build:types": "tsc --project .",
|
|
35
35
|
"build:esm": "babel --config-file=../../babel.esm.json src/ --extensions=.ts --out-dir=build/ --out-file-extension=.mjs",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"typecheck": "tsc --noEmit --emitDeclarationOnly false --project .",
|
|
40
40
|
"prettier:check": "prettier --check './src/**/*.{ts,js}'",
|
|
41
41
|
"prettier:fix": "prettier --write './src/**/*.{ts,js}'",
|
|
42
|
-
"test": "
|
|
42
|
+
"test": "pnpm test:unit && pnpm test:build",
|
|
43
43
|
"test:unit": "jest",
|
|
44
|
-
"test:build": "
|
|
44
|
+
"test:build": "pnpm test:build:i18n && pnpm test:build:i18n:dist && pnpm test:build:cjs && pnpm test:build:esm && pnpm test:build:types",
|
|
45
45
|
"test:build:types": "tsc --noEmit build/index.d.ts",
|
|
46
46
|
"test:build:i18n": "node tests/test-i18n.mjs",
|
|
47
47
|
"test:build:i18n:dist": "echo 'Checking if the build/i18n directory contains 49 files' && ls build/i18n/*.json | cut -d\\/ -f3 | cut -d. -f1 | sort | wc -l | grep -q 49 || (echo 'Fail' && false) && echo 'OK'",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "380f2285666ee87f3c9a5fa0242e220dd19ce86b"
|
|
77
77
|
}
|