0.1.7 • Published 11 months ago
@plastichub/osr-i18n v0.1.7
i18n related library and CLI for OSR content
Currently translates Markdown directories using DeepL API.
Installation
- Install from NPM
npm i -g @plastichub/osr-i18n
- Define an environment variable on your system
OSR-CONFIG
which holds the path to a json file, eg:C:\Users\nobody-likeyou\.osr\config.json
with the following content (see ./docs/config.json example):
{
"deepl": {
"comment": "Please get a key on deepl.com ! ",
"auth_key": "34dbf59f-adeb-1959-d906-502e0ec6afb7",
"free_api": false
}
}
You can verify the config by osr-i18n info
Commands
info
Brief: outputs configuration and supported language keys
osr-i18n info
translate
Simple
osr-i18n translate --text="Na Du Schnecke" --sourceLang="DE" --targetLang="EN"
# or pipe into a file
osr-i18n translate --text="Na Du Schnecke" --sourceLang="DE" --targetLang="EN" > translations.json
Example output
Translating Na Du Schnecke! Du schaust so traurig aus! to
[
{
detected_source_language: 'DE',
text: 'Well you snail! You look so sad!'
}
]
Using Glob patters
1. Translate directory of files, simple
osr-i18n translate --src="./**/*.md" --sourceLang="DE" --targetLang="EN"
Remarks:
this will translate all files in
./**/*.md
, to./**/somefile.EN.md
when no
--dst
argument is specified, the output path is composed by adding the target language in the filename, eg:my-info.md
becomesmy-info_de.md
please run
osr-i18n translate --help
for supported file types
2. Translate directory of files, advanced
osr-i18n translate --src="./**/*.md" --dst='${SRC_DIR}/${SRC_NAME}.${DST_LANG}.+(md)' --sourceLang="DE" --targetLang="EN"
2. Translate directory of files, advanced
osr-i18n translate --src="./**/*.md" --cwd='source directory' --dst='target directory' --sourceLang="DE" --targetLang="EN"
Remarks:
- sourceLang is not needed to be set explicit, DeepL will recognize
- please run
osr-i18n translate --help
for supported file types - See more examples in ./tests/
- Please see more integration examples in ./docs/Integration.md
Path variables
- DST_LANG: Destination language
- SRC_LANG: Destination language
- CWD: Current working directory, as specified on the CLI
- SRC_REL: Relative directory, from main source path to currently translated file
Todos
- Support Glossaries
- Plugins: emoji fuckery removal, ignore filter/patterns
- Imprint meta (osr-version, config)
- XLS
- Google Sheets, direct
- Google Speech API to produce audio files (see boilerplate in ./src/speech/google.ts)
- translate keys in
unitconv