tr-create
This project is focused mainly on angularjs projects using angular-translate.
Instalation
$ npm install -g tr-create
The Idea
Sometimes we are focused on the implementation and not on the copy text. We don't want our HTML/CSS/JS work to be bothered with the creation of the translate files for different languages. So we leave "Lorem ipsum" text or in my case "__text to be translated later__".
After the work is done, we run that script and it:
- creates JSON files for translations (
en.json
ores.json
) - if your JSON exists, we will merge the new content with the old one and will replace the existing file with the fresh content. - creates HTML file with
{{ 'global.someText' | translate }}
placeholder instead of__some text__
Usage
$ tr-create -s untranslated.html -t translated.html -l langs/en.json
Example:
untranslated.html
content:
Example__Please translate me____I need a translation____Please somebody to translate this text__
execute:
tr-create -s untranslated.html
By default it will create:
en.json
:
untranslated_tr.html
:
Example{{'global.pleaseTranslateMe' | translate }}{{'global.iNeedATranslation' | translate }}{{'global.pleaseSomebodyToTranslateThisText' | translate }}
Options
exmpaletr-create -s [html_source_file] -l [language_json_file] -n [name_space] -s, --sourceHTML file containig __text to translate__ dummy text -r, --replaceReplace the existing HTML with translations content -n, --name-spaceName space to be used in HTML translations: {{ 'nameSpace.textToBeTranslated' | translate }} -l, --langComma separated JSON file name
MIT License
Contribute
If you have an idea or special needs that this tool doesn't cover don't hesitate to fork and add the needed feature. There is only one requirement - use ES6 and babel.
Changelog
v1.0.0
- Changed
-ol
option to--ol
- Added
-r
,--replace
option - if set the existing HTML file provided by-s
will be overwritten with the translations content - Multiple JSON files - comma separated: --lang en.json,es.json - or en,es (JSON extension will be added automatically if omitted)
- Unit tests