Вопрос:

Lint: How to ignore "<key> is not translated in <language>" errors?

eclipse android-studio localization android-resources android-lint

100303 просмотра

13 ответа

35325 Репутация автора

I can't compile/debug our Android app, because the localization files are not perfect yet.

My IDE's validation tool Lint create errors saying:

newCardsOrderVals is not translated in ar, bg, ca, cs

Compiling/installing/running with Ant works fine, but I would like to use my IDE to ease debugging.

Is there a way to turn off this particular check, or ideally make it a warning rather than an error?

I understand that before release we will really need to get localisation files right, but for the time being it is not a priority as the screens themselves are being modified very frequently.

Автор: Nicolas Raoul Источник Размещён: 12.07.2012 01:45

Ответы (13)


348 плюса

35325 Репутация автора

Решение

Android Studio:

  • "File" > "Settings" and type "MissingTranslation" into the search box

Eclipse:

  • Windows/Linux: In "Window" > "Preferences" > "Android" > "Lint Error Checking"
  • Mac: "Eclipse" > "Preferences" > "Android" > "Lint Error Checking"

Find the MissingTranslation line, and set it to Warning as seen below:

Missing translations, is not translated in

Автор: Nicolas Raoul Размещён: 12.07.2012 02:09

85 плюса

1106 Репутация автора

You can set the attribute translatable="false" on the definition like this:

<string name="account_setup_imap" translatable="false">IMAP</string>

For more information: http://tools.android.com/recent/non-translatablestrings

Автор: efor18 Размещён: 13.09.2012 08:39

5 плюса

4247 Репутация автора

In addition,

Not project dependent properities, Eclipse Preferences.
In Mac, Eclipse > Preferences

enter image description here

Автор: Jinbom Heo Размещён: 15.03.2013 02:57

6 плюса

79 Репутация автора

Add following to your gradle file in android section

    lintOptions {
       disable 'MissingTranslation'
    }
Автор: chzahid Размещён: 16.08.2013 04:23

9 плюса

3938 Репутация автора

Insert in the lint.xml file this:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    ...

    <issue
        id="MissingTranslation"
        severity="ignore" />
</lint>

For more details: Suppressing Lint Warnings.

Автор: Brais Gabin Размещён: 31.01.2014 04:58

23 плюса

9344 Репутация автора

This will cause Lint to ignore the missing translation error for ALL strings in the file, yet other string resource files can be verified if needed.

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" 
    tools:ignore="MissingTranslation">
Автор: Tom Bollwitt Размещён: 03.04.2014 07:06

1 плюс

1660 Репутация автора

You can also put resources which you do not want to translate to file called donottranslate.xml.

Example and explanation: http://tools.android.com/recent/non-translatablestrings

Автор: Michal Vician Размещён: 25.04.2014 07:46

11 плюса

2739 Репутация автора

If you want to turn off the warnings about the specific strings, you can use the following:

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>    

    <!--suppress MissingTranslation -->
    <string name="some_string">ignore my translation</string>
    ...

</resources>

If you want to warn on specific strings instead of an error, you will need to build a custom Lint rule to adjust the severity status for a specific thing.

http://tools.android.com/tips/lint-custom-rules

Автор: Eduard Kotysh Размещён: 30.05.2014 10:47

1 плюс

1122 Репутация автора

Many of them has a given a different working answers, and i too got the same lint errors i make it ignore by doing the following with eclipse.

  1. click on Windows
  2. click on preferences
  3. select android > Lint Error Checking.
  4. click on ignore All > Apply > Ok.

Thats it.

Автор: raju Размещён: 07.07.2014 05:55

82 плюса

110930 Репутация автора

To ignore this in a gradle build add this to the android section of your build file:

lintOptions {
   disable 'MissingTranslation'
}
Автор: Janusz Размещён: 26.10.2014 06:49

1 плюс

11 Репутация автора

The following worked for me.

  • Click on Windows
  • Click on preferences
  • Select android > Lint Error Checking.
  • Find and select the relevant Lint checking and
  • Set the severity to 'Ignore' (on bottom right)
Автор: user4353093 Размещён: 12.12.2014 07:47

3 плюса

3040 Репутация автора

Another approach is to indicate the languages you intend to support and filter out the rest using the 'resConfigs' option with Gradle.

Check out this other answer for details

This is better, I think, because you don't have to completely ignore legitimate translation mistakes for languages you actually want to support

Автор: kip2 Размещён: 30.06.2015 03:29

8 плюса

98 Репутация автора

add the lines in your /res/values.xml file in resource root tab like this:

<resources
xmlns:tools="http://schemas.android.com/tools" 
    tools:locale="en" tools:ignore="MissingTranslation">

tools:locale set the local language to English, no need of language translation later on that for all resource strings and tools:ignore let Lint to isnore the missing translations of the resource string values.

Автор: Purvik Rana Размещён: 09.08.2015 10:38
Вопросы из категории :
32x32