@leyyo/localization 1.1.1 → 1.1.3
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/README.md +3 -3
- package/dist/base/base-localization.handler.d.ts +1 -1
- package/dist/base/base-localization.handler.js +18 -12
- package/dist/base/index.d.ts +2 -2
- package/dist/base/index.js +2 -19
- package/dist/base/index.types.js +1 -3
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -19
- package/dist/config/index.types.d.ts +3 -5
- package/dist/config/index.types.js +1 -3
- package/dist/config/localization.config.d.ts +1 -1
- package/dist/config/localization.config.js +33 -21
- package/dist/country/country.handler.d.ts +1 -1
- package/dist/country/country.handler.js +13 -23
- package/dist/country/country.map.d.ts +2 -2
- package/dist/country/country.map.js +252 -256
- package/dist/country/index.d.ts +2 -3
- package/dist/country/index.js +2 -20
- package/dist/country/index.types.d.ts +2 -3
- package/dist/country/index.types.js +1 -3
- package/dist/exchange/exchange.handler.d.ts +1 -1
- package/dist/exchange/exchange.handler.js +14 -25
- package/dist/exchange/exchange.map.d.ts +2 -2
- package/dist/exchange/exchange.map.js +36 -9
- package/dist/exchange/index.d.ts +2 -3
- package/dist/exchange/index.js +2 -20
- package/dist/exchange/index.types.d.ts +2 -3
- package/dist/exchange/index.types.js +1 -3
- package/dist/index.d.ts +11 -7
- package/dist/index.foretell.d.ts +1 -0
- package/dist/index.foretell.js +19 -0
- package/dist/index.js +11 -24
- package/dist/index.loader.d.ts +1 -0
- package/dist/index.loader.js +13 -0
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -5
- package/dist/language/index.d.ts +2 -3
- package/dist/language/index.js +2 -20
- package/dist/language/index.types.d.ts +2 -2
- package/dist/language/index.types.js +1 -3
- package/dist/language/language.handler.d.ts +1 -11
- package/dist/language/language.handler.js +13 -21
- package/dist/language/language.map.d.ts +2 -2
- package/dist/language/language.map.js +185 -189
- package/dist/literal/browser-type.d.ts +7 -0
- package/dist/literal/browser-type.js +2 -0
- package/dist/{country → literal}/country-code.d.ts +1 -1
- package/dist/literal/country-code.js +257 -0
- package/dist/literal/cpu-architecture.d.ts +7 -0
- package/dist/literal/cpu-architecture.js +20 -0
- package/dist/literal/device-type.d.ts +7 -0
- package/dist/literal/device-type.js +11 -0
- package/dist/literal/engine-type.d.ts +7 -0
- package/dist/literal/engine-type.js +23 -0
- package/dist/{exchange → literal}/exchange-code.d.ts +1 -1
- package/dist/literal/exchange-code.js +157 -0
- package/dist/literal/index.d.ts +9 -0
- package/dist/literal/index.js +9 -0
- package/dist/{language → literal}/language-code.d.ts +1 -1
- package/dist/literal/language-code.js +187 -0
- package/dist/{locale → literal}/locale-code.d.ts +1 -1
- package/dist/literal/locale-code.js +199 -0
- package/dist/{timezone → literal}/timezone-code.d.ts +1 -1
- package/dist/literal/timezone-code.js +605 -0
- package/dist/locale/index.d.ts +2 -3
- package/dist/locale/index.js +2 -20
- package/dist/locale/index.types.d.ts +2 -4
- package/dist/locale/index.types.js +1 -3
- package/dist/locale/locale.handler.d.ts +1 -17
- package/dist/locale/locale.handler.js +17 -28
- package/dist/locale/locale.map.d.ts +2 -2
- package/dist/locale/locale.map.js +84 -88
- package/dist/parser/index.d.ts +2 -2
- package/dist/parser/index.js +2 -19
- package/dist/parser/index.types.d.ts +4 -24
- package/dist/parser/index.types.js +1 -3
- package/dist/parser/localization.parser.d.ts +1 -1
- package/dist/parser/localization.parser.js +112 -111
- package/dist/timezone/index.d.ts +2 -3
- package/dist/timezone/index.js +2 -20
- package/dist/timezone/index.types.d.ts +2 -3
- package/dist/timezone/index.types.js +1 -3
- package/dist/timezone/timezone.handler.d.ts +1 -1
- package/dist/timezone/timezone.handler.js +21 -24
- package/dist/timezone/timezone.map.d.ts +2 -2
- package/dist/timezone/timezone.map.js +603 -607
- package/package.json +23 -23
- package/dist/base/base-localization.handler.js.map +0 -1
- package/dist/base/index.js.map +0 -1
- package/dist/base/index.types.js.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/index.types.js.map +0 -1
- package/dist/config/localization.config.js.map +0 -1
- package/dist/country/country-code.js +0 -19
- package/dist/country/country-code.js.map +0 -1
- package/dist/country/country.handler.js.map +0 -1
- package/dist/country/country.map.js.map +0 -1
- package/dist/country/index.js.map +0 -1
- package/dist/country/index.types.js.map +0 -1
- package/dist/exchange/exchange-code.js +0 -23
- package/dist/exchange/exchange-code.js.map +0 -1
- package/dist/exchange/exchange.handler.js.map +0 -1
- package/dist/exchange/exchange.map.js.map +0 -1
- package/dist/exchange/index.js.map +0 -1
- package/dist/exchange/index.types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/language/index.js.map +0 -1
- package/dist/language/index.types.js.map +0 -1
- package/dist/language/language-code.js +0 -33
- package/dist/language/language-code.js.map +0 -1
- package/dist/language/language.handler.js.map +0 -1
- package/dist/language/language.map.js.map +0 -1
- package/dist/locale/index.js.map +0 -1
- package/dist/locale/index.types.js.map +0 -1
- package/dist/locale/locale-code.js +0 -25
- package/dist/locale/locale-code.js.map +0 -1
- package/dist/locale/locale.handler.js.map +0 -1
- package/dist/locale/locale.map.js.map +0 -1
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/index.types.js.map +0 -1
- package/dist/parser/localization.parser.js.map +0 -1
- package/dist/timezone/index.js.map +0 -1
- package/dist/timezone/index.types.js.map +0 -1
- package/dist/timezone/timezone-code.js +0 -109
- package/dist/timezone/timezone-code.js.map +0 -1
- package/dist/timezone/timezone.handler.js.map +0 -1
- package/dist/timezone/timezone.map.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Leyyo: Localization
|
|
1
|
+
# Leyyo: Localization
|
|
2
2
|
Common library for Leyyo framework
|
|
3
3
|
|
|
4
4
|
## Import
|
|
5
|
-
- `npm i @leyyo/localization
|
|
5
|
+
- `npm i @leyyo/localization`
|
|
6
6
|
|
|
7
7
|
## Usage (Runtime)
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ Common library for Leyyo framework
|
|
|
12
12
|
> @see [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
|
|
13
13
|
>
|
|
14
14
|
```typescript
|
|
15
|
-
import {countryHandler} from "@leyyo/localization
|
|
15
|
+
import {countryHandler} from "@leyyo/localization";
|
|
16
16
|
|
|
17
17
|
/*
|
|
18
18
|
* Country exists
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseLocalizationHandlerLike, BaseLocalizationHandlerRaw, BaseLocalizationHandlerView } from "./index.types.js";
|
|
2
2
|
/** @inheritDoc */
|
|
3
3
|
export declare abstract class BaseLocalizationHandler<E extends string, W extends BaseLocalizationHandlerView<E>, R extends BaseLocalizationHandlerRaw> implements BaseLocalizationHandlerLike<E, W, R> {
|
|
4
4
|
/**
|
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseLocalizationHandler = void 0;
|
|
4
1
|
/** @inheritDoc */
|
|
5
|
-
class BaseLocalizationHandler {
|
|
2
|
+
export class BaseLocalizationHandler {
|
|
3
|
+
/**
|
|
4
|
+
* Raw records which is loaded from corresponding map file
|
|
5
|
+
* */
|
|
6
|
+
_raw;
|
|
7
|
+
/** @inheritDoc */
|
|
8
|
+
codes;
|
|
6
9
|
/** @inheritDoc */
|
|
7
10
|
has(code) {
|
|
8
|
-
if (typeof code !==
|
|
11
|
+
if (typeof code !== "string") {
|
|
9
12
|
return false;
|
|
10
13
|
}
|
|
11
14
|
return this._raw[code] !== undefined;
|
|
12
15
|
}
|
|
13
16
|
/** @inheritDoc */
|
|
14
17
|
getRaw(code) {
|
|
15
|
-
if (typeof code !==
|
|
18
|
+
if (typeof code !== "string") {
|
|
16
19
|
return undefined;
|
|
17
20
|
}
|
|
18
21
|
return this._raw[code];
|
|
19
22
|
}
|
|
20
23
|
/** @inheritDoc */
|
|
21
24
|
getName(code) {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
if (typeof code !== "string") {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return this.getRaw(code)?.n ?? code;
|
|
24
29
|
}
|
|
25
30
|
/** @inheritDoc */
|
|
26
31
|
getAll() {
|
|
27
|
-
return this.codes.map(code => this.get(code));
|
|
32
|
+
return this.codes.map((code) => this.get(code));
|
|
28
33
|
}
|
|
29
34
|
/** @inheritDoc */
|
|
30
35
|
getSelected(...codes) {
|
|
31
|
-
return codes
|
|
36
|
+
return codes
|
|
37
|
+
.filter((code) => typeof code === "string")
|
|
38
|
+
.filter((code) => this.codes.includes(code))
|
|
39
|
+
.map((code) => this.get(code));
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
|
-
exports.BaseLocalizationHandler = BaseLocalizationHandler;
|
|
35
|
-
//# sourceMappingURL=base-localization.handler.js.map
|
package/dist/base/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./base-localization.handler.js";
|
package/dist/base/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.types"), exports);
|
|
18
|
-
__exportStar(require("./base-localization.handler"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./base-localization.handler.js";
|
package/dist/base/index.types.js
CHANGED
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./localization.config.js";
|
package/dist/config/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.types"), exports);
|
|
18
|
-
__exportStar(require("./localization.config"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./localization.config.js";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LocaleCode } from "../
|
|
3
|
-
import { LanguageCode } from "../language";
|
|
4
|
-
import { CountryCode } from "../country";
|
|
1
|
+
import { BuilderAny } from "@leyyo/builder";
|
|
2
|
+
import { CountryCode, LanguageCode, LocaleCode } from "../literal/index.js";
|
|
5
3
|
export interface LocalizationConfigLike {
|
|
6
4
|
readonly authorizationKeys: string[];
|
|
7
5
|
readonly applicationKeys: string[];
|
|
@@ -19,4 +17,4 @@ export interface LocalizationConfigLike {
|
|
|
19
17
|
export type ReplacerLike<T extends string, V> = {
|
|
20
18
|
[K in T]?: V;
|
|
21
19
|
};
|
|
22
|
-
export type LocalizationConfigOmit = Omit<LocalizationConfigLike,
|
|
20
|
+
export type LocalizationConfigOmit = Omit<LocalizationConfigLike, "builder">;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LocalizationConfigLike } from "./index.types.js";
|
|
2
2
|
export declare const localizationConfig: LocalizationConfigLike;
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localizationConfig = void 0;
|
|
4
|
-
const builder_1 = require("@leyyo/builder");
|
|
1
|
+
import { Builder } from "@leyyo/builder";
|
|
5
2
|
class LocalizationConfig {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
authorizationKeys = ["authorization", "api-key"];
|
|
4
|
+
applicationKeys = ["application", "x-application"];
|
|
5
|
+
correlationKeys = ["x-correlation", "x-correlation-id"];
|
|
6
|
+
refererKeys = [
|
|
7
|
+
"x-fwd-referer",
|
|
8
|
+
"x-fwd-referrer",
|
|
9
|
+
"x-referer",
|
|
10
|
+
"x-referrer",
|
|
11
|
+
"referer",
|
|
12
|
+
"referrer",
|
|
13
|
+
];
|
|
14
|
+
userAgentKeys = ["x-fwd-user-agent", "x-user-agent", "user-agent"];
|
|
15
|
+
acceptLanguageKeys = [
|
|
16
|
+
"x-fwd-accept-language",
|
|
17
|
+
"x-accept-language",
|
|
18
|
+
"accept-language",
|
|
19
|
+
];
|
|
20
|
+
ipAddressKeys = [
|
|
21
|
+
"x-real-ip",
|
|
22
|
+
"x-client-ip",
|
|
23
|
+
"fastly-client-ip",
|
|
24
|
+
"true-client-ip",
|
|
25
|
+
"cf-connecting-ip",
|
|
26
|
+
"x-cluster-client-ip",
|
|
27
|
+
"x-forwarded-for",
|
|
28
|
+
];
|
|
29
|
+
applicationDelimiter = ":";
|
|
30
|
+
countryReplacer = {};
|
|
31
|
+
languageReplacer = {};
|
|
32
|
+
localeReplacer = {};
|
|
19
33
|
builder() {
|
|
20
|
-
return
|
|
21
|
-
.$setItem((key, value) => {
|
|
34
|
+
return Builder.build(this).$setItem((key, value) => {
|
|
22
35
|
this[key] = value;
|
|
23
36
|
});
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=localization.config.js.map
|
|
39
|
+
export const localizationConfig = new LocalizationConfig();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CountryHandlerLike } from "./index.types.js";
|
|
2
2
|
export declare const countryHandler: CountryHandlerLike;
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const country_code_1 = require("./country-code");
|
|
5
|
-
const country_map_1 = require("./country.map");
|
|
6
|
-
const base_1 = require("../base");
|
|
1
|
+
import { CountryCodeItems } from "../literal/index.js";
|
|
2
|
+
import { countryMap } from "./country.map.js";
|
|
3
|
+
import { BaseLocalizationHandler } from "../base/index.js";
|
|
7
4
|
/** @inheritDoc */
|
|
8
|
-
class CountryHandler extends
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** @inheritDoc */
|
|
14
|
-
this.codes = country_code_1.CountryCodeItems;
|
|
15
|
-
}
|
|
5
|
+
class CountryHandler extends BaseLocalizationHandler {
|
|
6
|
+
/** @inheritDoc */
|
|
7
|
+
_raw = countryMap;
|
|
8
|
+
/** @inheritDoc */
|
|
9
|
+
codes = CountryCodeItems;
|
|
16
10
|
/** @inheritDoc */
|
|
17
11
|
getAlpha3(code) {
|
|
18
|
-
|
|
19
|
-
return (_a = this.getRaw(code)) === null || _a === void 0 ? void 0 : _a.y;
|
|
12
|
+
return this.getRaw(code)?.y;
|
|
20
13
|
}
|
|
21
14
|
/** @inheritDoc */
|
|
22
15
|
getLanguages(code) {
|
|
23
|
-
|
|
24
|
-
return (_a = this.getRaw(code).l) !== null && _a !== void 0 ? _a : [];
|
|
16
|
+
return this.getRaw(code).l ?? [];
|
|
25
17
|
}
|
|
26
18
|
/** @inheritDoc */
|
|
27
19
|
findByLanguage(languageCode) {
|
|
28
|
-
if (typeof languageCode !==
|
|
20
|
+
if (typeof languageCode !== "string") {
|
|
29
21
|
return [];
|
|
30
22
|
}
|
|
31
23
|
const result = [];
|
|
@@ -38,14 +30,12 @@ class CountryHandler extends base_1.BaseLocalizationHandler {
|
|
|
38
30
|
}
|
|
39
31
|
/** @inheritDoc */
|
|
40
32
|
get(code) {
|
|
41
|
-
var _a;
|
|
42
33
|
const item = this.getRaw(code);
|
|
43
34
|
if (!item) {
|
|
44
35
|
return { code, name: code, alpha3: undefined, languages: [] };
|
|
45
36
|
}
|
|
46
|
-
return { code, name: item.n, alpha3: item.y, languages:
|
|
37
|
+
return { code, name: item.n, alpha3: item.y, languages: item.l ?? [] };
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
40
|
// noinspection JSUnusedGlobalSymbols
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=country.handler.js.map
|
|
41
|
+
export const countryHandler = new CountryHandler();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CountryCode } from "../literal/index.js";
|
|
2
|
+
import { CountryRaw } from "./index.types.js";
|
|
3
3
|
export declare const countryMap: Record<CountryCode, CountryRaw>;
|