ag-common 0.0.217 → 0.0.218
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.
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
declare type TLangExceptEn = 'id' | 'vi';
|
|
1
|
+
declare type TLangExceptEn = 'id' | 'vi' | 'pr';
|
|
2
2
|
export declare type TLang = TLangExceptEn | 'en';
|
|
3
3
|
export declare const AllLang: TLang[];
|
|
4
|
+
/**
|
|
5
|
+
* null = wont translate. undefined = fallback to eng
|
|
6
|
+
*/
|
|
4
7
|
export declare type TResource = {
|
|
5
|
-
[k in TLangExceptEn]?: string;
|
|
8
|
+
[k in TLangExceptEn]?: string | null;
|
|
6
9
|
} & {
|
|
7
10
|
en: string;
|
|
8
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.t = exports.getValidatedLang = exports.AllLang = void 0;
|
|
4
|
-
exports.AllLang = ['en', 'id', 'vi'];
|
|
4
|
+
exports.AllLang = ['en', 'id', 'vi', 'pr'];
|
|
5
5
|
const getValidatedLang = (raw) => {
|
|
6
6
|
const f = exports.AllLang.find((l) => l === raw);
|
|
7
7
|
if (!f) {
|
|
@@ -10,5 +10,11 @@ const getValidatedLang = (raw) => {
|
|
|
10
10
|
return f;
|
|
11
11
|
};
|
|
12
12
|
exports.getValidatedLang = getValidatedLang;
|
|
13
|
-
const t = (res, lang) => {
|
|
13
|
+
const t = (res, lang) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (res[lang] === null) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
return (_a = res[lang]) !== null && _a !== void 0 ? _a : res.en;
|
|
19
|
+
};
|
|
14
20
|
exports.t = t;
|