Prerequisites
-
API access token with
read writescope -
Strings project ID shown in the tab of the project settings
-
Basic YAML knowledge, including indentation
-
Git read and write permissions if the repository will run
phrase pushorphrase pullin CI
To automatically create a configuration file, follow these steps:
-
From the command line, type
phrase initto create a .phrase.yml file.The configuration wizard starts in the CLI.
-
Provide:
-
Access token
Paste or hit Enter to let $PHRASE_ACCESS_TOKEN be used
-
Strings Project ID (e.g.
abcdef1234567890abcdef1234567890) -
Locale file format (e.g. json, rails_yaml, ios_strings)
-
Local path
Glob or exact path to locale files in the project codebase (e.g.
config/locales/*.json)
-
A basic .phrase.yml file is created in the current directory.
Tip
Supply flags to skip the wizard entirely, for example phrase init --access_token=$PHRASE_ACCESS_TOKEN --project_id=... --file_format=ios_strings --path='ios/*.strings'.
If using a manually created or copied configuration file, place it in one of these locations:
-
The current working directory (
pwd) in which the CLI client is called. -
The home directory of the current user (
$HOMEin Unix,$HomePathin Windows). -
The path specified in the
PHRASEAPP_CONFIGenvironment variable. -
Path to configuration file via the
--configflag (e.g./some/path/to/phrase.yml).
CLI Options Overview
Sample configuration file.
Global Settings
|
Key |
Type |
Required |
Description |
|---|---|---|---|
|
|
string |
Yes |
Personal access token. |
|
|
string |
Yes |
Public project ID shown in Strings project settings. |
|
|
string |
Yes |
Default locale file format (API extension). |
|
|
object |
No |
Maps Phrase locale IDs to custom names for use in file paths with the If a locale is not specified in the mapping, its standard Phrase locale name is used by default. |
Push: Sources
|
Key |
Type |
Required |
Description |
|---|---|---|---|
|
|
path |
Yes |
Relative path to file(s) to push, e.g. |
|
|
string |
Override the global |
Push: Parameters
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
string |
header |
Override file format for this source. |
|
|
string |
— |
Locale name (e.g. |
|
|
string |
— |
Comma-separated tags for new keys. |
|
|
boolean |
|
Update existing translations with file content. |
|
|
boolean |
|
Pass |
|
|
boolean |
|
Update key descriptions; empty descriptions overwrite existing. |
|
|
boolean |
|
Upload tags are not created. |
|
|
boolean |
|
Updated translations are not unverified. |
|
|
string |
— |
File encoding: |
|
|
object |
— |
(Excel/CSV only) Map locale codes to column names, e.g. |
|
|
boolean |
|
Auto-fetch translations for the uploaded language. |
|
|
boolean |
|
Mark imported translations as reviewed (advanced review workflow must be enabled). |
Push: Format Options
All available format options are supported in the CLI configuration. See Sample configuration file for examples.
Pull: Targets
|
Key |
Type |
Required |
Description |
|---|---|---|---|
|
|
path |
Yes |
Relative path for pulled locale files, e.g. |
|
|
string |
Override the global |
Pull: Parameters
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
string |
— |
Must be |
|
|
string |
— |
Locale name (e.g. |
|
|
string |
— |
Comma-separated tags to filter which keys to pull. |
|
|
boolean |
|
Include keys without any translations. |
|
|
boolean |
|
Exclude zero-form plurals when empty. |
|
|
boolean |
|
Include keys that already have translations. |
|
|
boolean |
|
Preserve |
|
|
string |
— |
File encoding: |
|
|
boolean |
|
If |
|
|
boolean |
|
If |
|
|
string |
— |
Fallback locale to use for missing translations. |
Pull: Format Options
All available format options are supported in the CLI configuration. See Sample configuration file for examples.
Multiple configurations
In monorepos, place one configuration file in each package and run the CLI from the corresponding subfolder, or point CI jobs to different configuration files with the --config option.
Git integration
GitLab:
-
The
.phrase.ymlconfiguration file must be present in the repository. The file defines which files to import (pull) or export (push) from the repository. -
Read and write access are required for the repository.
-
Incorrectly defined configuration files may cause errors. Ensure that the file contains at least one push and one pull target, correct file formats and the correct setting of the
update_translationsparameter. -
Use GitLab 9.5 or newer to ensure API compatibility.
GitHub:
-
The
.phrase.ymlconfiguration file must be present in the repository. The file defines which files to import (pull) or export (push) from the repository. -
Read and write access are required for the repository.
-
Incorrectly defined configuration files may cause errors. Ensure that the file contains at least one push and one pull target, correct file formats and the correct setting of the
update_translationsparameter. -
A GitHub access token for the scope of the repository (
public_repoif synchronizing with a public repository). -
If SSO is enabled in GitHub, it must also be enabled for the access token.
-
The phrase_translations branch cannot be protected.
-
Ensure repository settings do not require signed commits.
BitBucket:
-
The
.phrase.ymlconfiguration file must be present in the repository. The file defines which files to import (pull) or export (push) from the repository. -
Read and write access are required for the repository.
-
Incorrectly defined configuration files may cause errors. Ensure that the file contains at least one push and one pull target, correct file formats and the correct setting of the
update_translationsparameter.