locize cli to import / export locales, add / edit / remove sync segments
Latest commit 638ff77 Dec 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin introduce language and namespace argument for sync command Nov 19, 2018
.editorconfig cleanup and readme May 10, 2016
.eslintrc cleanup and readme May 10, 2016
.gitignore ignore package-lock.json Jun 10, 2017
CHANGELOG.md #19 try to make sync a bit safer, by checking first if folder to rm i… Dec 10, 2018
README.md introduce laravel format Nov 16, 2018
add.js fix exit code on error May 1, 2018
convertToDesiredFormat.js adding support for nested laravel files Nov 20, 2018
copyVersion.js fix exit code on error May 1, 2018
deleteNamespace.js introduce delete-namespace Jul 26, 2018
download.js add possibility to download multiple namespaces in all languages Oct 15, 2018
formats.js introduce laravel format Nov 16, 2018
get.js fix exit code on error May 1, 2018
getJob.js fix exit code on error May 1, 2018
getRemoteLanguages.js - introduce "reference-language-only" argument for sync command Oct 6, 2018
getRemoteNamespace.js fix strange error handling #16 Nov 7, 2018
index.js add missing exports May 1, 2018
lngs.json #19 try to make sync a bit safer, by checking first if folder to rm i… Dec 10, 2018
migrate.js fix exit code on error May 1, 2018
package.json update deps Dec 11, 2018
publishVersion.js fix exit code on error May 1, 2018
removeUndefinedFromArrays.js prepare for new major release Sep 20, 2018
sync.js #19 try to make sync a bit safer, by checking first if folder to rm i… Dec 10, 2018
unflatten.js prepare for new major release Sep 20, 2018

README.md

npm

Getting started with the locize-cli

Step 0: Install the cli (preferred globally)

npm install -g locize-cli

Adding/Updating new keys

Step 1: execute

Add your api-key and your project-id and let's go...

locize add --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --language en namespace1 myNewKey "My new value"

Remove keys

Step 1: execute

Add your api-key and your project-id and let's go...

locize remove --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --language en namespace1 myNewKey

or

locize remove common title

Get keys

Step 1: execute

Add your project-id and let's go...

locize get --project-id my-project-id-93e1-442a-ab35-24331fa294ba --language en namespace1 myNewKey

or

locize get common title

Download current published files

Step 1: execute

Add your project-id and let's go...

locize download --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver latest --language en --namespace namespace1 --path ./backup

or

locize download

or add a format like (json, flat, xliff2, xliff12, android, yaml, yaml-rails, csv, xlsx, po, strings, resx, fluent, tmx, laravel)

locize download --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver latest --language en --namespace namespace1 --path ./backup --format android

Synchronize locize with your repository (or any other local directory)

Step 1: Go near to your translation files

cd my-awesome-project/locales

Make sure you have this type of tree structure: Each language should be a directory and each namespace should be a file

locales
├── en
│   ├── namespace1.extension
│   ├── namespace2.extension
│   ├── ...
├── de
│   ├── ...

the cli by will use the directory name as language and the filename (without extension as namespace name).

Step 3: execute

Add your api-key and your project-id and let's go...

locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba

or add a format like (json, flat, xliff2, xliff12, android, yaml, yaml-rails, csv, xlsx, po, strings, resx, fluent, tmx, laravel)

locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --format android

‼️ By default: The reference language in your local repository is the master ‼️

  • if you have new keys in your local namespace it will add the missing one to locize
  • if you have new namespaces in your local language directory it will add the missing one to locize
  • if you have less keys (you have deleted some keys) in your local namespace it will remove them in locize too
  • all non reference languages will always be just locally replaced by what is published on locize
  • if you change the values of existing keys in the reference language, it will not change them in locize (to change the existing values you have to change it directly in locize)
  • if you want to take into account all languages instead of the reference language only while comparing the namespace content between local and remote, you can use the command argument --reference-language-only false
  • if you want to take into account the modification time while comparing the namespace content between local and remote, you can use the command argument --compare-modification-time true

Step 4: verify

Navigate to your locize project and check the results => www.locize.io

Copy version

Step 1: execute

Add your api-key (of target version) and your project-id and let's go...

# this will copy version latest to production
locize copy-version latest --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver production

Publish version

Step 1: execute

Add your api-key and your project-id and let's go...

locize publish-version --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver production

Delete namespace

Step 1: execute

Add your api-key and your project-id and let's go...

locize delete-namespace common --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver latest

Migration of existing i18next files

We suggest to use the sync command instead of the migrate command. The migrate command is older and only works with json files.

Step 1: Go near to your translation files

At the moment only i18next translation files (json) are supported

cd my-awesome-project/locales

Step 2: Decide if you want to migrate all languages or only one

If you have a directory structure like this:

locales
├── en
│   ├── namespace1
│   ├── namespace2
│   ├── ...
├── de
│   ├── ...

the cli by default will try to use the directory name as language.

If you have a directory structure like this:

locales
├── namespace1
├── namespace2
├── ...

you can use the --language option to define the language.

Step 3: execute

Add your api-key and your project-id and let's go...

locize migrate --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --path ./en --language en

Passing the argument --replace will empty the optionally existing namespace before saving the new translations. (default: false)

Step 4: verify

Navigate to your locize project and check the results => www.locize.io

Other information

You can define a config file in your home directory (or wherever you want (by specifying it in the command)) that contains defaults for your commands. i.e.

cat /Users/user/.locize

apiKey = my-api-key-d9de-4f55-9855-a9ef0ed44672
projectId = my-project-id-93e1-442a-ab35-24331fa294ba
language = en
version = latest

like this you can just work like this:

locize migrate

or

locize add common title "the title of my cool app"