Android: Get missing translations for strings-resources

前端 未结 16 1386
無奈伤痛
無奈伤痛 2020-12-02 22:43

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/value

相关标签:
16条回答
  • 2020-12-02 23:24

    The new official Android Lint tool helps you detect this problem, and many others: http://tools.android.com/tips/lint

    0 讨论(0)
  • 2020-12-02 23:24

    There's a much improved version of the Android Dev Kit lint tool in Eclipse since SDK version 17 - see the docs here: New Eclipse Lint UI

    Just click the "lint" tool bar item, run it on your project then open the "is not translated" item that will appear to show you every tag that needs translation.

    Credit to satur9nine - this is an updated version of their answer which lead me to this one.

    0 讨论(0)
  • 2020-12-02 23:24

    I built a command line tool called ams (for android-missing-strings) that prints a report of every missing entry as well as leftover entries that no longer appear on your base strings.xml file.

    It's available here https://github.com/gubatron/android-missing-strings

    ams - Android Missing Strings reporting tool.
    
    Usage:
    ams [-l xx[,yy,zz...]] -o <output_file>
    
    Options:
    -h --help            Print this help
    
    
    -l --lang <xx>       Specify a language or many with comma separated 2-char language codes.
    
                         e.g:  -l cn         (creates report for Chinese strings.xml)
                               -l cn,it,fr   (creates report for Chinese, Italian and French strings.xml files)
    
                         If this parameter is ommited, a report with every language file found will be created.
    
    
    -o --oFile           Specify the output file name for the report
    
    Copyright (c) 2014 - The Mit License (MIT)
    
    Authors:
    Angel Leon <gubatron@gmail.com>
    Katay Santos <kataysantos@gmail.com>
    
    0 讨论(0)
  • 2020-12-02 23:27

    Interesting question. I've wrote simple script to find duplicate resources in android project at https://gist.github.com/1133059. It is ugly, I know, but I'll rewrite it in a few days and maybe create a project on github. To run it from console:
    $scala DuplicatesFinder.scala /path/to/android/project

    UPDATE:
    I've made a project on github https://github.com/4e6/android-localization-helper, maybe someone find it helpful

    0 讨论(0)
  • 2020-12-02 23:30

    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

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

    1. All selected strings are missing translations
    0 讨论(0)
  • 2020-12-02 23:32

    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.

    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.

    0 讨论(0)
提交回复
热议问题