diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03650de --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +translations.generated.json \ No newline at end of file diff --git a/README.md b/README.md index 9babc4c..c281b04 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ ### Merged i18n - # Centralized Translation Repository -This repository manages all multilingual translations for the project in a single JSON file: `languages.json`. The centralized structure ensures consistency and simplifies updates by consolidating all languages in one place. - +This repository manages all multilingual translations for the project in a single JSON file: `translations.generated.json`. The centralized structure ensures consistency and simplifies updates by consolidating all languages in one place. ### **Translation Format** -The `languages.json` file organizes translations in a nested structure: -- **Keys** represent the unique identifiers for each translatable string. +The `translations.generated.json` file organizes translations in a nested structure: +- **Keys** represent the unique identifiers for each translatable string, generated automatically from the file structure. - **Sub-keys** represent the supported language codes (e.g., `en`, `de`, `fr`). - **Values** are the localized translations for each language. @@ -29,8 +27,18 @@ The `languages.json` file organizes translations in a nested structure: } ``` +### **Using the Project** -All languages are accepted. +#### Prerequisites +- Ensure you have [Node.js](https://nodejs.org) installed. + +#### Generating the Translations Index +1. **Add or modify translation files**: Place JSON translation files in the appropriate directory structure under the `merged` folder. +2. **Run the generator**: + ```bash + node generator.js + ``` + This will produce the `translations.generated.json` file in the root directory, containing all the translations consolidated into a single JSON object. ### **Contributing** @@ -38,19 +46,11 @@ We welcome contributions to improve or expand translations. Please follow these 1. **Fork the repository.** 2. **Create a new branch** for your changes. -3. **Update the `languages.json` file**: - - Add new keys or languages where applicable. - - Ensure consistency in the JSON structure. +3. **Update or add translation files**: + - Place your JSON files in the appropriate folder structure under `merged`. + - Run the `generator.js` script to regenerate the `translations.generated.json` file. 4. **Submit a pull request** with a clear description of your changes. - -### **Advantages of a Centralized File** - -- **Simplicity**: All translations are stored in one place, making it easy to access and update. -- **Consistency**: Reduces duplication and ensures all keys are synchronized across languages. -- **Scalability**: Adding new keys or languages requires minimal effort. - - ### **Contact** If you have questions or suggestions, feel free to open an issue in the repository. diff --git a/generator.js b/generator.js new file mode 100644 index 0000000..40c0b68 --- /dev/null +++ b/generator.js @@ -0,0 +1,41 @@ +const fs = require('fs'); +const path = require('path'); + +const translationsDir = './merged'; + +const outputFile = 'translations.generated.json'; + +function listJsonFiles(dir, prefix = '') { + let files = fs.readdirSync(dir); + let result = {}; + + files.forEach(file => { + let fullPath = path.join(dir, file); + let stat = fs.statSync(fullPath); + + if (stat.isDirectory()) { + let subPrefix = prefix ? `${prefix}.${file}` : file; + Object.assign(result, listJsonFiles(fullPath, subPrefix)); + } else if (file.endsWith('.json')) { + let key = `${prefix}.${path.basename(file, '.json')}`; + result[key] = fullPath; + } + }); + + return result; +} + +function generateTranslationsIndex() { + let translations = {}; + let files = listJsonFiles(translationsDir); + + Object.entries(files).forEach(([key, filePath]) => { + let content = JSON.parse(fs.readFileSync(filePath, 'utf8')); + translations[key] = content; + }); + + fs.writeFileSync(outputFile, JSON.stringify(translations, null, 4), 'utf8'); + console.log(`Translations index generated: ${outputFile}`); +} + +generateTranslationsIndex(); diff --git a/merged/core/server/moved.json b/merged/core/server/moved.json new file mode 100644 index 0000000..766cad7 --- /dev/null +++ b/merged/core/server/moved.json @@ -0,0 +1,10 @@ +{ + "de": "Du wurdest auf %s verschoben.", + "en": "You have been moved to %s.", + "fr": "Vous avez éteindre vers %s.", + "it": "Hai essere spostato su %s.", + "pl": "Byłeś przeniesiony do %s.", + "ru": "Ты был перемещен в %s.", + "zh": "你已被移动到 %s.", + "jp": "あなたは %s に移動しました。" +} \ No newline at end of file diff --git a/merged/core/tablist/unknown.json b/merged/core/tablist/unknown.json new file mode 100644 index 0000000..a6ec65f --- /dev/null +++ b/merged/core/tablist/unknown.json @@ -0,0 +1,10 @@ +{ + "de": "Unbekannt", + "en": "Unknown", + "fr": "Inconnu", + "it": "Sconosciuto", + "pl": "Nieznany", + "ru": "Неизвестно", + "zh": "未知", + "jp": "不明" +} \ No newline at end of file diff --git a/merged/party/any/create.json b/merged/party/any/create.json new file mode 100644 index 0000000..6f46562 --- /dev/null +++ b/merged/party/any/create.json @@ -0,0 +1,10 @@ +{ + "de": "Party erstellen", + "en": "Create party", + "fr": "Créer une partie", + "it": "Crea una partita", + "pl": "Utwórz grupę", + "ru": "Создать группу", + "zh": "创建队伍", + "jp": "グループ作成" +} \ No newline at end of file diff --git a/merged/party/any/disbanded.owner.left.json b/merged/party/any/disbanded.owner.left.json new file mode 100644 index 0000000..3b5f0e0 --- /dev/null +++ b/merged/party/any/disbanded.owner.left.json @@ -0,0 +1,10 @@ +{ + "de": "Die Party wurde aufgelöst, weil der Party Leiter hat die Party verlassen hat.", + "en": "The party was disbanded because the party leader left the party.", + "fr": "La partie a disparu car le leader de la partie a quitter la partie.", + "it": "La partita è stata disbandata perché il leader della partita ha lasciato la partita.", + "pl": "Grupa została rozłączona, ponieważ lider grupy opuścił grupę.", + "ru": "Группа была расформирована, поскольку лидер группы покинул группу.", + "zh": "队伍因队长离开队伍而解散。", + "jp": "グループは、グループリーダーがグループを離れたため解散しました。" +} \ No newline at end of file diff --git a/merged/party/any/joined.json b/merged/party/any/joined.json new file mode 100644 index 0000000..a8c5c5f --- /dev/null +++ b/merged/party/any/joined.json @@ -0,0 +1,10 @@ +{ + "de": "%s hat die Party beigetreten.", + "en": "%s has joined the party.", + "fr": "%s a rejoindre la partie.", + "it": "%s ha partecipato alla partita.", + "pl": "%s dołacono do grupy.", + "ru": "%s присоединился к группе.", + "zh": "%s 加入队伍。", + "jp": "%s はグループに参加しました。" +} \ No newline at end of file diff --git a/merged/party/any/left.json b/merged/party/any/left.json new file mode 100644 index 0000000..aaec9d2 --- /dev/null +++ b/merged/party/any/left.json @@ -0,0 +1,10 @@ +{ + "de": "%s hat die Party verlassen.", + "en": "%s has left the party.", + "fr": "%s a quitter la partie.", + "it": "%s ha lasciato la partita.", + "pl": "%s opuścił grupę.", + "ru": "%s покинул группу.", + "zh": "%s 离开队伍。", + "jp": "%s はグループを離れました。" +} \ No newline at end of file diff --git a/merged/party/sender/left.party.json b/merged/party/sender/left.party.json new file mode 100644 index 0000000..779512f --- /dev/null +++ b/merged/party/sender/left.party.json @@ -0,0 +1,10 @@ +{ + "de": "Du hast die Party verlassen.", + "en": "You have left the party.", + "fr": "Vous avez quitter la partie.", + "it": "Hai lasciato la partita.", + "pl": "Opuściłeś grupę.", + "ru": "Ты покинул группу.", + "zh": "你离开队伍。", + "jp": "あなたはグループを離れました。" +} \ No newline at end of file diff --git a/merged/party/sender/not.in.party.json b/merged/party/sender/not.in.party.json new file mode 100644 index 0000000..ae79f2a --- /dev/null +++ b/merged/party/sender/not.in.party.json @@ -0,0 +1,10 @@ +{ + "de": "Du bist nicht in einer Party.", + "en": "You are not in a party.", + "fr": "Vous n'etes pas dans une partie.", + "it": "Non sei in una partita.", + "pl": "Nie jesteś w grupie.", + "ru": "Ты не в группе.", + "zh": "你不在队伍中。", + "jp": "あなたはグループにいません。" +} \ No newline at end of file diff --git a/translations.json b/translations.json deleted file mode 100644 index 189cc65..0000000 --- a/translations.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "party.create": { - "de": "Party erstellen", - "en": "Create party", - "fr": "Créer une partie", - "it": "Crea una partita", - "pl": "Utwórz grupę", - "ru": "Создать группу", - "zh": "创建队伍" - } -}