@iobroker/adapter-react-v5 3.1.18 → 3.1.19
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 -0
- package/i18n.js +19 -12
- package/i18n.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -642,6 +642,9 @@ If you still have questions, try to find an answer [here](https://mui.com/guides
|
|
|
642
642
|
-->
|
|
643
643
|
|
|
644
644
|
## Changelog
|
|
645
|
+
### 3.1.19 (2022-07-08)
|
|
646
|
+
* (bluefox) Allowed to extend translations for all languages together
|
|
647
|
+
|
|
645
648
|
### 3.1.18 (2022-07-06)
|
|
646
649
|
* (bluefox) Added translation
|
|
647
650
|
|
package/i18n.js
CHANGED
|
@@ -64,19 +64,26 @@ var I18n = /*#__PURE__*/function () {
|
|
|
64
64
|
value: function extendTranslations(words, lang) {
|
|
65
65
|
try {
|
|
66
66
|
if (!lang) {
|
|
67
|
-
|
|
68
|
-
Object.keys(words
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!I18n.translations[lang][word]) {
|
|
74
|
-
I18n.translations[lang][word] = words[word][lang];
|
|
75
|
-
} else if (I18n.translations[lang][word] !== words[word][lang]) {
|
|
76
|
-
console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word][lang]));
|
|
77
|
-
}
|
|
67
|
+
if (words.en && words.de && words.ru) {
|
|
68
|
+
Object.keys(words).forEach(function (lang) {
|
|
69
|
+
I18n.translations[lang] = I18n.translations[lang] || {};
|
|
70
|
+
Object.assign(I18n.translations[lang], words[lang]);
|
|
78
71
|
});
|
|
79
|
-
}
|
|
72
|
+
} else {
|
|
73
|
+
Object.keys(words).forEach(function (word) {
|
|
74
|
+
Object.keys(words[word]).forEach(function (lang) {
|
|
75
|
+
if (!I18n.translations[lang]) {
|
|
76
|
+
console.warn("Used unknown language: ".concat(lang));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!I18n.translations[lang][word]) {
|
|
80
|
+
I18n.translations[lang][word] = words[word][lang];
|
|
81
|
+
} else if (I18n.translations[lang][word] !== words[word][lang]) {
|
|
82
|
+
console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word][lang]));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
80
87
|
} else {
|
|
81
88
|
if (!I18n.translations[lang]) {
|
|
82
89
|
console.warn("Used unknown language: ".concat(lang));
|
package/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":["I18n","lang","words","Object","keys","forEach","
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["I18n","lang","words","en","de","ru","Object","keys","forEach","translations","assign","word","console","warn","e","error","translation","w","_disableWarning","log","args","arg","replace","disable","window","sysLang"],"sources":["i18n.js"],"sourcesContent":["/***\n * Copyright 2018-2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n ***/\n\n /**\n * Translation string management.\n */\nclass I18n {\n /**\n * List of all languages with their translations.\n * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}\n */\n static translations = {};\n\n /**\n * The currently displayed language.\n * @type {ioBroker.Languages}\n */\n static lang = window.sysLang || 'en';\n\n static _disableWarning = false;\n\n /**\n * Set the language to display.\n * @param {ioBroker.Languages} lang\n */\n static setLanguage(lang) {\n if (lang) {\n I18n.lang = lang;\n }\n }\n\n /**\n * Add translations\n * User can provide two types of structures:\n * - {\"word1\": \"translated word1\", \"word2\": \"translated word2\"}, but in this case the lang must be provided\n * - {\"word1\": {\"en\": \"translated en word1\", \"de\": \"translated de word1\"}, \"word2\": {\"en\": \"translated en word2\", \"de\": \"translated de word2\"}}, but no lang must be provided\n * @param {object} words additional words for specific language\n * @param {ioBroker.Languages} lang\n */\n static extendTranslations(words, lang) {\n try {\n if (!lang) {\n if (words.en && words.de && words.ru) {\n Object.keys(words).forEach(lang => {\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.assign(I18n.translations[lang], words[lang]);\n });\n } else {\n Object.keys(words).forEach(word => {\n Object.keys(words[word]).forEach(lang => {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word][lang];\n } else if (I18n.translations[lang][word] !== words[word][lang]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word][lang]}`);\n }\n });\n });\n }\n } else {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.keys(words)\n .forEach(word => {\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word];\n } else if (I18n.translations[lang][word] !== words[word]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word]}`);\n }\n });\n }\n } catch (e) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations\n */\n static setTranslations(translations) {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n * @returns {ioBroker.Languages} The current language.\n */\n static getLanguage() {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language.\n * @param {string} word The (key) word to look up the string.\n * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurrences of %s\n */\n static t(word, ...args) {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n I18n._disableWarning && console.log(`Translate: ${word}`);\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n\n /**\n * Disable warning about non-translated words\n * Required during development\n * @param {boolean} disable Do the warning should be disabled\n */\n static disableWarning(disable) {\n I18n._disableWarning = !!disable;\n }\n}\n\n/*I18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};*/\n\nexport default I18n;"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;IACMA,I;;;;;;;;IACF;AACJ;AACA;AACA;;IAGI;AACJ;AACA;AACA;;IAKI;AACJ;AACA;AACA;IACI,qBAAmBC,IAAnB,EAAyB;MACrB,IAAIA,IAAJ,EAAU;QACND,IAAI,CAACC,IAAL,GAAYA,IAAZ;MACH;IACJ;IAEA;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;;WACK,4BAA0BC,KAA1B,EAAiCD,IAAjC,EAAuC;MACnC,IAAI;QACA,IAAI,CAACA,IAAL,EAAW;UACP,IAAIC,KAAK,CAACC,EAAN,IAAYD,KAAK,CAACE,EAAlB,IAAwBF,KAAK,CAACG,EAAlC,EAAsC;YAClCC,MAAM,CAACC,IAAP,CAAYL,KAAZ,EAAmBM,OAAnB,CAA2B,UAAAP,IAAI,EAAI;cAC/BD,IAAI,CAACS,YAAL,CAAkBR,IAAlB,IAA0BD,IAAI,CAACS,YAAL,CAAkBR,IAAlB,KAA2B,EAArD;cACAK,MAAM,CAACI,MAAP,CAAcV,IAAI,CAACS,YAAL,CAAkBR,IAAlB,CAAd,EAAuCC,KAAK,CAACD,IAAD,CAA5C;YACH,CAHD;UAIH,CALD,MAKO;YACHK,MAAM,CAACC,IAAP,CAAYL,KAAZ,EAAmBM,OAAnB,CAA2B,UAAAG,IAAI,EAAI;cAC/BL,MAAM,CAACC,IAAP,CAAYL,KAAK,CAACS,IAAD,CAAjB,EAAyBH,OAAzB,CAAiC,UAAAP,IAAI,EAAI;gBACrC,IAAI,CAACD,IAAI,CAACS,YAAL,CAA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