Android: Get missing translations for strings-resources

Viewed 22233

In Android, you can specify the texts in the default locale in res/values/strings.xml. Additional translations can be added for new languages in res/values-it/strings.xml (for Italian for example). If a string is not translated, the fallback-default locale is used.

Currently I can not tell which strings I still need to translate (so are in values/strings.xml, but not in values-$/strings.xml for all $ in languages) and which are translated, although the are obsolte (so are in values-$/strings.xml, but not in values/strings.xml exists $ in languages)

I'm searching for a tool which gives me the translations which are missing and the one which are obsolete.

To be honest, it is not that difficult to write such a tool for the command-line, I can only hardly believe nobody has already done this.

16 Answers

On Android Studio, Analyze > Run Inspection By Name, Type following and execute inspections for Custom scope Project Production Files.

  • Extra translation
  • Incomplete translation

I created a tool to solve precisely this problem. You can download the tool from https://github.com/vijtheveg/tea.

The tool can generate an Excel spreadsheet from the Android project, like the one shown below, with the source strings and their translations shown side-by-side. Excel spreadsheet for translation

Most importantly, the tool will output only those strings that were newly added or modified since the last translation!

You can send this Excel spreadsheet to your translator and once the translations are filled in, you can regenerate the string XML files for the target language from this Excel file.

Best of all, you can perform this process (add/delete/modify strings in the source language XML files) -> (generate Excel and send it for translation) -> (regenerate target language XML files) any number of times, and each time the tool will only output those strings that need translation into the Excel file. The tool will also delete strings that have been removed from the source language from the target language XML files.

More details on the tool's GitHub page above. I hope you find it useful.

Steps to get all missing translations are :

  1. enable lint error for missing translation in app level build.gradle

    lintOptions {
       abortOnError false
       enable 'MissingTranslation'
    }
    
  2. add languages to compare inside default config of level.gradle (here english and hindi)

    resConfigs "en", "hi"
    
  3. right click on default strings.xml. Then Analyze -> Inspect Code

enter image description here

  1. now check inspection result. Android -> Lint -> Correctness -> Messages > Incomplete Translation

enter image description here

  1. All selected strings are missing translations

If you also want to let other people contribute and have a web site you can use the open source TranslateApp-tool.

It keeps track of what is translated and not, you can also update the default language and say if translations should be invalidated of not.

https://bitbucket.org/erik_melkersson/translateapp Note: I am the author of the tool. Pull requests with updates are welcome. I actively use the tool myself.

Related