iobroker.ebus 3.6.2 → 3.6.6
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 +12 -0
- package/admin/i18n/de/translations.json +1 -1
- package/admin/i18n/en/translations.json +51 -51
- package/admin/i18n/es/translations.json +2 -2
- package/admin/jsonConfig.json5 +2 -2
- package/admin/words.js +2 -2
- package/io-package.json +94 -53
- package/lib/support_tools.js +26 -44
- package/lib/tools.js +8 -6
- package/main.js +515 -347
- package/package.json +9 -9
package/lib/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const axios = require('axios').default;
|
|
2
2
|
|
|
3
|
+
//Tests whether the given variable is a real object and not an Array
|
|
3
4
|
/**
|
|
4
|
-
* Tests whether the given variable is a real object and not an Array
|
|
5
5
|
* @param {any} it The variable to test
|
|
6
6
|
* @returns {it is Record<string, any>}
|
|
7
7
|
*/
|
|
@@ -13,18 +13,20 @@ function isObject(it) {
|
|
|
13
13
|
return Object.prototype.toString.call(it) === '[object Object]';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
//Tests whether the given variable is really an Array
|
|
16
17
|
/**
|
|
17
|
-
* Tests whether the given variable is really an Array
|
|
18
18
|
* @param {any} it The variable to test
|
|
19
19
|
* @returns {it is any[]}
|
|
20
20
|
*/
|
|
21
21
|
function isArray(it) {
|
|
22
|
-
if (typeof Array.isArray === 'function')
|
|
22
|
+
if (typeof Array.isArray === 'function') {
|
|
23
|
+
return Array.isArray(it);
|
|
24
|
+
}
|
|
23
25
|
return Object.prototype.toString.call(it) === '[object Array]';
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
//Translates text to the target language.Automatically chooses the right translation API.
|
|
26
29
|
/**
|
|
27
|
-
* Translates text to the target language. Automatically chooses the right translation API.
|
|
28
30
|
* @param {string} text The text to translate
|
|
29
31
|
* @param {string} targetLang The target languate
|
|
30
32
|
* @param {string} [yandexApiKey] The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
@@ -43,8 +45,8 @@ async function translateText(text, targetLang, yandexApiKey) {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
//Translates text with Yandex API
|
|
46
49
|
/**
|
|
47
|
-
* Translates text with Yandex API
|
|
48
50
|
* @param {string} text The text to translate
|
|
49
51
|
* @param {string} targetLang The target languate
|
|
50
52
|
* @param {string} apiKey The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
@@ -66,8 +68,8 @@ async function translateYandex(text, targetLang, apiKey) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
//Translates text with Google API
|
|
69
72
|
/**
|
|
70
|
-
* Translates text with Google API
|
|
71
73
|
* @param {string} text The text to translate
|
|
72
74
|
* @param {string} targetLang The target languate
|
|
73
75
|
* @returns {Promise<string>}
|