jopi-toolkit 3.0.15 → 3.1.22
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/jk_app/common.d.ts +8 -5
- package/dist/jk_app/common.js +35 -19
- package/dist/jk_app/common.js.map +1 -1
- package/dist/jk_data/index.d.ts +32 -17
- package/dist/jk_data/index.js +55 -25
- package/dist/jk_data/index.js.map +1 -1
- package/dist/jk_events/index.d.ts +2 -0
- package/dist/jk_events/index.js +29 -7
- package/dist/jk_events/index.js.map +1 -1
- package/dist/jk_fs/jBundler_ifBrowser.d.ts +2 -0
- package/dist/jk_fs/jBundler_ifBrowser.js +6 -0
- package/dist/jk_fs/jBundler_ifBrowser.js.map +1 -1
- package/dist/jk_fs/jBundler_ifServer.d.ts +13 -11
- package/dist/jk_fs/jBundler_ifServer.js +53 -7
- package/dist/jk_fs/jBundler_ifServer.js.map +1 -1
- package/dist/jk_logs/jBundler_ifServer.js +5 -0
- package/dist/jk_logs/jBundler_ifServer.js.map +1 -1
- package/dist/jk_process/jBundler_ifServer.d.ts +4 -0
- package/dist/jk_process/jBundler_ifServer.js +31 -0
- package/dist/jk_process/jBundler_ifServer.js.map +1 -1
- package/dist/jk_schemas/index.d.ts +82 -6
- package/dist/jk_schemas/index.js +48 -5
- package/dist/jk_schemas/index.js.map +1 -1
- package/dist/jk_term/index.d.ts +2 -0
- package/dist/jk_term/index.js +2 -0
- package/dist/jk_term/index.js.map +1 -1
- package/dist/jk_tools/jBundler_ifServer.js +19 -7
- package/dist/jk_tools/jBundler_ifServer.js.map +1 -1
- package/package.json +26 -18
- package/src/jk_app/common.js +40 -24
- package/src/jk_app/common.ts +41 -26
- package/src/jk_data/index.js +68 -30
- package/src/jk_data/index.ts +86 -49
- package/src/jk_events/index.js +15 -7
- package/src/jk_events/index.ts +50 -19
- package/src/jk_fs/jBundler_ifBrowser.ts +8 -0
- package/src/jk_fs/jBundler_ifServer.ts +54 -7
- package/src/jk_logs/jBundler_ifServer.ts +6 -0
- package/src/{jk_fs → jk_process}/index.js +0 -1
- package/src/jk_process/jBundler_ifServer.ts +35 -1
- package/src/jk_schemas/index.js +50 -5
- package/src/jk_schemas/index.ts +140 -11
- package/src/jk_term/index.js +2 -0
- package/src/jk_term/index.ts +3 -0
- package/src/jk_tools/jBundler_ifServer.ts +19 -6
- package/src/jk_what/jBundler_ifServer.js +8 -5
- package/dist/jk_schemas/jkSchemas.d.ts +0 -188
- package/dist/jk_schemas/jkSchemas.js +0 -257
- package/dist/jk_schemas/jkSchemas.js.map +0 -1
- package/dist/jk_translate/index.d.ts +0 -21
- package/dist/jk_translate/index.js +0 -56
- package/dist/jk_translate/index.js.map +0 -1
- package/src/jk_fs/common.js +0 -1
- package/src/jk_fs/jBundler_ifServer.js +0 -729
- package/src/jk_translate/index.js +0 -56
- package/src/jk_translate/index.ts +0 -85
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var gCurrentLanguage = 'en';
|
|
2
|
-
var gTranslations = {};
|
|
3
|
-
export function setLanguage(languageName) {
|
|
4
|
-
gCurrentLanguage = languageName;
|
|
5
|
-
}
|
|
6
|
-
export function translate(key, p) {
|
|
7
|
-
return translateTo(gCurrentLanguage, key, p);
|
|
8
|
-
}
|
|
9
|
-
export function translateTo(language, key, p) {
|
|
10
|
-
// Does it exist?
|
|
11
|
-
if (!gTranslations[language]) {
|
|
12
|
-
gTranslations[language] = {};
|
|
13
|
-
}
|
|
14
|
-
var translation;
|
|
15
|
-
// Must use plural?
|
|
16
|
-
//
|
|
17
|
-
var translationKey = key;
|
|
18
|
-
//
|
|
19
|
-
if ((p.count !== undefined) && (p.count > 1)) {
|
|
20
|
-
var pluralKey = "".concat(key, "_plural");
|
|
21
|
-
translation = gTranslations[language][pluralKey];
|
|
22
|
-
}
|
|
23
|
-
// Get the translation.
|
|
24
|
-
if (!translation) {
|
|
25
|
-
translation = gTranslations[language][translationKey];
|
|
26
|
-
}
|
|
27
|
-
// Not found?
|
|
28
|
-
if (!translation) {
|
|
29
|
-
if (p.default) {
|
|
30
|
-
gTranslations[language][translationKey] = p.default;
|
|
31
|
-
return p.default;
|
|
32
|
-
}
|
|
33
|
-
translation = "[trNotFound:".concat(key, "]");
|
|
34
|
-
}
|
|
35
|
-
// Replace the parameters in the translation.
|
|
36
|
-
if (p.params && translation.includes("$")) {
|
|
37
|
-
for (var _i = 0, _a = Object.entries(p.params); _i < _a.length; _i++) {
|
|
38
|
-
var _b = _a[_i], paramKey = _b[0], paramValue = _b[1];
|
|
39
|
-
var placeholder = "$" + paramKey;
|
|
40
|
-
translation = translation.replace(placeholder, String(paramValue));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return translation;
|
|
44
|
-
}
|
|
45
|
-
export function addTranslation(language, key, value) {
|
|
46
|
-
if (!gTranslations[language]) {
|
|
47
|
-
gTranslations[language] = {};
|
|
48
|
-
}
|
|
49
|
-
gTranslations[language][key] = value;
|
|
50
|
-
}
|
|
51
|
-
export function addTranslations(language, newTranslations) {
|
|
52
|
-
if (!gTranslations[language]) {
|
|
53
|
-
gTranslations[language] = {};
|
|
54
|
-
}
|
|
55
|
-
Object.assign(gTranslations[language], newTranslations);
|
|
56
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
let gCurrentLanguage = 'en';
|
|
2
|
-
const gTranslations: { [language: string]: { [key: string]: string } } = {};
|
|
3
|
-
|
|
4
|
-
export interface TranslationRequest {
|
|
5
|
-
/**
|
|
6
|
-
* The default value for the translation.
|
|
7
|
-
*/
|
|
8
|
-
default?: string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The parameters to use for values with parameters
|
|
12
|
-
*/
|
|
13
|
-
params?: any;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* If 'count' is more than one, then use plural form.
|
|
17
|
-
*/
|
|
18
|
-
count?: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function setLanguage(languageName: string): void {
|
|
22
|
-
gCurrentLanguage = languageName;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function translate(key: string, p: TranslationRequest): string {
|
|
26
|
-
return translateTo(gCurrentLanguage, key, p);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function translateTo(language: string, key: string, p: TranslationRequest): string {
|
|
30
|
-
// Does it exist?
|
|
31
|
-
if (!gTranslations[language]) {
|
|
32
|
-
gTranslations[language] = {};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let translation: string | undefined;
|
|
36
|
-
|
|
37
|
-
// Must use plural?
|
|
38
|
-
//
|
|
39
|
-
let translationKey = key;
|
|
40
|
-
//
|
|
41
|
-
if ((p.count !== undefined) && (p.count > 1)) {
|
|
42
|
-
const pluralKey = `${key}_plural`;
|
|
43
|
-
translation = gTranslations[language][pluralKey]
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Get the translation.
|
|
47
|
-
if (!translation) {
|
|
48
|
-
translation = gTranslations[language][translationKey];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Not found?
|
|
52
|
-
if (!translation) {
|
|
53
|
-
if (p.default) {
|
|
54
|
-
gTranslations[language][translationKey] = p.default;
|
|
55
|
-
return p.default;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
translation = `[trNotFound:${key}]`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Replace the parameters in the translation.
|
|
62
|
-
if (p.params && translation.includes("$")) {
|
|
63
|
-
for (const [paramKey, paramValue] of Object.entries(p.params)) {
|
|
64
|
-
const placeholder = "$" + paramKey;
|
|
65
|
-
translation = translation.replace(placeholder, String(paramValue));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return translation;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function addTranslation(language: string, key: string, value: string): void {
|
|
73
|
-
if (!gTranslations[language]) {
|
|
74
|
-
gTranslations[language] = {};
|
|
75
|
-
}
|
|
76
|
-
gTranslations[language][key] = value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function addTranslations(language: string, newTranslations: { [key: string]: string }): void {
|
|
80
|
-
if (!gTranslations[language]) {
|
|
81
|
-
gTranslations[language] = {};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Object.assign(gTranslations[language], newTranslations);
|
|
85
|
-
}
|