@iobroker/adapter-react-v5 3.1.4 → 3.1.7
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/Components/JsonConfigComponent/ConfigFile.js +183 -0
- package/Components/JsonConfigComponent/ConfigFile.js.map +1 -0
- package/Components/JsonConfigComponent/ConfigFileSelector.js +747 -0
- package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -0
- package/Dialogs/SelectID.js +1 -1
- package/Dialogs/SelectID.js.map +1 -1
- package/GenericApp.js +1025 -0
- package/GenericApp.js.map +1 -0
- package/Prompt.js +21 -0
- package/Prompt.js.map +1 -0
- package/README.md +1 -1
- package/Theme.js +422 -0
- package/Theme.js.map +1 -0
- package/i18n.js +180 -0
- package/i18n.js.map +1 -0
- package/package.json +1 -1
package/i18n.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
/***
|
|
17
|
+
* Copyright 2018-2022 bluefox <dogafox@gmail.com>
|
|
18
|
+
*
|
|
19
|
+
* MIT License
|
|
20
|
+
*
|
|
21
|
+
***/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Translation string management.
|
|
25
|
+
*/
|
|
26
|
+
var I18n = /*#__PURE__*/function () {
|
|
27
|
+
function I18n() {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, I18n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(0, _createClass2["default"])(I18n, null, [{
|
|
32
|
+
key: "setLanguage",
|
|
33
|
+
value:
|
|
34
|
+
/**
|
|
35
|
+
* List of all languages with their translations.
|
|
36
|
+
* @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The currently displayed language.
|
|
41
|
+
* @type {ioBroker.Languages}
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Set the language to display.
|
|
46
|
+
* @param {ioBroker.Languages} lang
|
|
47
|
+
*/
|
|
48
|
+
function setLanguage(lang) {
|
|
49
|
+
if (lang) {
|
|
50
|
+
I18n.lang = lang;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Add translations
|
|
55
|
+
* User can provide two types of structures:
|
|
56
|
+
* - {"word1": "translated word1", "word2": "translated word2"}, but in this case the lang must be provided
|
|
57
|
+
* - {"word1": {"en": "translated en word1", "de": "translated de word1"}, "word2": {"en": "translated en word2", "de": "translated de word2"}}, but no lang must be provided
|
|
58
|
+
* @param {object} words additional words for specific language
|
|
59
|
+
* @param {ioBroker.Languages} lang
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
}, {
|
|
63
|
+
key: "extendTranslations",
|
|
64
|
+
value: function extendTranslations(words, lang) {
|
|
65
|
+
try {
|
|
66
|
+
if (!lang) {
|
|
67
|
+
Object.keys(words).forEach(function (word) {
|
|
68
|
+
Object.keys(words[word]).forEach(function (lang) {
|
|
69
|
+
if (!I18n.translations[lang]) {
|
|
70
|
+
console.warn("Used unknown language: ".concat(lang));
|
|
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
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
if (!I18n.translations[lang]) {
|
|
82
|
+
console.warn("Used unknown language: ".concat(lang));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
I18n.translations[lang] = I18n.translations[lang] || {};
|
|
86
|
+
Object.keys(words).forEach(function (word) {
|
|
87
|
+
if (!I18n.translations[lang][word]) {
|
|
88
|
+
I18n.translations[lang][word] = words[word];
|
|
89
|
+
} else if (I18n.translations[lang][word] !== words[word]) {
|
|
90
|
+
console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word]));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error("Cannot apply translations: ".concat(e));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sets all translations (in all languages).
|
|
100
|
+
* @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
}, {
|
|
104
|
+
key: "setTranslations",
|
|
105
|
+
value: function setTranslations(translations) {
|
|
106
|
+
if (translations) {
|
|
107
|
+
I18n.translations = translations;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the currently chosen language.
|
|
112
|
+
* @returns {ioBroker.Languages} The current language.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
}, {
|
|
116
|
+
key: "getLanguage",
|
|
117
|
+
value: function getLanguage() {
|
|
118
|
+
return I18n.lang;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Translate the given string to the selected language.
|
|
122
|
+
* @param {string} word The (key) word to look up the string.
|
|
123
|
+
* @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurrences of %s
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
}, {
|
|
127
|
+
key: "t",
|
|
128
|
+
value: function t(word) {
|
|
129
|
+
var translation = I18n.translations[I18n.lang];
|
|
130
|
+
|
|
131
|
+
if (translation) {
|
|
132
|
+
var w = translation[word];
|
|
133
|
+
|
|
134
|
+
if (w) {
|
|
135
|
+
word = w;
|
|
136
|
+
} else {
|
|
137
|
+
I18n._disableWarning && console.log("Translate: ".concat(word));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
142
|
+
args[_key - 1] = arguments[_key];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
for (var _i = 0, _args = args; _i < _args.length; _i++) {
|
|
146
|
+
var arg = _args[_i];
|
|
147
|
+
word = word.replace('%s', arg);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return word;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Disable warning about non-translated words
|
|
154
|
+
* Required during development
|
|
155
|
+
* @param {boolean} disable Do the warning should be disabled
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
}, {
|
|
159
|
+
key: "disableWarning",
|
|
160
|
+
value: function disableWarning(disable) {
|
|
161
|
+
I18n._disableWarning = !!disable;
|
|
162
|
+
}
|
|
163
|
+
}]);
|
|
164
|
+
return I18n;
|
|
165
|
+
}();
|
|
166
|
+
/*I18n.translations = {
|
|
167
|
+
'en': require('./i18n/en'),
|
|
168
|
+
'ru': require('./i18n/ru'),
|
|
169
|
+
'de': require('./i18n/de'),
|
|
170
|
+
};
|
|
171
|
+
I18n.fallbacks = true;
|
|
172
|
+
I18n.t = function () {};*/
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
(0, _defineProperty2["default"])(I18n, "translations", {});
|
|
176
|
+
(0, _defineProperty2["default"])(I18n, "lang", window.sysLang || 'en');
|
|
177
|
+
(0, _defineProperty2["default"])(I18n, "_disableWarning", false);
|
|
178
|
+
var _default = I18n;
|
|
179
|
+
exports["default"] = _default;
|
|
180
|
+
//# sourceMappingURL=i18n.js.map
|
package/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["I18n","lang","words","Object","keys","forEach","word","translations","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 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 } 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;MAC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