.phrase.yml
파일은 재사용된 명령줄 인수를 저장하는 데 사용됩니다.
지원 인수:
-
project_id
프로젝트 ID
-
file_format
소스 및 대상 항목 내에서 명시적으로 지정되지 않은 경우 사용되는 파일 형식
-
per_page
페이지별 응답에서 반환된 항목의 수입니다.
샘플 구성 파일
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 옵션은 업로드
API 엔드포인트와 동일하고, Pull 옵션은 로캘 다운로드
API 엔드포인트와 동일합니다.
Push 예:
push: sources: - file: ./locales/en.json params: update_translations: true
Pull 예:
pull: targets: - file: "./locales/example.yml" params: include_unverified_translations: true
파일 형식에 따라 매개 변수 섹션에 형식 옵션을 적용할 수 있습니다. 형식 옵션은 업로드, 다운로드 또는 둘 다에 적용할 수 있습니다.
형식 예:
params: format_options: convert_placeholder: true
일부 파일 형식으로 파일 구문을 더 많이 제어할 수 있습니다.
phrase: pull: targets: - file: file.xml params: format_options: convert_placeholder: true push: sources: - file: file.csv params: format_options: column_separator: ";"
다음 자리 표시자 및 Globbing 작업 연산자가 파일 항목 내 경로에 배치될 수 있습니다.
Globbing
*
와 **
는 Globbing 연산자입니다. *
는 경로에 있는 모든 폴더를 건너뜁니다. **
는 표준 Globbing 연산자와 마찬가지로 재귀적이고 비포괄적으로 모든 문자를 매칭합니다.
예:
# a file pattern ./abc/**/*.yml
# with a few files on your system ./abc/defg/en.yml ./abc/es.yml ./fr.yml
# selects ./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: sources: - file: ./locales/en.json params: update_translations: false locale_id: YOUR_LOCALE_ID # the locale must exist remotely
참고
가져온 번역 항목은 삭제 수 없습니다. 필요한 경우 관련 API 엔드포인트를 통해 번역을 비어 있는
값으로 업데이트하십시오.
Ruby on Rails : 지정된 파일 유형 업로드
./config/locales/
에 있는 .yml로 끝나는 모든 파일을 업로드합니다
. Ruby on Rails YAML 파일에는 로캘 정보가 포함되어 있으므로 명시적으로 로캘 지정할 필요가 없습니다. Update_translations
가 참으로 설정되므로 기존 데이터를 덮어쓰면서 번역 변경 사항을 모두 가져옵니다.
phrase: push: sources: - 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: sources: - 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: sources: - 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: sources: - 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
에서 필수 패턴을 지정합니다.
phrase: access_token: ACCESS_TOKEN project_id: PROJECT_ID file_format: "xml" push: sources: - file: "./res/values-<locale_code>/strings.xml" pull: targets: - file: "./res/values-<locale_code>/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 # Unique locale id for English locale_id: LOCALE_ID - file: ./app/src/main/res/values-de/strings.xml params: file_format: xml # Unique locale id for German locale_id: LOCALE_ID - file: ./app/src/main/res/values-de-rAU/strings.xml params: file_format: xml # Unique locale id for Austrian locale_id: LOCALE_ID push: sources: - 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 - file: ./app/src/main/res/values-de-rAU/strings.xml params: file_format: xml locale_id: LOCALE_ID