@iobroker/adapter-react-v5 8.1.3 → 8.1.4
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/build/Components/DeviceType/i18n/de.json +1 -0
- package/build/Components/DeviceType/i18n/en.json +1 -0
- package/build/Components/DeviceType/i18n/fr.json +1 -0
- package/build/Components/DeviceType/i18n/it.json +1 -0
- package/build/Components/DeviceType/i18n/nl.json +1 -0
- package/build/Components/DeviceType/i18n/pl.json +1 -0
- package/build/Components/DeviceType/i18n/pt.json +1 -0
- package/build/Components/DeviceType/i18n/ru.json +1 -0
- package/build/Components/DeviceType/i18n/uk.json +1 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +1 -0
- package/build/i18n.js +12 -15
- package/build/i18n.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"type-lock": "Lock",
|
|
27
27
|
"type-media": "Media-player",
|
|
28
28
|
"type-motion": "Motion sensor",
|
|
29
|
+
"type-percentage": "Percentage",
|
|
29
30
|
"type-rgb": "RGB light",
|
|
30
31
|
"type-rgbSingle": "R,G,B light - single states",
|
|
31
32
|
"type-rgbwSingle": "R,G,B,W light - single states",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"type-lock": "Замок",
|
|
27
27
|
"type-media": "Медиа-плейер",
|
|
28
28
|
"type-motion": "Датчик движения",
|
|
29
|
+
"type-percentage": "Проценты",
|
|
29
30
|
"type-rgb": "RGB свет",
|
|
30
31
|
"type-rgbSingle": "R,G,B как отдельные значение",
|
|
31
32
|
"type-rgbwSingle": "R,G,B,W как отдельные значение",
|
package/build/i18n.js
CHANGED
|
@@ -71,9 +71,8 @@ export class I18n {
|
|
|
71
71
|
if (words.en && words.de && words.ru) {
|
|
72
72
|
Object.keys(words).forEach(key => {
|
|
73
73
|
const _lang = key;
|
|
74
|
-
I18n.translations[_lang]
|
|
75
|
-
|
|
76
|
-
Object.assign(wordsOfOneLang, words[_lang]);
|
|
74
|
+
I18n.translations[_lang] ||= {};
|
|
75
|
+
Object.assign(I18n.translations[_lang], words[_lang]);
|
|
77
76
|
});
|
|
78
77
|
}
|
|
79
78
|
else {
|
|
@@ -101,18 +100,16 @@ export class I18n {
|
|
|
101
100
|
if (!I18n.translations[lang]) {
|
|
102
101
|
console.warn(`Used unknown language: ${lang}`);
|
|
103
102
|
}
|
|
104
|
-
I18n.translations[lang]
|
|
103
|
+
I18n.translations[lang] ||= {};
|
|
105
104
|
const languageDictionary = I18n.translations[lang];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
}
|
|
105
|
+
Object.keys(words).forEach(word => {
|
|
106
|
+
if (!languageDictionary[word]) {
|
|
107
|
+
languageDictionary[word] = words[word];
|
|
108
|
+
}
|
|
109
|
+
else if (languageDictionary[word] !== words[word]) {
|
|
110
|
+
console.warn(`Translation for word "${word}" in "${lang}" was ignored: existing = "${languageDictionary[word]}", new = ${words[word]}`);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
catch (e) {
|
|
@@ -190,7 +187,7 @@ export class I18n {
|
|
|
190
187
|
});
|
|
191
188
|
console.log(JSON.stringify(result, null, 2));
|
|
192
189
|
}
|
|
193
|
-
else if (typeof filter === 'object') {
|
|
190
|
+
else if (filter && typeof filter === 'object') {
|
|
194
191
|
I18n.unknownTranslations.forEach(word => {
|
|
195
192
|
if (filter.test(word)) {
|
|
196
193
|
result[word] = word;
|
package/build/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"./src/","sources":["i18n.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH;;GAEG;AACH,MAAM,OAAO,IAAI;IACb,qDAAqD;IACrD,MAAM,C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AAQ,EAAE,CAAC;YACpC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACpC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;gBACxB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAgB;QAClC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;;AAGL,0BAA0B;AAC1B,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AAChC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC;AAEhD;;;;;;;;EAQE","sourcesContent":["/**\n * Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com>\n *\n * MIT License\n *\n */\n\ndeclare global {\n interface Window {\n sysLang: ioBroker.Languages;\n i18nShow: (filter: string | RegExp) => void;\n i18nDisableWarning: (disable: boolean) => void;\n }\n}\n\ntype I18nWordDictionary = Record<ioBroker.Languages, string>;\n\ntype I18nWordsDictionary = Record<string, I18nWordDictionary>;\n\ntype I18nOneLanguageDictionary = Record<string, string>;\n\ntype I18nDictionary = {\n [lang in ioBroker.Languages]?: I18nOneLanguageDictionary;\n};\n\ntype I18nWordsWithPrefix = I18nDictionary & { prefix?: string };\n\n/**\n * Translation string management.\n */\nexport class I18n {\n /** List of all languages with their translations. */\n static translations: I18nDictionary = {};\n\n /** List of unknown translations during development. */\n static unknownTranslations: string[] = [];\n\n /** The currently displayed language. */\n static lang: ioBroker.Languages = window.sysLang || 'en';\n\n static _disableWarning: boolean = false;\n\n /**\n * Set the language to display\n *\n * @param lang The default language for translations.\n */\n static setLanguage(lang: ioBroker.Languages): void {\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 *\n * @param words additional words for specific language\n * @param lang language for the words\n */\n static extendTranslations(\n words: I18nWordsWithPrefix | I18nOneLanguageDictionary | I18nWordsDictionary,\n lang?: ioBroker.Languages,\n ): void {\n // automatically extend all languages with prefix\n if ((words as I18nWordsWithPrefix).prefix) {\n const wordsWithPrefix = words as I18nWordsWithPrefix;\n if (typeof wordsWithPrefix.prefix === 'string') {\n const prefix = wordsWithPrefix.prefix;\n delete wordsWithPrefix.prefix;\n Object.keys(wordsWithPrefix).forEach(key => {\n const _lang = key as ioBroker.Languages;\n const _words: I18nOneLanguageDictionary = {};\n const wordsOfOneLanguage = wordsWithPrefix[_lang];\n Object.keys(wordsOfOneLanguage as Record<string, string>).forEach(word => {\n if (!word) {\n return;\n }\n if (wordsOfOneLanguage) {\n if (!word.startsWith(prefix)) {\n _words[`${prefix}${word}`] = wordsOfOneLanguage[word];\n } else {\n _words[word] = wordsOfOneLanguage[word];\n }\n }\n });\n words[_lang] = _words;\n });\n } else {\n console.warn('Found prefix in translations, but it is not a string');\n }\n }\n\n try {\n if (!lang) {\n // if it is a dictionary with all/many languages\n if (words.en && words.de && words.ru) {\n Object.keys(words).forEach(key => {\n const _lang = key as ioBroker.Languages;\n I18n.translations[_lang] = I18n.translations[_lang] || {};\n const wordsOfOneLang: I18nOneLanguageDictionary | undefined = I18n.translations[_lang];\n Object.assign(wordsOfOneLang as Record<string, string>, words[_lang]);\n });\n } else {\n // It could be vice versa: words.word1 = {en: 'translated word1', de: 'übersetztes Wort2'}\n Object.keys(words).forEach(word => {\n const _word: I18nWordDictionary = (words as I18nWordsDictionary)[word];\n Object.keys(_word).forEach(key => {\n const _lang = key as ioBroker.Languages;\n const languageDictionary: I18nOneLanguageDictionary | undefined = I18n.translations[_lang];\n if (!languageDictionary) {\n console.warn(`Used unknown language: ${_lang}`);\n } else if (!languageDictionary[word]) {\n languageDictionary[word] = _word[_lang];\n } else if (languageDictionary[word] !== _word[_lang]) {\n console.warn(\n `Translation for word \"${word}\" in \"${_lang}\" was ignored: existing = \"${languageDictionary[word]}\", new = ${_word[_lang]}`,\n );\n }\n });\n });\n }\n } else {\n // translations for one language\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] = I18n.translations[lang] || {};\n const languageDictionary: I18nOneLanguageDictionary | undefined = I18n.translations[lang];\n if (languageDictionary) {\n Object.keys(words).forEach(word => {\n if (!languageDictionary[word]) {\n languageDictionary[word] = (words as I18nOneLanguageDictionary)[word];\n } else if (languageDictionary[word] !== (words as I18nOneLanguageDictionary)[word]) {\n console.warn(\n `Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${languageDictionary[word]}\", new = ${(words as I18nOneLanguageDictionary)[word]}`,\n );\n }\n });\n }\n }\n } catch (e: any) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n *\n * @param translations The translations to add.\n */\n static setTranslations(translations: I18nDictionary): void {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n *\n * @returns The current language.\n */\n static getLanguage(): ioBroker.Languages {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language\n *\n * @param word The (key) word to look up the string.\n * @param args Optional arguments which will replace the first (second, third, ...) occurrences of %s\n */\n static t(word: string, ...args: any[]): string {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n if (!I18n.unknownTranslations.includes(word)) {\n I18n.unknownTranslations.push(word);\n !I18n._disableWarning && console.log(`Translate: ${word}`);\n }\n // fallback to english\n if (I18n.lang !== 'en' && I18n.translations.en) {\n const wordEn = I18n.translations.en[word];\n if (wordEn) {\n word = wordEn;\n }\n }\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n\n /**\n * Show non-translated words\n * Required during development\n *\n * @param filter The filter to apply to the list of non-translated words.\n */\n static i18nShow(filter?: string | RegExp): void {\n /** List words with their translations. */\n const result: Record<string, string> = {};\n if (!filter) {\n I18n.unknownTranslations.forEach(word => (result[word] = word));\n console.log(JSON.stringify(result, null, 2));\n } else if (typeof filter === 'string') {\n I18n.unknownTranslations.forEach(word => {\n if (word.startsWith(filter)) {\n result[word] = word.replace(filter, '');\n }\n });\n console.log(JSON.stringify(result, null, 2));\n } else if (typeof filter === 'object') {\n I18n.unknownTranslations.forEach(word => {\n if (filter.test(word)) {\n result[word] = word;\n }\n });\n console.log(JSON.stringify(result, null, 2));\n }\n }\n\n /**\n * Disable warning about non-translated words\n * Required during development\n *\n * @param disable Whether to disable the warning\n */\n static disableWarning(disable: boolean): void {\n I18n._disableWarning = !!disable;\n }\n}\n\n// install global handlers\nwindow.i18nShow = I18n.i18nShow;\nwindow.i18nDisableWarning = I18n.disableWarning;\n\n/*\nI18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};\n*/\n"]}
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"./src/","sources":["i18n.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH;;GAEG;AACH,MAAM,OAAO,IAAI;IACb,qDAAqD;IACrD,MAAM,CAAC,YAAY,GAAmB,EAAE,CAAC;IAEzC,uDAAuD;IACvD,MAAM,CAAC,mBAAmB,GAAa,EAAE,CAAC;IAE1C,wCAAwC;IACxC,MAAM,CAAC,IAAI,GAAuB,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;IAEzD,MAAM,CAAC,eAAe,GAAY,KA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;IACH,MAAM,CAAC,cAAc,CAAC,OAAgB;QAClC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;;AAGL,0BAA0B;AAC1B,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AAChC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC;AAEhD;;;;;;;;EAQE","sourcesContent":["/**\n * Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com>\n *\n * MIT License\n *\n */\n\ndeclare global {\n interface Window {\n sysLang: ioBroker.Languages;\n i18nShow: (filter: string | RegExp) => void;\n i18nDisableWarning: (disable: boolean) => void;\n }\n}\n\ntype I18nWordDictionary = Record<ioBroker.Languages, string>;\n\ntype I18nWordsDictionary = Record<string, I18nWordDictionary>;\n\ntype I18nOneLanguageDictionary = Record<string, string>;\n\ntype I18nDictionary = {\n [lang in ioBroker.Languages]?: I18nOneLanguageDictionary;\n};\n\ntype I18nWordsWithPrefix = I18nDictionary & { prefix?: string };\n\n/**\n * Translation string management.\n */\nexport class I18n {\n /** List of all languages with their translations. */\n static translations: I18nDictionary = {};\n\n /** List of unknown translations during development. */\n static unknownTranslations: string[] = [];\n\n /** The currently displayed language. */\n static lang: ioBroker.Languages = window.sysLang || 'en';\n\n static _disableWarning: boolean = false;\n\n /**\n * Set the language to display\n *\n * @param lang The default language for translations.\n */\n static setLanguage(lang: ioBroker.Languages): void {\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 *\n * @param words additional words for specific language\n * @param lang language for the words\n */\n static extendTranslations(\n words: I18nWordsWithPrefix | I18nOneLanguageDictionary | I18nWordsDictionary,\n lang?: ioBroker.Languages,\n ): void {\n // automatically extend all languages with prefix\n if ((words as I18nWordsWithPrefix).prefix) {\n const wordsWithPrefix = words as I18nWordsWithPrefix;\n if (typeof wordsWithPrefix.prefix === 'string') {\n const prefix = wordsWithPrefix.prefix;\n delete wordsWithPrefix.prefix;\n Object.keys(wordsWithPrefix).forEach(key => {\n const _lang = key as ioBroker.Languages;\n const _words: I18nOneLanguageDictionary = {};\n const wordsOfOneLanguage = wordsWithPrefix[_lang];\n Object.keys(wordsOfOneLanguage as Record<string, string>).forEach(word => {\n if (!word) {\n return;\n }\n if (wordsOfOneLanguage) {\n if (!word.startsWith(prefix)) {\n _words[`${prefix}${word}`] = wordsOfOneLanguage[word];\n } else {\n _words[word] = wordsOfOneLanguage[word];\n }\n }\n });\n words[_lang] = _words;\n });\n } else {\n console.warn('Found prefix in translations, but it is not a string');\n }\n }\n\n try {\n if (!lang) {\n // if it is a dictionary with all/many languages\n if (words.en && words.de && words.ru) {\n Object.keys(words).forEach(key => {\n const _lang = key as ioBroker.Languages;\n I18n.translations[_lang] ||= {};\n Object.assign(I18n.translations[_lang], words[_lang]);\n });\n } else {\n // It could be vice versa: words.word1 = {en: 'translated word1', de: 'übersetztes Wort2'}\n Object.keys(words).forEach(word => {\n const _word: I18nWordDictionary = (words as I18nWordsDictionary)[word];\n Object.keys(_word).forEach(key => {\n const _lang = key as ioBroker.Languages;\n const languageDictionary: I18nOneLanguageDictionary | undefined = I18n.translations[_lang];\n if (!languageDictionary) {\n console.warn(`Used unknown language: ${_lang}`);\n } else if (!languageDictionary[word]) {\n languageDictionary[word] = _word[_lang];\n } else if (languageDictionary[word] !== _word[_lang]) {\n console.warn(\n `Translation for word \"${word}\" in \"${_lang}\" was ignored: existing = \"${languageDictionary[word]}\", new = ${_word[_lang]}`,\n );\n }\n });\n });\n }\n } else {\n // translations for one language\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] ||= {};\n const languageDictionary = I18n.translations[lang];\n Object.keys(words).forEach(word => {\n if (!languageDictionary[word]) {\n languageDictionary[word] = (words as I18nOneLanguageDictionary)[word];\n } else if (languageDictionary[word] !== (words as I18nOneLanguageDictionary)[word]) {\n console.warn(\n `Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${languageDictionary[word]}\", new = ${(words as I18nOneLanguageDictionary)[word]}`,\n );\n }\n });\n }\n } catch (e: any) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n *\n * @param translations The translations to add.\n */\n static setTranslations(translations: I18nDictionary): void {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n *\n * @returns The current language.\n */\n static getLanguage(): ioBroker.Languages {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language\n *\n * @param word The (key) word to look up the string.\n * @param args Optional arguments which will replace the first (second, third, ...) occurrences of %s\n */\n static t(word: string, ...args: any[]): string {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n if (!I18n.unknownTranslations.includes(word)) {\n I18n.unknownTranslations.push(word);\n !I18n._disableWarning && console.log(`Translate: ${word}`);\n }\n // fallback to english\n if (I18n.lang !== 'en' && I18n.translations.en) {\n const wordEn = I18n.translations.en[word];\n if (wordEn) {\n word = wordEn;\n }\n }\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n\n /**\n * Show non-translated words\n * Required during development\n *\n * @param filter The filter to apply to the list of non-translated words.\n */\n static i18nShow(filter?: string | RegExp): void {\n /** List words with their translations. */\n const result: Record<string, string> = {};\n if (!filter) {\n I18n.unknownTranslations.forEach(word => (result[word] = word));\n console.log(JSON.stringify(result, null, 2));\n } else if (typeof filter === 'string') {\n I18n.unknownTranslations.forEach(word => {\n if (word.startsWith(filter)) {\n result[word] = word.replace(filter, '');\n }\n });\n console.log(JSON.stringify(result, null, 2));\n } else if (filter && typeof filter === 'object') {\n I18n.unknownTranslations.forEach(word => {\n if (filter.test(word)) {\n result[word] = word;\n }\n });\n console.log(JSON.stringify(result, null, 2));\n }\n }\n\n /**\n * Disable warning about non-translated words\n * Required during development\n *\n * @param disable Whether to disable the warning\n */\n static disableWarning(disable: boolean): void {\n I18n._disableWarning = !!disable;\n }\n}\n\n// install global handlers\nwindow.i18nShow = I18n.i18nShow;\nwindow.i18nDisableWarning = I18n.disableWarning;\n\n/*\nI18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};\n*/\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/adapter-react-v5",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.4",
|
|
4
4
|
"description": "React components to develop ioBroker interfaces with react.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@alcalzone/release-script-plugin-license": "^5.1.1",
|
|
81
81
|
"@iobroker/build-tools": "^3.0.1",
|
|
82
82
|
"@iobroker/eslint-config": "^2.2.0",
|
|
83
|
-
"@types/node": "^25.
|
|
83
|
+
"@types/node": "^25.5.0",
|
|
84
84
|
"@types/react": "^18.3.28",
|
|
85
85
|
"@types/react-color": "^3.0.13",
|
|
86
86
|
"ajv": "^8.18.0",
|