diff --git a/TRANSLATIONS.md b/TRANSLATIONS.md new file mode 100644 index 0000000..ff389d4 --- /dev/null +++ b/TRANSLATIONS.md @@ -0,0 +1,42 @@ +# Translations Guidelines + +## Overview +Translations for the "DualShock Calibration GUI" project are managed through +JSON files located in the [lang/ directory](https://github.com/dualshock-tools/dualshock-tools.github.io/tree/main/lang). + +This document provides guidelines on how to contribute translations for new languages. + +## Getting Started +To translate the project into a new language, follow these steps: + +1. **Duplicate an Existing File**: Start by duplicating an existing language file located in the `lang/` directory. For example, if you're translating into Spanish, duplicate `lang/it_it.json` and rename it to `lang/es_es.json`. + +2. **Edit the File**: Open the duplicated JSON file and replace the translations of strings with the corresponding translations in the target language. The first entry `.authorMsg` is customizable, write there your name and, if you want, your website! + +3. **Save the File**: Save the changes to the JSON file. + +4. **Update `core.js`**: Add the new language to the list of available languages (`available_langs`) in [core.js](https://github.com/dualshock-tools/dualshock-tools.github.io/blob/main/core.js). For example: + +```json +var available_langs = { + "zh_cn": { "name": "Chinese", "file": "zh_cn.json"}, + "fr_fr": { "name": "Français", "file": "fr_fr.json"}, + "hu_hu": { "name": "Hungarian", "file": "hu_hu.json"}, + "it_it": { "name": "Italiano", "file": "it_it.json"}, + "es_es": { "name": "Español", "file": "es_es.json"}, +}; +``` + +## Submitting Translations +Once you have completed the translation, you can contribute it in one of the following ways: + +- **Pull Request (PR)**: Open a Pull Request with the changes. +- **Discord**: Send the translated file to `the_al` on Discord. +- **Email**: Send the translated file to `ds4@the.al` via email. + +Feel free to adjust any details or formatting according to your preferences! + +## Thank you + +We extend our heartfelt gratitude to everyone who contributes translations to +make this project accessible to a wider audience. Thank you! diff --git a/core.js b/core.js index 858e99e..2f96956 100644 --- a/core.js +++ b/core.js @@ -8,10 +8,10 @@ var lang_cur = {}; var lang_disabled = true; var available_langs = { - "fr_fr": "fr_fr.json", - "hu_hu": "hu_hu.json", - "it_it": "it_it.json", - "zh_cn": "zh_cn.json", + "zh_cn": { "name": "中文", "file": "zh_cn.json"}, + "fr_fr": { "name": "Français", "file": "fr_fr.json"}, + "it_it": { "name": "Italiano", "file": "it_it.json"}, + "hu_hu": { "name": "Magyar", "file": "hu_hu.json"}, }; function dec2hex(i) { @@ -1030,7 +1030,38 @@ function lang_init() { var nlang = navigator.language.replace('-', '_').toLowerCase(); var ljson = available_langs[nlang]; if(ljson !== undefined) { - lang_translate(ljson); + lang_translate(ljson["file"], nlang); + } + + var langs = Object.keys(available_langs); + var olangs = ""; + olangs += '