@adminforth/i18n 1.8.0 → 1.8.1
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.log +2 -2
- package/dist/index.js +12 -8
- package/index.ts +13 -8
- package/package.json +2 -1
package/build.log
CHANGED
|
@@ -17,5 +17,5 @@ custom/package-lock.json
|
|
|
17
17
|
custom/package.json
|
|
18
18
|
custom/tsconfig.json
|
|
19
19
|
|
|
20
|
-
sent 33,
|
|
21
|
-
total size is 32,230 speedup is 0.
|
|
20
|
+
sent 33,163 bytes received 248 bytes 66,822.00 bytes/sec
|
|
21
|
+
total size is 32,230 speedup is 0.96
|
package/dist/index.js
CHANGED
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes, RAMLock } from "adminforth";
|
|
11
11
|
import iso6391 from 'iso-639-1';
|
|
12
|
-
import { iso31661Alpha2ToAlpha3 } from 'iso-3166';
|
|
13
12
|
import path from 'path';
|
|
14
13
|
import fs from 'fs-extra';
|
|
15
14
|
import chokidar from 'chokidar';
|
|
16
15
|
import { AsyncQueue } from '@sapphire/async-queue';
|
|
17
16
|
import getFlagEmoji from 'country-flag-svg';
|
|
17
|
+
import { parse } from 'bcp-47';
|
|
18
18
|
const processFrontendMessagesQueue = new AsyncQueue();
|
|
19
19
|
const SLAVIC_PLURAL_EXAMPLES = {
|
|
20
20
|
uk: 'яблук | Яблуко | Яблука | Яблук', // zero | singular | 2-4 | 5+
|
|
@@ -52,15 +52,19 @@ function getPrimaryLanguageCode(langCode) {
|
|
|
52
52
|
return String(langCode).split('-')[0];
|
|
53
53
|
}
|
|
54
54
|
function isValidSupportedLanguageTag(langCode) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
try {
|
|
56
|
+
const schema = parse(String(langCode), {
|
|
57
|
+
normalize: true,
|
|
58
|
+
warning: (reason, code, offset) => {
|
|
59
|
+
console.warn(`Warning in validating language tag ${langCode}: reason=${reason}, code=${code}, offset=${offset}`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const isValid = schema && schema.language && schema.language.length === 2;
|
|
63
|
+
return !!isValid;
|
|
58
64
|
}
|
|
59
|
-
|
|
60
|
-
return
|
|
65
|
+
catch (e) {
|
|
66
|
+
return false;
|
|
61
67
|
}
|
|
62
|
-
const regionUpper = region.toUpperCase();
|
|
63
|
-
return /^[A-Z]{2}$/.test(regionUpper) && (regionUpper in iso31661Alpha2ToAlpha3);
|
|
64
68
|
}
|
|
65
69
|
class CachingAdapterMemory {
|
|
66
70
|
constructor() {
|
package/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import fs from 'fs-extra';
|
|
|
8
8
|
import chokidar from 'chokidar';
|
|
9
9
|
import { AsyncQueue } from '@sapphire/async-queue';
|
|
10
10
|
import getFlagEmoji from 'country-flag-svg';
|
|
11
|
-
|
|
11
|
+
import { parse } from 'bcp-47'
|
|
12
12
|
|
|
13
13
|
const processFrontendMessagesQueue = new AsyncQueue();
|
|
14
14
|
|
|
@@ -52,15 +52,20 @@ function getPrimaryLanguageCode(langCode: SupportedLanguage): string {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function isValidSupportedLanguageTag(langCode: SupportedLanguage): boolean {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
try {
|
|
56
|
+
const schema = parse(String(langCode),
|
|
57
|
+
{
|
|
58
|
+
normalize: true,
|
|
59
|
+
warning: (reason, code, offset) => {
|
|
60
|
+
console.warn(`Warning in validating language tag ${langCode}: reason=${reason}, code=${code}, offset=${offset}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
const isValid = schema && schema.language && schema.language.length === 2;
|
|
65
|
+
return !!isValid;
|
|
66
|
+
} catch (e) {
|
|
57
67
|
return false;
|
|
58
68
|
}
|
|
59
|
-
if (!region) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
const regionUpper = region.toUpperCase();
|
|
63
|
-
return /^[A-Z]{2}$/.test(regionUpper) && (regionUpper in iso31661Alpha2ToAlpha3);
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/i18n",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@aws-sdk/client-ses": "^3.654.0",
|
|
32
32
|
"@sapphire/async-queue": "^1.5.5",
|
|
33
|
+
"bcp-47": "^2.1.0",
|
|
33
34
|
"chokidar": "^4.0.1",
|
|
34
35
|
"country-flag-svg": "^1.0.19",
|
|
35
36
|
"fs-extra": "^11.3.2",
|