Not only can you use any language/alphabet you want with content/template files and page names for urls, there are two command-line based translators worth checking out if you want to translate text when building websites:
- Translate Shell (formerly Google Translate CLI) - a command-line translator powered by Google Translate (default), Bing Translator, Yandex.Translate, and Apertium. It gives you easy access to all of these translation engines in your terminal;
- DeepL Translator CLI - a command-line tool delivering text translation capabilities to your console and is powered by DeepL.
Note: Translate Shell needs the internet to run, if you are building your website and Translate Shell is called without internet access your build might stall. It is also unlikely to scale well to websites with 10k+ pages, possibly even 1k+.
The simplest way to use Translate Shell with Nift is:
@systemoutput("trans -brief 'text'")
If you want to translate text in a file use
@systemoutput("trans -brief file://file-path")@dep("file-path")
To specify which language to translate to add
@systemoutput("trans -brief eo: 'vorto'") @systemoutput("trans -brief :zh-CN 'hello'") @systemoutput("trans -brief en: :zh-CN 'hello'")
To list the available translation engines enter
@systemoutput("trans -e yandex -brief :en '你好'")
DeepL Translator CLI
You can use
$ yarn global add deepl-translator-cli
Along with below, there are examples to help you get started here.
The simplest way to use DeepL Translator CLI with Nift is:
@systemoutput("deepl translate -t 'country-code' 'text'")
language-codeis the code for the language you want to translate in to (the available codes are in the table below); and textis the text you want translated.
If you want to specify the language to translate from use the
@systemoutput("deepl translate -s 'EN' -t 'DE' 'How do you do?'")
You can pipe text from standard input, for example:
@systemoutput("echo 'text' | deepl translate -t 'language-code'")
If you want to translate a file, you can do so as follows:
@systemoutput("cat file-path | deepl translate -t 'language-code'")@dep("file-path")
The available languages and codes are: