Android XML 리소스
Lingo.dev CLI를 사용한 Android XML 리소스 파일의 AI 번역
Android XML 리소스란 무엇인가요?
Android는 현지화를 위한 문자열 리소스를 저장하기 위해 XML 기반 리소스 파일을 사용합니다. 이러한 파일은 일반적으로 res/values/ 디렉토리에 로케일별 하위 디렉토리(예: 스페인어의 경우 res/values-es/)와 함께 저장됩니다.
예시:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string name="welcome_message">Hello, world!</string>
<string-array name="color_names">
<item>Red</item>
<item>Green</item>
</string-array>
<plurals name="notification_count">
<item quantity="one">%d new message</item>
<item quantity="other">%d new messages</item>
</plurals>
</resources>
참고: translatable="false"로 표시된 문자열은 번역에서 제외되며 소스 로케일 파일에만 나타납니다.
Lingo.dev CLI란 무엇인가요?
Lingo.dev CLI는 AI를 사용하여 앱과 콘텐츠를 번역하기 위한 무료 오픈소스 CLI입니다. 기존 파이프라인과 통합하면서 전통적인 번역 관리 소프트웨어를 대체하도록 설계되었습니다.
자세한 내용은 개요를 참조하세요.
이 가이드에 대하여
이 가이드는 Lingo.dev CLI를 사용하여 Android XML 리소스 파일을 번역하는 방법을 설명합니다.
다음 내용을 배우게 됩니다:
- 처음부터 프로젝트 생성하기
- 번역 파이프라인 구성하기
- AI로 번역 생성하기
사전 요구 사항
Lingo.dev CLI를 사용하려면 Node.js v18 이상이 설치되어 있어야 합니다:
❯ node -v
v22.17.0
1단계. 프로젝트 설정하기
프로젝트 디렉토리에 i18n.json 파일을 생성합니다:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
이 파일은 번역할 언어와 파일 시스템에서 현지화 가능한 콘텐츠가 존재하는 위치를 포함하여 번역 파이프라인의 동작을 정의합니다.
사용 가능한 속성에 대해 자세히 알아보려면 i18n.json을 참조하세요.
2단계. 소스 로케일 구성하기
_소스 로케일_은 콘텐츠가 원래 작성된 언어와 지역입니다. 소스 로케일을 구성하려면 i18n.json 파일에서 locale.source 속성을 설정하세요:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
소스 로케일은 BCP 47 언어 태그로 제공되어야 합니다.
Lingo.dev CLI가 지원하는 로케일 코드의 전체 목록은 지원되는 로케일 코드를 참조하세요.
3단계. 대상 로케일 구성
_대상 로케일_은 콘텐츠를 번역하고자 하는 언어와 지역입니다. 대상 로케일을 구성하려면 i18n.json 파일에서 locale.targets 속성을 설정하세요:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
4단계. 소스 콘텐츠 생성
아직 생성하지 않았다면, 번역할 콘텐츠가 포함된 하나 이상의 Android XML 리소스 파일을 생성하세요.
Android XML 리소스 파일의 경우 다음 요구사항이 적용됩니다:
- 파일은
<resources>루트 요소가 있는 유효한 XML이어야 합니다. - 문자열 리소스는
<string name="key">value</string>태그로 정의됩니다. - 문자열 배열은
<string-array name="key"><item>value</item></string-array>구조를 사용합니다. - 복수형은
<plurals name="key"><item quantity="one|other">value</item></plurals>구조를 사용합니다. translatable="false"로 표시된 요소는 번역되지 않습니다.- 불리언(
<bool>)과 정수(<integer>) 리소스 유형을 지원합니다. - CDATA 섹션과 HTML 엔티티는 보존됩니다.
5단계. 버킷 생성
-
i18n.json파일에서buckets객체에"android"객체를 추가하세요:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "android": {} } } -
"android"객체에서 하나 이상의include패턴 배열을 정의하세요:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "android": { "include": ["./[locale]/example.xml"] } } }이러한 패턴은 번역할 파일을 정의합니다.
패턴 자체는:
- 구성된 로케일의 플레이스홀더로
[locale]을 포함해야 합니다 - 파일 경로를 가리킬 수 있습니다(예:
"[locale]/strings.xml") - 와일드카드 플레이스홀더로 별표를 사용할 수 있습니다(예:
"[locale]/*.xml")
재귀적 글로브 패턴(예:
**/*.xml)은 지원되지 않습니다. - 구성된 로케일의 플레이스홀더로
6단계. LLM 구성하기
Lingo.dev CLI는 AI로 콘텐츠를 번역하기 위해 대규모 언어 모델(LLM)을 사용합니다. 이러한 모델 중 하나를 사용하려면 지원되는 제공업체의 API 키가 필요합니다.
가능한 빨리 시작하려면 매월 10,000 토큰의 무료 사용량을 제공하는 자체 호스팅 플랫폼인 Lingo.dev Engine을 사용하는 것이 좋습니다:
-
다음 명령어를 실행하세요:
npx lingo.dev@latest login이렇게 하면 기본 브라우저가 열리고 인증을 요청합니다.
-
안내에 따라 진행하세요.
7단계. 번역 생성하기
i18n.json 파일이 포함된 디렉토리에서 다음 명령어를 실행하세요:
npx lingo.dev@latest run
이 명령어는 다음을 수행합니다:
i18n.json파일을 읽습니다.- 번역이 필요한 파일을 찾습니다.
- 파일에서 번역 가능한 콘텐츠를 추출합니다.
- 구성된 LLM을 사용하여 추출된 콘텐츠를 번역합니다.
- 번역된 콘텐츠를 파일 시스템에 다시 작성합니다.
번역이 처음 생성될 때 i18n.lock 파일이 생성됩니다. 이 파일은 어떤 콘텐츠가 번역되었는지 추적하여 이후 실행 시 불필요한 재번역을 방지합니다.
예시
en/example.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string name="welcome_message">Hello, world!</string>
<string name="button_text">Get Started</string>
<string name="api_endpoint" translatable="false">https://api.example.com</string>
<string-array name="color_names">
<item>Red</item>
<item>Green</item>
<item>Blue</item>
</string-array>
<plurals name="notification_count">
<item quantity="one">%d new message</item>
<item quantity="other">%d new messages</item>
</plurals>
</resources>
es/example.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string name="welcome_message">¡Hola, mundo!</string>
<string name="button_text">Comenzar</string>
<string name="api_endpoint" translatable="false">https://api.example.com</string>
<string-array name="color_names">
<item>Rojo</item>
<item>Verde</item>
<item>Azul</item>
</string-array>
<plurals name="notification_count">
<item quantity="one">%d mensaje nuevo</item>
<item quantity="other">%d mensajes nuevos</item>
</plurals>
</resources>
i18n.json
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {
"android": {
"include": ["./[locale]/example.xml"]
}
}
}
i18n.lock
version: 1
checksums:
ec06a6ebae97ffd5f7afc99d9a8f051b:
app_name: 7dc70110429d46e3685f385bd2cc941c
welcome_message: 0468579ef2fbc83c9d520c2f2f1c5059
button_text: 1d5f030c4ec9c869e647ae060518b948
html_snippet: f060191b1af70b3848106a4df91f43cd
apostrophe_example: 997099339b144b06266f8da411de8d93
cdata_example: ba876d1379f854628eaebf67ea330ccc
color_names/0: bace0083b78cdb188523bc4abc7b55c6
color_names/1: 482ff383a4258357ba404f283682471d
color_names/2: a5cf034b2d370a976119335cd99f4217
mixed_items/0: 9278f79dfb062c6c04f6395108907816
mixed_items/1: 9823a57cbe6e6e84c1d025ce24a1eec4
notification_count/one: fe0aceb70f334c52a87937c36898a1d0
notification_count/other: 13acfd95b16962ebe1f67dcd343513e1