@vocab/core 1.2.0 → 1.2.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/LICENSE +21 -0
- package/dist/declarations/src/ValidationError.d.ts +5 -5
- package/dist/declarations/src/compile.d.ts +6 -6
- package/dist/declarations/src/config.d.ts +4 -4
- package/dist/declarations/src/generate-language.d.ts +5 -5
- package/dist/declarations/src/icu-handler.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +6 -6
- package/dist/declarations/src/load-translations.d.ts +32 -32
- package/dist/declarations/src/logger.d.ts +3 -3
- package/dist/declarations/src/runtime.d.ts +3 -3
- package/dist/declarations/src/translation-file.d.ts +2 -2
- package/dist/declarations/src/utils.d.ts +26 -26
- package/dist/declarations/src/validate/index.d.ts +3 -3
- package/dist/vocab-core.cjs.dev.js +73 -180
- package/dist/vocab-core.cjs.prod.js +73 -180
- package/dist/vocab-core.esm.js +39 -146
- package/icu-handler/dist/vocab-core-icu-handler.cjs.dev.js +3 -6
- package/icu-handler/dist/vocab-core-icu-handler.cjs.prod.js +3 -6
- package/icu-handler/dist/vocab-core-icu-handler.esm.js +2 -5
- package/package.json +2 -2
- package/translation-file/dist/vocab-core-translation-file.cjs.dev.js +0 -8
- package/translation-file/dist/vocab-core-translation-file.cjs.prod.js +0 -8
- package/translation-file/dist/vocab-core-translation-file.esm.js +0 -8
|
@@ -11,21 +11,18 @@ var IntlMessageFormat__default = /*#__PURE__*/_interopDefault(IntlMessageFormat)
|
|
|
11
11
|
const moduleCache = new WeakMap();
|
|
12
12
|
const getParsedICUMessages = (m, locale) => {
|
|
13
13
|
const moduleCachedResult = moduleCache.get(m);
|
|
14
|
-
|
|
15
14
|
if (moduleCachedResult && moduleCachedResult[locale]) {
|
|
16
15
|
return moduleCachedResult[locale];
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
const parsedICUMessages = {};
|
|
20
|
-
|
|
21
18
|
for (const translation of Object.keys(m)) {
|
|
22
|
-
const intlMessageFormat = new IntlMessageFormat__default[
|
|
19
|
+
const intlMessageFormat = new IntlMessageFormat__default["default"](m[translation], locale);
|
|
23
20
|
parsedICUMessages[translation] = {
|
|
24
21
|
format: params => intlMessageFormat.format(params)
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
moduleCache.set(m, {
|
|
25
|
+
...moduleCachedResult,
|
|
29
26
|
[locale]: parsedICUMessages
|
|
30
27
|
});
|
|
31
28
|
return parsedICUMessages;
|
|
@@ -11,21 +11,18 @@ var IntlMessageFormat__default = /*#__PURE__*/_interopDefault(IntlMessageFormat)
|
|
|
11
11
|
const moduleCache = new WeakMap();
|
|
12
12
|
const getParsedICUMessages = (m, locale) => {
|
|
13
13
|
const moduleCachedResult = moduleCache.get(m);
|
|
14
|
-
|
|
15
14
|
if (moduleCachedResult && moduleCachedResult[locale]) {
|
|
16
15
|
return moduleCachedResult[locale];
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
const parsedICUMessages = {};
|
|
20
|
-
|
|
21
18
|
for (const translation of Object.keys(m)) {
|
|
22
|
-
const intlMessageFormat = new IntlMessageFormat__default[
|
|
19
|
+
const intlMessageFormat = new IntlMessageFormat__default["default"](m[translation], locale);
|
|
23
20
|
parsedICUMessages[translation] = {
|
|
24
21
|
format: params => intlMessageFormat.format(params)
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
moduleCache.set(m, {
|
|
25
|
+
...moduleCachedResult,
|
|
29
26
|
[locale]: parsedICUMessages
|
|
30
27
|
});
|
|
31
28
|
return parsedICUMessages;
|
|
@@ -3,21 +3,18 @@ import IntlMessageFormat from 'intl-messageformat';
|
|
|
3
3
|
const moduleCache = new WeakMap();
|
|
4
4
|
const getParsedICUMessages = (m, locale) => {
|
|
5
5
|
const moduleCachedResult = moduleCache.get(m);
|
|
6
|
-
|
|
7
6
|
if (moduleCachedResult && moduleCachedResult[locale]) {
|
|
8
7
|
return moduleCachedResult[locale];
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
const parsedICUMessages = {};
|
|
12
|
-
|
|
13
10
|
for (const translation of Object.keys(m)) {
|
|
14
11
|
const intlMessageFormat = new IntlMessageFormat(m[translation], locale);
|
|
15
12
|
parsedICUMessages[translation] = {
|
|
16
13
|
format: params => intlMessageFormat.format(params)
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
moduleCache.set(m, {
|
|
17
|
+
...moduleCachedResult,
|
|
21
18
|
[locale]: parsedICUMessages
|
|
22
19
|
});
|
|
23
20
|
return parsedICUMessages;
|
package/package.json
CHANGED
|
@@ -5,38 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function createTranslationFile(translationsByLanguage) {
|
|
6
6
|
function getByLanguage(language) {
|
|
7
7
|
const translationModule = translationsByLanguage[language];
|
|
8
|
-
|
|
9
8
|
if (!translationModule) {
|
|
10
9
|
throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return translationModule;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return {
|
|
17
14
|
getLoadedMessages(language, locale) {
|
|
18
15
|
const translationModule = getByLanguage(language);
|
|
19
16
|
return translationModule.getValue(locale || language) || null;
|
|
20
17
|
},
|
|
21
|
-
|
|
22
18
|
getMessages(language, locale) {
|
|
23
19
|
const translationModule = getByLanguage(language);
|
|
24
20
|
return translationModule.load().then(() => {
|
|
25
21
|
const result = translationModule.getValue(locale || language);
|
|
26
|
-
|
|
27
22
|
if (!result) {
|
|
28
23
|
throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return result;
|
|
32
26
|
});
|
|
33
27
|
},
|
|
34
|
-
|
|
35
28
|
load(language) {
|
|
36
29
|
const translationModule = getByLanguage(language);
|
|
37
30
|
return translationModule.load();
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
};
|
|
41
33
|
}
|
|
42
34
|
|
|
@@ -5,38 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function createTranslationFile(translationsByLanguage) {
|
|
6
6
|
function getByLanguage(language) {
|
|
7
7
|
const translationModule = translationsByLanguage[language];
|
|
8
|
-
|
|
9
8
|
if (!translationModule) {
|
|
10
9
|
throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return translationModule;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return {
|
|
17
14
|
getLoadedMessages(language, locale) {
|
|
18
15
|
const translationModule = getByLanguage(language);
|
|
19
16
|
return translationModule.getValue(locale || language) || null;
|
|
20
17
|
},
|
|
21
|
-
|
|
22
18
|
getMessages(language, locale) {
|
|
23
19
|
const translationModule = getByLanguage(language);
|
|
24
20
|
return translationModule.load().then(() => {
|
|
25
21
|
const result = translationModule.getValue(locale || language);
|
|
26
|
-
|
|
27
22
|
if (!result) {
|
|
28
23
|
throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return result;
|
|
32
26
|
});
|
|
33
27
|
},
|
|
34
|
-
|
|
35
28
|
load(language) {
|
|
36
29
|
const translationModule = getByLanguage(language);
|
|
37
30
|
return translationModule.load();
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
};
|
|
41
33
|
}
|
|
42
34
|
|
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
function createTranslationFile(translationsByLanguage) {
|
|
2
2
|
function getByLanguage(language) {
|
|
3
3
|
const translationModule = translationsByLanguage[language];
|
|
4
|
-
|
|
5
4
|
if (!translationModule) {
|
|
6
5
|
throw new Error(`Attempted to retrieve translations for unknown language "${language}"`);
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
return translationModule;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return {
|
|
13
10
|
getLoadedMessages(language, locale) {
|
|
14
11
|
const translationModule = getByLanguage(language);
|
|
15
12
|
return translationModule.getValue(locale || language) || null;
|
|
16
13
|
},
|
|
17
|
-
|
|
18
14
|
getMessages(language, locale) {
|
|
19
15
|
const translationModule = getByLanguage(language);
|
|
20
16
|
return translationModule.load().then(() => {
|
|
21
17
|
const result = translationModule.getValue(locale || language);
|
|
22
|
-
|
|
23
18
|
if (!result) {
|
|
24
19
|
throw new Error(`Unable to find translations for ${language} after attempting to load. Module may have failed to load or an internal error may have occurred.`);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
return result;
|
|
28
22
|
});
|
|
29
23
|
},
|
|
30
|
-
|
|
31
24
|
load(language) {
|
|
32
25
|
const translationModule = getByLanguage(language);
|
|
33
26
|
return translationModule.load();
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
30
|
|