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.
Translate Shell
You can find installation instructions for Translate Shell here, the recommended way being direct download, though there is information about package managers here.
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+.
Along with below, there are examples to help get you started here and documentation on usage here.
The simplest way to use Translate Shell with Nift is:
@system("trans -brief 'text'")
where
If you want to translate text in a file use
@system("trans -brief file://file-path")@dep("file-path")
where
To specify which language to translate to add
@system("trans -brief eo: 'vorto'") @system("trans -brief :zh-CN 'hello'") @system("trans -brief en: :zh-CN 'hello'")
To list the available translation engines enter
@system("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:
@system("deepl translate -t 'country-code' 'text'")
where:
language-code is the code for the language you want to translate in to (the available codes are in the table below); andtext is the text you want translated.
If you want to specify the language to translate from use the
@system("deepl translate -s 'EN' -t 'DE' 'How do you do?'")
You can pipe text from standard input, for example:
@system("echo 'text' | deepl translate -t 'language-code'")
If you want to translate a file, you can do so as follows:
@system("cat file-path | deepl translate -t 'language-code'")@dep("file-path")
where
The available languages and codes are:
language | code |
---|---|
English | EN |
German | DE |
French | FR |
Spanish | ES |
Italian | IT |
Dutch | NL |
Polish | PL |
language | code |