targams
v0.0.7
Published
Package npm for manage language and get translation
Downloads
150
Readme
Targams
Manage your language files and get translation easily
Get started
npm install -D targams
Add a new script on your package.json
{
"scripts": {
"targams": "targams-scripts"
}
}
Add a targams-config.json file on your root directory
{
"googleCredentialsFile": "<Path to your google credentials file : ./google_credentials.json>",
"srcDirectory": "<Your-src-directory>",
"refLanguage": "<Your-ref-language>"
}
The google Credentials File is your google api service account keys : (Do not push it on you git repo)
{
"type": "<type>>",
"project_id": "<project_id>",
"private_key_id": "<private_key_id>",
"private_key": "<private_key>",
"client_email": "<client_email>",
"client_id": "<client_id>",
"auth_uri": "<auth_uri>",
"token_uri": "<token_uri>",
"auth_provider_x509_cert_url": "<auth_provider_x509_cert_url>",
"client_x509_cert_url": "<client_x509_cert_url>",
"universe_domain": "<universe_domain>"
}
You can add exclude files on your source folder by setting an exclude param with array of files names:
{
"googleCredentialsFile": "<Path to your google credentials file>",
"srcDirectory": "<Your-src-directory>",
"refLanguage": "<Your-ref-language>",
"exclude": ["file_to_exclude.json", "file_to_exclude_2.json"]
}
On your source directory, create json files with your reference file and other target files. Files must be named with [isoCode].json
//./locales
| FilesName | IsoCode | | --------- | ------- | | en-GB.json (ref file) | en-GB | | fr-FR.json | fr-FR | | de-DE.json | de-DE | | ... | ... |
Run and get the magic:
npm run targams
Target files are modified with missing keys compare to the ref file. N.B.: if a value contains a parameter like '{params}' this params will be not translate.