You've already forked Tricky-Addon-Update-Target-List
mirror of
https://github.com/KOWX712/Tricky-Addon-Update-Target-List.git
synced 2025-09-06 06:37:09 +00:00
fix: get language function
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Translation Guide
|
# Translation Guide
|
||||||
## Fix Bad Translation
|
## Fix Bad Translation
|
||||||
1. Fork this repository.
|
1. Fork this repository.
|
||||||
2. Find your language string file in `/module/webroot/locales/`.
|
2. Find your language string file in `/module/webui/locales/`.
|
||||||
3. Edit the string value with translated incorrectly.
|
3. Edit the string value with translated incorrectly.
|
||||||
4. Create a Pull Request.
|
4. Create a Pull Request.
|
||||||
|
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
### Advanced
|
### Advanced
|
||||||
1. Fork this repository.
|
1. Fork this repository.
|
||||||
2. Make a copy of `/module/webroot/locales/A-template.json`
|
2. Make a copy of `/module/webui/locales/A-template.json`
|
||||||
3. Rename it to `language_code-COUNTRY_CODE.json`, e.g., `en-US.json`.
|
3. Rename it to `language_code-COUNTRY_CODE.json`, e.g., `en-US.json`.
|
||||||
4. Translate the string value inside.
|
4. Translate the string value inside.
|
||||||
|
5. Add the language code to `/module/webui/locales/available-lang.json`.
|
||||||
6. Create a Pull Request.
|
6. Create a Pull Request.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"languages": [
|
||||||
|
"en-US",
|
||||||
|
"es-ES",
|
||||||
|
"ja-JP",
|
||||||
|
"pl-PL",
|
||||||
|
"ru-RU",
|
||||||
|
"tl-PH",
|
||||||
|
"tr-TR",
|
||||||
|
"zh-CN",
|
||||||
|
"zh-TW"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -12,15 +12,9 @@ let availableLanguages = ['en-US'];
|
|||||||
// Function to check for available language
|
// Function to check for available language
|
||||||
export async function initializeAvailableLanguages() {
|
export async function initializeAvailableLanguages() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('locales/');
|
const response = await fetch('locales/available-lang.json');
|
||||||
const text = await response.text();
|
const config = await response.json();
|
||||||
const parser = new DOMParser();
|
availableLanguages = config.languages;
|
||||||
const html = parser.parseFromString(text, 'text/html');
|
|
||||||
const files = Array.from(html.querySelectorAll('a'))
|
|
||||||
.map(a => a.href.split('/').pop())
|
|
||||||
.filter(file => file.endsWith('.json') && file !== 'A-template.json')
|
|
||||||
.map(file => file.replace('.json', ''));
|
|
||||||
availableLanguages = files;
|
|
||||||
generateLanguageMenu();
|
generateLanguageMenu();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch available languages:', error);
|
console.error('Failed to fetch available languages:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user