Push
$ phrase push
Push 명령은 로컬 프로젝트 디렉토리에서 찾은 파일을 업로드합니다. .phrase.yml 파일을 사용하여 업로드할 파일을 지정하고 추가 매개 변수를 설정합니다. <tag> 자리 표시자는 태그에 따라 개별 파일로 키를 다운로드하는 데에도 사용될 수 있습니다.
Pull
$ phrase pull
Push 명령과 유사하지만, 예외적으로 globbing은 사용할 수 없습니다. 자리 표시자를 사용할 때마다 가능한 한 <locale_name>를 사용하십시오. 특정 태그가 있는 키로 파일을 Pull하려면 다음과 같은 tags 매개 변수를 사용합니다.
phrase:
pull:
targets:
- file: path/to/file/<locale_name>.yml
params:
tags:tag_name
<tag> 자리 표시자를 사용하려면 원하는 태그가 params 섹션에 나열되어야 합니다.
매개 변수
Push 및 Pull 명령은 .phrase.yml 파일 내에 구성할 수 있습니다.
푸시 예:
push:
소스:
- 파일: ./locales/en.json
params:
update_translations: true
풀 예:
pull:
targets:
- 파일: "./locales/example.yml"
params:
include_unverified_translations: true
파일 형식에 따라 매개 변수 섹션에 형식 옵션을 적용할 수 있습니다. 형식 옵션은 업로드, 다운로드 또는 둘 다에 적용할 수 있습니다.
형식 예:
params:
format_options:
convert_placeholder: true
일부 파일 형식으로 파일 구문을 더 많이 제어할 수 있습니다:
phrase:
pull:
targets:
- 파일: file.xml
params:
format_options:
convert_placeholder: true
push:
소스:
- 파일: file.csv
params:
format_options:
column_separator: ";"
다음 자리 표시자 및 Globbing 작업 연산자가 파일 항목 내 경로에 배치될 수 있습니다.
Globbing
*와 **는 Globbing 연산자입니다. 단일 별표 *는 경로에 있는 모든 폴더를 건너뜁니다. 이중 별표 **는 표준 Globbing 연산자와 마찬가지로 재귀적이고 비포괄적으로 모든 문자를 매칭합니다.
예:
# 파일 패턴 ./abc/**/*.yml
# 시스템에 있는 몇 개의 파일과 함께 ./abc/defg/en.yml ./abc/es.yml ./fr.yml
# 선택 ./abc/defg/en.yml ./abc/es.yml
pull 명령으로 파일을 다운로드할 때 /abc/defg/<locale_name>.yml 대신 ./**/*.yml와 같은 명시적인 파일 패턴을 제공합니다.
특정 로캘에 파일 업로드
주어진 locale_id와 함께 en.json 파일을 ./locales/ 디렉토리에 업로드합니다(로캘은 이미 존재해야 함).
Update_translations가 거짓으로 설정되므로 새 키와 번역만 가져옵니다. 참으로 설정된 경우 클라이언트는 기존 번역에 대한 로컬 변경 사항도 가져와 이미 있는 컨텐츠를 덮어씁니다.
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: nested_json
push:
소스:
- 파일: ./locales/en.json
params:
update_translations: false
locale_id: YOUR_LOCALE_ID # 로캘은 원격으로 존재해야 합니다.
참고
가져온 번역 항목은 삭제할 수 없습니다. 필요한 경우 관련 API 엔드포인트를 통해 번역을 비어 있는 값으로 업데이트하십시오.
Ruby on Rails: 지정된 파일 유형 업로드
./config/locales/에 있는 .yml로 끝나는 모든 파일을 업로드합니다. Ruby on Rails YAML 파일에는 로캘 정보가 포함되어 있으므로 명시적으로 로캘을 지정할 필요가 없습니다. Update_translations가 참으로 설정되므로 기존 데이터를 덮어쓰면서 번역 변경 사항을 모두 가져옵니다.
phrase:
push:
소스:
- file: ./config/locales/*.yml
params:
update_translations: true
file_format: yml
iOS Strings 일치 항목
.lproj 폴더에 Localizable.strings 이름의 파일을 가진 모든 iOS Strings 파일을 일치시킵니다.
<locale_code>는 / 이후와 .lproj 이전에 일치하는 모든 항목으로, 로캘을 생성하고 식별합니다.
update_translations 매개 변수는 생략되어 거짓으로 설정한 것과 동일한 효과를 가집니다.
phrase:
push:
소스:
- file: "./<locale_code>.lproj/Localizable.strings"
params:
file_format: strings
하나의 현지화 프로젝트에 대한 여러 Strings 프로젝트 유지 관리
번역을 작은 범주로 분할하여 프로젝트의 범위를 제한하려면 구성 파일을 편집합니다.
구성 파일을 요구 사항에 맞게 수정한 다음 소스 제어 또는 버전 제어 시스템에 확인합니다.
Rails
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: "yml"
push:
소스:
- file: "./config/locales/*.yml"
pull:
targets:
- file: "./config/locales/<locale_name>.yml"
iOS Strings
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: "strings"
push:
소스:
- file: "./<locale_code>.lproj/Localizable.strings"
pull:
targets:
- file: "./<locale_code>.lproj/Localizable.strings"
- file: "./<locale_code>.lproj/Localizable.stringsdict"
params:
#file_format can be overwritten
file_format: "stringsdict"
Android XML
Android는 표준 ISO 언어 코드를 파일 패턴으로 사용하지 않습니다. .phrase.yml에서 필수 패턴을 지정합니다.
각 로캘에 대해 별도의 풀 대상을 정의하는 대신, 전역 locale_mapping 설정과 <locale_name> 자리 표시자를 사용하십시오. CLI는 해당 로캘에 대한 매핑에서 사용자 지정 이름을 사용하고, 다른 모든 언어에 대해 기본 Phrase 로캘 코드로 대체됩니다.
예:
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: "xml"
# Phrase 로캘을 Android 전용 디렉토리 이름에 매핑합니다.
locale_mapping:
en-US: values
de-DE: values-de-rDE
fr-FR: values-fr
push:
소스:
# 소스 파일은 기본 언어로, 'values'에 매핑됩니다.
- file: ./app/src/main/res/values/strings.xml
params:
locale_id: en-US # Phrase에서 소스 로캘과 일치해야 합니다.
pull:
targets:
# 매핑에 의해 대체될 <locale_name> 자리 표시자를 사용하십시오.
- file: ./app/src/main/res/<locale_name>/strings.xml
로캘을 명시적으로 설정하는 예
기본 언어인 영어와 독일 로캘, 오스트리아 독일어를 위한 독일 지역 로캘 사례:
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: xml
pull:
targets:
- file: ./app/src/main/res/values/strings.xml
params:
file_format: xml
# 영어에 대한 고유 로캘 ID
locale_id: LOCALE_ID
- file: ./app/src/main/res/values-de/strings.xml
params:
file_format: xml
# 독일어 고유 로캘 ID
locale_id: LOCALE_ID
- 파일: ./app/src/main/res/values-de-rAU/strings.xml
params:
file_format: xml
# 오스트리아 고유 로캘 ID
locale_id: LOCALE_ID
push:
소스:
- file: ./app/src/main/res/values/strings.xml
params:
file_format: xml
locale_id: LOCALE_ID
- file: ./app/src/main/res/values-de/strings.xml
params:
file_format: xml
locale_id: LOCALE_ID
- 파일: ./app/src/main/res/values-de-rAU/strings.xml
params:
file_format: xml
locale_id: LOCALE_ID
다중 플랫폼 예제
하나의 구성에서 여러 대상에 대한 번역을 자동으로 푸시하고 풀 수 있습니다.
phrase:
access_token: ACCESS_TOKEN
project_id: PROJECT_ID
file_format: nested_json
push:
소스:
# 웹 JSON
- 파일: "apps/web/src/assets/i18n/.json"
params:
file_format: nested_json
locale_id: LOCALE_ID
# Android XML
- 파일: "apps/android/app/src/main/res/values-/strings.xml"
params:
file_format: android
locale_id: LOCALE_ID
# iOS Strings
- 파일: "apps/ios/.lproj/Localizable.strings"
params:
file_format: strings
locale_id: LOCALE_ID
pull:
targets:
- 파일: "apps/web/src/assets/i18n/.json"
params:
file_format: nested_json
locale_id: LOCALE_ID
- 파일: "apps/android/app/src/main/res/values-/strings.xml"
params:
file_format: android
locale_id: LOCALE_ID
- 파일: "apps/ios/.lproj/Localizable.strings"
params:
file_format: strings
locale_id: LOCALE_ID