Is it possible to ignore a specific locale for translation with lint in Android Studio?

Viewed 482

As the title says I'm looking to ignore specific locales from the MissingTranslation lint error in Android Studio. Here's the reason behind this question:

I have multiple Android Studio projects for specific applications. All of these applications reference one or more modules from a shared library project that contains common code, resources, etc.

The shared modules contain common code, widgets, resources, and strings that are used across all the other applications. The problem is that my shared modules have translations for more languages than my applications so the applications complain that application specific strings are not translated in the additional languages included in the shared modules.

I have a feeling that if I built the shared modules as libraries and referenced them that way, rather than referencing the code directly in the application projects, this error would go away. However when I am working in an application I am often modifying code in the shared libraries as well so it is much more efficient to reference the code directly rather than a built module.

I am also aware that I can disable the MissingTranslation entirely but I would like to be aware that an application specific string is not translated in a locale that application supports.

1 Answers

The MissingTranslation Lint warning will always appear if there is a chance that users will see a partially translated app.

Therefore, you have two choices:

  1. Limit languages only to those you specifically support by removing unused alternative resources (thus removing the translated strings from your library project for unsupported languages):
    android {
        defaultConfig {
            ...
            resConfigs "en", "fr"
        }
    }
  1. Suppressing the MissingTranslation warning.
Related