@peassoft/mnr-langs 1.0.1 → 1.2.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/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,27 @@ export declare const defaultLanguage: "en";
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export type SupportedLanguage = UnionOf<typeof supportedLanguages>;
|
|
26
|
+
/**
|
|
27
|
+
* Descriptor of a supported language
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export type SupportedLanguageDescriptor = {
|
|
32
|
+
code: SupportedLanguage;
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Return supported languages descriptors
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function supportedLanguagesDescriptors(): ReadonlyArray<SupportedLanguageDescriptor>;
|
|
41
|
+
/**
|
|
42
|
+
* Return language descriptor for the default language
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare function defautlLanguageDescriptor(): SupportedLanguageDescriptor;
|
|
26
47
|
/**
|
|
27
48
|
* Get all remaining supported languages except the given one.
|
|
28
49
|
*
|
|
@@ -37,5 +58,13 @@ export declare function getRemainingLanguages(lang: SupportedLanguage): Supporte
|
|
|
37
58
|
* @public
|
|
38
59
|
*/
|
|
39
60
|
export declare function langToPathSegment(lang: SupportedLanguage): '/' | `/${typeof lang}/`;
|
|
61
|
+
/**
|
|
62
|
+
* Validate and type assert a value as a supported language.
|
|
63
|
+
*
|
|
64
|
+
* If the value is not a supported language, returns `null`.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateLanguage(value: unknown): SupportedLanguage | null;
|
|
40
69
|
export {};
|
|
41
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,KAAK,OAAO,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,uBAAwB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,GAAG,IAAI,OAAO,IAAI,GAAG,CAGnF"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,KAAK,OAAO,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,uBAAwB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,IAAI,aAAa,CAAC,2BAA2B,CAAC,CAK1F;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,2BAA2B,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,GAAG,IAAI,OAAO,IAAI,GAAG,CAGnF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,GAAG,IAAI,CAKzE"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,25 @@ export const supportedLanguages = ['en', 'ru'];
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export const defaultLanguage = supportedLanguages[0];
|
|
18
|
+
/**
|
|
19
|
+
* Return supported languages descriptors
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export function supportedLanguagesDescriptors() {
|
|
24
|
+
return [
|
|
25
|
+
{ code: 'en', name: 'English' },
|
|
26
|
+
{ code: 'ru', name: 'Русский' },
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Return language descriptor for the default language
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export function defautlLanguageDescriptor() {
|
|
35
|
+
return { code: 'en', name: 'English' };
|
|
36
|
+
}
|
|
18
37
|
/**
|
|
19
38
|
* Get all remaining supported languages except the given one.
|
|
20
39
|
*
|
|
@@ -35,4 +54,17 @@ export function langToPathSegment(lang) {
|
|
|
35
54
|
return '/';
|
|
36
55
|
return `/${lang}/`;
|
|
37
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Validate and type assert a value as a supported language.
|
|
59
|
+
*
|
|
60
|
+
* If the value is not a supported language, returns `null`.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export function validateLanguage(value) {
|
|
65
|
+
if (typeof value === 'string' && supportedLanguages.includes(value)) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
38
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAmBrD;;;;GAIG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO;QACL,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;QAC/B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;KAChC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAuB;IAC3D,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAuB;IACvD,IAAI,IAAI,KAAK,eAAe;QAAE,OAAO,GAAG,CAAC;IACzC,OAAO,IAAI,IAAI,GAAG,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAA0B,CAAC,EAAE,CAAC;QACzF,OAAO,KAA0B,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peassoft/mnr-langs",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The source of truth for supported UI languages in Memorize'n'Revise",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@memnrev/eslint-v9-config": "^0.4.0",
|
|
17
17
|
"@microsoft/api-extractor": "^7.54.0",
|
|
18
18
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
19
|
+
"asserttt": "^1.0.1",
|
|
19
20
|
"del-cli": "^7.0.0",
|
|
20
21
|
"eslint": "^9.8.0",
|
|
21
22
|
"typescript": "^5.2.0",
|