[android] Android Lint가 번역되지 않은 문자열에 대해 불평하지 않도록 방지

value-* 디렉토리 내의 파일에있는 문자열 이 의도적으로 다른 언어로 번역되지 않도록 지정할 수 있습니까? 모든 언어에 공통적이고 번역이 필요하지 않은 문자열이 많이 있으므로 디렉토리 unlocalized-strings.xml내에 파일을 생성했습니다 values. 문제를 확인하기 위해 Android Lint를 실행하면 일부 번역이 누락되었다는 메시지가 계속 표시됩니다 .. 원하지 않습니다. 전체 프로젝트에서이 검사를 비활성화하려면 일부 XML 파일에서만 비활성화하고 싶습니다. 가능합니까?

"title_widget_updater_service" is not translated in de, en, en-rUS, it

Issue: Checks for incomplete translations where not all strings are translated
Id: MissingTranslation

If an application has more than one locale, then all the strings declared in one language
should also be translated in all other languages.

By default this detector allows regions of a language to just provide a subset of the
strings and fall back to the standard language strings. You can require all regions to
provide a full translation by setting the environment variable
ANDROID_LINT_COMPLETE_REGIONS.

지역화되지 않은 문자열 영역 을 어떻게 정의 할 수 있습니까?



답변

모든 파일을 무시하는 방법을 모르겠지만 다음을 사용하여 문자열별로 수행 할 수 있습니다.

<string name="hello" translatable="false">hello</string>


답변

다음과 같이 문자열 파일 ignore에있는 tools네임 스페이스 의 속성입니다 .

<?xml version="1.0" encoding="utf-8"?>
<resources
  xmlns:tools="http://schemas.android.com/tools"
  tools:ignore="MissingTranslation" >

  <!-- your strings here; no need now for the translatable attribute -->

</resources>


답변

추가 build.gradle:

android {
     lintOptions {
        disable 'MissingTranslation'
    }
}


답변

내가 아는 세 가지 방법이 있습니다.

값으로 수정 값을 적용하려면 다음 translatable="false"과 같이 <string>정의에 속성 을 설정하십시오 .

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

번역하지 말아야 할 리소스가 많은 경우 이름이 지정된 파일에 배치 할 수 donottranslate.xml있으며 Lint는 번역 할 수없는 리소스를 모두 고려합니다.

Hackers Keyboard 프로젝트 소스 를 탐색하는 동안 발견 한 또 다른 방법 : 리소스 파일에
접두사 donottranslate-를 추가 할 수 있습니다 . 이전 예에서와 같이 Lint는 번역 할 수없는 리소스를 모두 고려합니다.
귀하의 경우에는, 당신은 대체 할 수 있습니다 unlocalized-strings.xmldonottranslate-strings.xml. 작동하는 것 같지만이 팁에 대한 문서를 찾지 못했습니다.

참조 : Android 도구 프로젝트 사이트 : 번역 할 수없는 문자열


답변

이 치명적인 Lint 오류를 비활성화하는 Android Studio 솔루션은 다음과 같습니다.

여기에 이미지 설명 입력


답변

Lint를 비활성화하는 대신 필요한 것은 속성으로 표시하는 것입니다.

translatable="false"


답변

파일 이름이 ” donottranslate “(예 : donottranslate.xml , donottranslate_urls.xml 등)로 시작하는 리소스 파일을 생성하면 Lint는 누락 된 번역을 확인할 때 해당 문자열을 모두 무시합니다.