From 52cc7d699a9bc335e9084ce8e515267e2279615f Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 21 Jul 2018 00:44:13 -0400 Subject: [PATCH] Added translation guide / Added locale list autogen --- .gitignore | 1 + TRANSLATING.md | 23 +++++++++++++++++++++++ build.gradle | 16 ++++++++++++++++ core/assets/locales.json | 4 +--- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 TRANSLATING.md diff --git a/.gitignore b/.gitignore index 5a3526c397..402c10f82a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ /android/assets/mindustry-saves/ /core/assets/gifexport/ /core/assets/version.properties +/core/assets/locales.json *.gif version.properties diff --git a/TRANSLATING.md b/TRANSLATING.md new file mode 100644 index 0000000000..d7712cb691 --- /dev/null +++ b/TRANSLATING.md @@ -0,0 +1,23 @@ +## Translating for Mindustry + +To begin, log in to your GitHub account, or if you don't have one yet, create it [here](https://github.com/). + +Consult [this list](https://www.science.co.il/language/Locale-codes.php) to find the locale code for your language. Once you've found it, +head over to the Mindustry GitHub repository and check the [list of bundles](https://github.com/Anuken/Mindustry/tree/master/core/assets/bundles) that have already been created. +You're looking for a file called "`bundle_`(insert locale code here)`.properties`". + +#### Editing an existing translation + +If a translation bundle already exists, that means someone has already started working on a translation. To edit it or translate text, simply click the file and press the edit (pencil) button in the top right. Once you're done editing, press the green "propose file change" button at the bottom, then "create pull request" (twice). +Once this is done, all you need to do is wait for me to approve your changes. + +#### Creating a new translation bundle + +If a translation bundle for your language *doesn't* exist, you need to create one yourself. +In the folder with all the bundles in it, click the *'create new file'* button, and name it `bundle_(locale code here).properties`. +Then, copy-paste the entire contents of the [English translation bundle](https://raw.githubusercontent.com/Anuken/Mindustry/master/core/assets/bundles/bundle.propertie) into the file, and edit it to your liking. +Once you are done, press the *propose new file* button at the bottom, then 'create pull request twice'. + +**And that's it.** + +*(...of course, that's never really it. Bother me on Discord when something inevatably goes wrong.)* \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7b0c2961a0..ddef997065 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,17 @@ allprojects { return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1) } + generateLocales = { + def output = '["en",' + def bundles = new File('core/assets/bundles/') + bundles.listFiles().each { other -> + if(other.name == "bundle.properties") return; + output += '"' + other.name.substring("bundle".length() + 1, other.name.lastIndexOf('.')) + '",' + } + output = (output.substring(0, output.size() - 1) + "]") + new File('core/assets/locales.json').text = output; + } + writeVersion = { def pfile = new File('core/assets/version.properties') def props = new Properties() @@ -135,8 +146,13 @@ project(":ios") { project(":core") { apply plugin: "java" + task finish { + generateLocales() + } + dependencies { compileOnly project(":annotations") + build.finalizedBy(finish) boolean comp = System.properties["release"] == null || System.properties["release"] == "false" diff --git a/core/assets/locales.json b/core/assets/locales.json index 4f4c9cc3d9..cc251cd10c 100644 --- a/core/assets/locales.json +++ b/core/assets/locales.json @@ -1,3 +1 @@ -[ - "en", "fr", "ru", "uk_UA", "pl", "de", "pt_BR","ko","in_ID", "ita","es","zh_TW" -] \ No newline at end of file +["en","es","pl","ita","ko","fr","ru","de","in_ID","tk","pt_BR","zh_TW","uk_UA"] \ No newline at end of file