From 588f4c57d31c09654df4788076d649ecbb775cd8 Mon Sep 17 00:00:00 2001 From: mklepp Date: Thu, 25 Jun 2015 11:26:39 +0200 Subject: [PATCH] Add build step description for android/gradle to README.md --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8884b4d..4cdca33 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Whitepace in this file is mostly ignored. If you absolutely need to put spaces a en = No fr = Non ja = いいえ - + [[Errors]] [path_not_found_error] en = The file '%@' could not be found. @@ -57,7 +57,7 @@ Whitepace in this file is mostly ignored. If you absolutely need to put spaces a en = The network is currently unavailable. tags = app1 comment = An error describing when the device can not connect to the internet. - + [[Escaping Example]] [list_item_separator] en = `, ` @@ -84,7 +84,7 @@ If you would like to enable twine to create language files in another format, cr ## Usage Usage: twine COMMAND STRINGS_FILE [INPUT_OR_OUTPUT_PATH] [--lang LANG1,LANG2...] [--tags TAG1,TAG2,TAG3...] [--format FORMAT] - + ### Commands #### `generate-string-file` @@ -149,6 +149,8 @@ The easiest way to create your first strings.txt file is to run the `consume-all ## Twine and Your Build Process +### Xcode + It is easy to incorporate Twine right into your iOS and OS X app build processes. 1. In your project folder, create all of the `.lproj` directories that you need. It does not really matter where they are. We tend to put them in `Resources/Locales/`. @@ -165,6 +167,21 @@ It is easy to incorporate Twine right into your iOS and OS X app build processes Now, whenever you build your application, Xcode will automatically invoke Twine to make sure that your `.strings` files are up-to-date. +### Android Studio/Gradle + +Add the following task at the top level in app/build.gradle: +``` +task generateStrings { + String script = 'if hash twine 2>/dev/null; then twine generate-string-file strings.txt ./src/main/res/values/generated_strings.xml; fi' + exec { + executable "sh" + args '-c', script + } +} + +Now every time you build your app the strings are generated from the twine file. + + ## User Interface * [Twine TextMate 2 Bundle](https://github.com/mobiata/twine.tmbundle) — This [TextMate 2](https://github.com/textmate/textmate) bundle will make it easier for you to work with Twine strings files. In particular, it lets you use code folding to easily collapse and expand both strings and sections.