Getting started
In this guide, we will setup you’re first project, sync a localization file and make updates on a sample project.
Install the Accent CLI
This CLI will be used to communicate with Accent’s API.
$ npm install -g accent-cli
This guide uses accent-cli v0.9.0
Configure the tool
accent-cli reads from the accent.json
file. The file should contain valid JSON representing the configuration of your project.
If your project stores the localization files in app/locales
, the accent.json
file should look like:
{
"apiUrl": "http://your.accent.instance",
"apiKey": "2nziVSaa8yUJxLkwoZA",
"files": [
{
"format": "json",
"source": "app/locales/fr/*.json",
"target": "app/locales/%slug%/%document_path%.json"
}
]
}
With this config, for each JSON file in the app/locales/fr
directory, a file will be created in Accent. the file are translated and written locally with the target
param.
It means that if you have a en
language in Accent alongside the fr
language, a sync
will write the file locally to app/locales/fr/foo.json
and app/locales/en/foo.json
.
Name pattern
{
"apiUrl": "http://your.accent.instance",
"apiKey": "2nziVSaa8yUJxLkwoZA",
"files": [
{
"namePattern": "file",
"format": "json",
"source": "app/locales/fr/*.json",
"target": "app/locales/%slug%/%document_path%.json"
}
]
}
file (default)
The default document name parsing is file
.
Given the source app/locales/fr/*.json
and a file app/locales/fr/admin.json
, the document path in Accent will be admin
.
parentDirectory
Some frameworks and tools stores all translations inside the same directory.
Given the source app/locales/**/*.json
and a file app/locales/admin/fr.json
, the document path in Accent will be admin
.
fullDirectory
Given the source app/locales/**/*.json
and a file app/locales/admin/fr.json
, the document path in Accent will be app/locales/admin
.
Sync your first file
This will sync the file app/locales/fr/translations.json
.
$ accent sync
Fetch config... ✓
=== Sync My First Project
Syncing paths (1)
→ app/locales/fr/*.json
app/locales/fr/translations.json
✓ Successfully synced the files in Accent
Writing paths (1)
→ app/locales/fr/*.json
app/locales/fr/translations.json
✓ Successfully write the locale files from Accent
You can also preview the changes that a sync will make before overwriting your locale files!
$ accent sync --dry-run
Fetch config... ✓
=== Sync My First Project
Syncing paths (1)
→ app/locales/fr/*.json
app/locales/fr/translations.json
new 10
remove 3
Et Voilà!
You can now start to translate your project! After you have made some changes, just run the sync
command to update your master language.
Adding another language
In the web UI, you can add another language which will follow the master language. It will add the same strings when you sync, remove the same strings and add conflicts when strings in the master language are marked as conflicts.
After this is done, the target
section of your config will automatically write translated lanugages in your project.
Now, if you want to sync your translations, you just use the add-translations
flag.
Of course you can preview first.
$ accent sync --add-translations --dry-run
Fetch config... ✓
=== Add translations My First Project
Adding translations paths (1)
→ app/locales/en/*.json
app/locales/en/translations.json
update 4
And update locale file when everything looks good!
$ accent sync --add-translations
Hooks, stats…
And more features coming soon, the accent-cli is a must for Accent users!