Create loadLanguages.js
Browse files- js/rus/loadLanguages.js +22 -0
js/rus/loadLanguages.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
async function loadLanguageFiles(callback) {
|
2 |
+
const langUrls = {
|
3 |
+
'ru-RU': 'https://your-server.com/path-to-your-file/ru-RU.lang',
|
4 |
+
// Добавьте другие языковые файлы по аналогии
|
5 |
+
};
|
6 |
+
|
7 |
+
const langFiles = {};
|
8 |
+
|
9 |
+
for (const [langCode, url] of Object.entries(langUrls)) {
|
10 |
+
try {
|
11 |
+
const response = await fetch(url);
|
12 |
+
const data = await response.json();
|
13 |
+
langFiles[langCode] = data;
|
14 |
+
} catch (e) {
|
15 |
+
console.error(`Ошибка загрузки языкового файла ${url}:`, e);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
callback(null, langFiles);
|
20 |
+
}
|
21 |
+
|
22 |
+
module.exports = loadLanguageFiles;
|