pax_global_header 0000666 0000000 0000000 00000000064 13516335241 0014515 g ustar 00root root 0000000 0000000 52 comment=b4132bd505a2a84bb1f670a0125565f6d28e4355
translate-shell-0.9.6.11/ 0000775 0000000 0000000 00000000000 13516335241 0015053 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/.circleci/ 0000775 0000000 0000000 00000000000 13516335241 0016706 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/.circleci/config.yml 0000664 0000000 0000000 00000000714 13516335241 0020700 0 ustar 00root root 0000000 0000000 version: 2
jobs:
build:
environment:
LC_ALL: C.UTF-8
LANG: C.UTF-8
docker:
- image: debian:stretch
steps:
- checkout
- run:
name: Install Dependencies
command: |
apt-get update
apt-get -y install locales make
apt-get -y install util-linux bsdmainutils gawk curl rlwrap emacs
- run:
name: Sanity Check
command: |
make test
translate-shell-0.9.6.11/.gitignore 0000664 0000000 0000000 00000000065 13516335241 0017044 0 ustar 00root root 0000000 0000000 /_*
/build
/gh-pages
/registry
/wiki
*.emacs*
*.html
translate-shell-0.9.6.11/.travis.yml 0000664 0000000 0000000 00000001420 13516335241 0017161 0 ustar 00root root 0000000 0000000 os:
- linux
- osx
before_install: |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:schot/gawk -y; fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -q; fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gawk; fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install rlwrap; fi
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install emacs; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gawk; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install rlwrap; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install emacs; fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bash; fi
script: make check
translate-shell-0.9.6.11/CONTRIBUTING.md 0000664 0000000 0000000 00000001631 13516335241 0017305 0 ustar 00root root 0000000 0000000 ## How to Report an Issue
1. For bugs and suggestions, please always **[report your issue on GitHub](https://github.com/soimort/translate-shell/issues)**.
2. For bugs, make sure you can reproduce on **the latest stable version** before reporting.
3. In your bug report, please include details such as:
* The exact command you entered, expected output and actual output
* The output of `trans -V` on your system
## How to Send a Pull Request
### Waiving Copyrights
This is a public domain software, which means the author(s) do not retain any copyright interest in this repository. You ("the contributor") will be asked to **[sign the Contributor License Agreement](https://www.clahub.com/agreements/soimort/translate-shell)** before your contribution can be considered.
### Following the Coding Style
Please review the **[AWK style guide](https://github.com/soimort/translate-shell/wiki/AWK-Style-Guide)**.
translate-shell-0.9.6.11/LICENSE 0000664 0000000 0000000 00000002273 13516335241 0016064 0 ustar 00root root 0000000 0000000 This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
translate-shell-0.9.6.11/Makefile 0000664 0000000 0000000 00000002141 13516335241 0016511 0 ustar 00root root 0000000 0000000 NAME = "translate-shell"
COMMAND = trans
BUILDDIR ?= build
MANDIR = man
TARGET ?= bash
PREFIX ?= /usr/local
.PHONY: default clean build release grip test check install uninstall
default: build
clean:
@gawk -f build.awk clean
build:
@gawk -f build.awk build -target=$(TARGET)
release:
@gawk -f build.awk build -target=$(TARGET) -type=release
grip:
@gawk -f build.awk readme && grip
test: build
@gawk -f test.awk
check: test
$(BUILDDIR)/$(COMMAND) -V
[ "`$(BUILDDIR)/$(COMMAND) -no-init -D -b 忍者`" = 'Ninja' ] &&\
[ "`$(BUILDDIR)/$(COMMAND) -no-init -D -b -e bing 忍者`" = 'Ninja' ] &&\
[ "`$(BUILDDIR)/$(COMMAND) -no-init -D -b -e yandex Ninja`" = 'Ninja' ]
install: build
@mkdir -p $(DESTDIR)$(PREFIX)/bin &&\
install $(BUILDDIR)/$(COMMAND) $(DESTDIR)$(PREFIX)/bin/$(COMMAND) &&\
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 &&\
install $(MANDIR)/$(COMMAND).1 $(DESTDIR)$(PREFIX)/share/man/man1/$(COMMAND).1 &&\
echo "[OK] $(NAME) installed."
uninstall:
@rm $(DESTDIR)$(PREFIX)/bin/$(COMMAND) $(DESTDIR)$(PREFIX)/share/man/man1/$(COMMAND).1 &&\
echo "[OK] $(NAME) uninstalled."
translate-shell-0.9.6.11/README.md 0000664 0000000 0000000 00000075141 13516335241 0016342 0 ustar 00root root 0000000 0000000 # Translate Shell
[](https://www.soimort.org/translate-shell)
[](https://circleci.com/gh/soimort/translate-shell)
[](https://github.com/soimort/translate-shell/releases)
[](https://www.soimort.org/translate-shell/trans)
[](https://gitter.im/soimort/translate-shell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**[Translate Shell](https://www.soimort.org/translate-shell)** (formerly _Google Translate CLI_) is a command-line translator powered by **[Google Translate](https://translate.google.com/)** (default), **[Bing Translator](https://www.bing.com/translator)**, **[Yandex.Translate](https://translate.yandex.com/)**, and **[Apertium](https://www.apertium.org/)**. It gives you easy access to one of these translation engines in your terminal:
```
$ trans 'Saluton, Mondo!'
Saluton, Mondo!
Hello, World!
Translations of Saluton, Mondo!
[ Esperanto -> English ]
Saluton ,
Hello,
Mondo !
World!
```
By default, translations with detailed explanations are shown. You can also translate the text briefly: (only the most relevant translation will be shown)
```
$ trans -brief 'Saluton, Mondo!'
Hello, World!
```
**Translate Shell** can also be used like an interactive shell; input the text to be translated line by line:
```
$ trans -shell -brief
> Rien ne réussit comme le succès.
Nothing succeeds like success.
> Was mich nicht umbringt, macht mich stärker.
What does not kill me makes me stronger.
> Юмор есть остроумие глубокого чувства.
Humor has a deep sense of wit.
> 學而不思則罔,思而不學則殆。
Learning without thought is labor lost, thought without learning is perilous.
> 幸福になるためには、人から愛されるのが一番の近道。
In order to be happy, the best way is to be loved by people.
```
## Prerequisites
### System Requirements
**Translate Shell** is known to work on many POSIX-compliant systems, including but not limited to:
* GNU/Linux
* macOS
* *BSD
* Android (through Termux)
* Windows (through WSL, Cygwin, or MSYS2)
### Dependencies
* **[GNU Awk](https://www.gnu.org/software/gawk/)** (**gawk**) **4.0 or later**
* This program relies heavily on GNU extensions of the [AWK language](http://en.wikipedia.org/wiki/AWK), which are non-portable for other AWK implementations (e.g. nawk).
* How to get gawk:
* gawk comes with all GNU/Linux distributions.
* On FreeBSD, gawk is available in the ports.
* On macOS, gawk is available in MacPorts and Homebrew.
* **[GNU Bash](http://www.gnu.org/software/bash/)** or **[Zsh](http://www.zsh.org/)**
* You may use Translate Shell from any Unix shell of your choice (bash, zsh, ksh, tcsh, fish, etc.); however, the wrapper script requires either **bash** or **zsh** installed.
### Recommended Dependencies
These dependencies are optional, but strongly recommended for full functionality:
* **[curl](http://curl.haxx.se/)** with **OpenSSL** support
* **[GNU FriBidi](http://fribidi.org/)**: _an implementation of the Unicode Bidirectional Algorithm (bidi)_
* required for displaying text in Right-to-Left scripts (e.g. Arabic, Hebrew)
* **[mplayer](http://www.mplayerhq.hu/)**, **[mpv](http://mpv.io/)**, **[mpg123](http://mpg123.org/)**, or **[eSpeak](http://espeak.sourceforge.net/)**
* required for the Text-to-Speech functionality
* **[less](http://www.greenwoodsoftware.com/less/)**, **[more](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html)** or **[most](http://www.jedsoft.org/most/)**
* required for terminal paging
* **[rlwrap](http://utopia.knoware.nl/~hlub/uck/rlwrap/#rlwrap)**: *a GNU readline wrapper*
* required for readline-style editing and history in the interactive shell
* **[aspell](http://aspell.net/)** or **[hunspell](http://hunspell.github.io/)**
* required for spell checking
### Environment and Fonts
It is a must to have corresponding fonts for the language(s) / script(s) you wish to display in your terminal. See **[wiki: Writing Systems and Fonts](https://github.com/soimort/translate-shell/wiki/Writing-Systems-and-Fonts#unicode-fonts)** for more details on scripts and recommended Unicode fonts.
## Try It Out!
Start an interactive shell and translate anything you input into your native language: (in **bash** or **zsh**)
$ gawk -f <(curl -Ls git.io/translate) -- -shell
(in **fish**)
$ gawk -f (curl -Ls git.io/translate | psub) -- -shell
## Installation
### Option #1. Direct Download
Download [the self-contained executable](http://git.io/trans) and place it into your path. It's everything you need.
$ wget git.io/trans
$ chmod +x ./trans
There is a [GPG signature](https://www.soimort.org/translate-shell/trans.sig).
### Option #2. From A Package Manager
#### Using [Antigen](https://github.com/zsh-users/antigen) (Recommended for Zsh users)
Add the following line to your `.zshrc`:
antigen bundle soimort/translate-shell
#### Using your favorite package manager
See **[wiki: Distros](https://github.com/soimort/translate-shell/wiki/Distros)** on how to install from a specific package manager on your distro.
### Option #3. From Git (Recommended for seasoned hackers)
$ git clone https://github.com/soimort/translate-shell
$ cd translate-shell/
$ make
$ [sudo] make install
In case you have only zsh but not bash in your system, build with:
$ make TARGET=zsh
The default `PREFIX` of installation is `/usr/local`. To install the program to somewhere else (e.g. `/usr`, `~/.local`), use:
$ [sudo] make PREFIX=/usr install
## Getting Started by Examples
### Translate a Word
#### From any language to your language
Google Translate can identify the language of the source text automatically, and Translate Shell by default translates the source text into the language of your `locale`.
$ trans vorto
#### From any language to one or more specific languages
Translate a word into French:
$ trans :fr word
Translate a word into Chinese and Japanese: (use a plus sign "`+`" as the delimiter)
$ trans :zh+ja word
Alternatively, equals sign ("`=`") can be used in place of the colon ("`:`"). Note that in some shells (e.g. zsh), equals signs may be interpreted differently, therefore the argument specifying languages needs to be protected:
$ trans {=zh+ja} word
$ trans '=zh+ja' word
You can also use the `-target` (`-t`) option to specify the target language(s):
$ trans -t zh+ja word
With the `-t` option, the name of the language may also be used instead of the language code:
$ trans -t japanese word
$ trans -t 日本語 word
#### From a specific language
Google Translate may wrongly identify the source text as some other language than you expected:
$ trans 手紙
In that case, you need to specify its language explicitly:
$ trans ja: 手紙
$ trans zh: 手紙
You can also use the `-source` (`-s`) option to specify the source language:
$ trans -s ja 手紙
### Translate Multiple Words or a Phrase
Translate each word alone:
$ trans en:zh word processor
Put words into one argument, and translate them as a whole:
$ trans en:zh "word processor"
### Translate a Sentence
Translating a sentence is much the same like translating a phrase; you can just quote the sentence into one argument:
$ trans :zh "To-morrow, and to-morrow, and to-morrow,"
$ trans :zh 'To-morrow, and to-morrow, and to-morrow,'
It is also possible to translate multi-line sentences:
$ trans :zh "Creeps in this petty pace from day to day,
> To the last syllable of recorded time;
> And all our yesterdays have lighted fools
> The way to dusty death."
To avoid punctuation marks (e.g. "`!`") or other special characters being interpreted by the shell, use *single quotes*:
$ trans :zh 'Out, out, brief candle!'
There are some cases though, you may still want to use *double quotes*: (e.g. the sentence contains a single quotation mark "`'`")
$ trans :zh "Life's but a walking shadow, a poor player"
Alternatively, use the `-join-sentence` (`-j`) option to treat all arguments as one sentence so that quotes can be omitted:
$ trans -j :zh Life\'s but a walking shadow, a poor player
### Brief Mode
By default, Translate Shell displays translations in a verbose manner. If you prefer to see only the most relevant translation, there is a brief mode available using the `-brief` (`-b`) option:
$ trans -b :fr "Saluton, Mondo"
In brief mode, phonetic notation (if any) is not shown by default. To enable this, put an at sign "`@`" in front of the language code:
$ trans -b :@ja "Saluton, Mondo"
### Dictionary Mode
Google Translate can be used as a dictionary. When translating a word and the target language is the same as the source language, the dictionary entry of the word is shown:
$ trans :en word
To enable dictionary mode no matter whether the source language and the target language are identical, use the `-dictionary` (`-d`) option.
$ trans -d fr: mot
**Note:** Not every language supported by Google Translate has provided dictionary data. See **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)** to find out which language(s) has dictionary support.
### Language Identification
Use the `-identify` (`-id`) option to identify the language of the text:
$ trans -id 言葉
### Text-to-Speech
Use the `-play` (`-p`) option to listen to the translation:
$ trans -b -p :ja "Saluton, Mondo"
Use the `-speak` (`-sp`) option to listen to the original text:
$ trans -sp "你好,世界"
### Terminal Paging
Sometimes the content of translation can be too much for display in one screen. Use the `-view` (`-v`) option to view the translation in a terminal pager such as `less` or `more`:
$ trans -d -v word
### Right-to-Left (RTL) Languages
[Right-to-Left (RTL) languages](http://en.wikipedia.org/wiki/Right-to-left) are well supported via [GNU FriBidi](http://fribidi.org/).
The program will automatically adjust the screen width for padding when displaying right-to-left languages. Alternatively, you may use the `-width` (`-w`) option to specify the screen width:
$ trans -b -w 40 :he "Saluton, Mondo"
See **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)** to find out which language(s) uses a Right-to-Left writing system.
### Pipeline, Input and Output
If no source text is given in command-line arguments, the program will read from standard input, or from the file specified by the `-input` (`-i`) option:
$ echo "Saluton, Mondo" | trans -b :fr
$ trans -b -i input.txt :fr
Translations are written to standard output, or to the file specified by the `-output` (`-o`) option:
$ echo "Saluton, Mondo" | trans -b -o output.txt :fr
### Translate a File
Instead of using the `-input` option, a [file URI scheme](http://en.wikipedia.org/wiki/File_URI_scheme) (`file://` followed by the file name) can be used as a command-line argument:
$ trans :fr file://input.txt
**Note**: Brief mode is used when translating from file URI schemes.
### Translate a Web Page
To translate a web page, an http(s) URI scheme can be used as an argument:
$ trans :fr http://www.w3.org/
A browser session will open for viewing the translation (via Google Translate's web interface). To specify your web browser of choice, use the `-browser` option:
$ trans -browser firefox :fr http://www.w3.org/
### Language Details
Use the `-list` (`-L`) option to view details of one or more languages:
$ trans -L fr
$ trans -L de+en
Some basic information of the language will be displayed: its English name and endonym (language name in the language itself), language family, writing system, canonical Google Translate code and ISO 639-3 code.
### Interactive Translate Shell (REPL)
Start an interactive shell using the `-shell` (or `-interactive`, `-I`) option:
$ trans -shell
You may specify the source language and the target language(s) before starting an interactive shell:
$ trans -shell en:fr
You may also change these settings during an interactive session. See **[wiki: REPL](https://github.com/soimort/translate-shell/wiki/REPL)** for more advanced usage of the interactive Translate Shell.
## Usage
For more details on command-line options, see the man page **[trans(1)](https://www.soimort.org/translate-shell/trans.1.html)** or use `trans -M` in a terminal.
```
Usage: trans [OPTIONS] [SOURCES]:[TARGETS] [TEXT]...
Information options:
-V, -version
Print version and exit.
-H, -help
Print help message and exit.
-M, -man
Show man page and exit.
-T, -reference
Print reference table of languages and exit.
-R, -reference-english
Print reference table of languages (in English names) and exit.
-L CODES, -list CODES
Print details of languages and exit.
-S, -list-engines
List available translation engines and exit.
-U, -upgrade
Check for upgrade of this program.
Translator options:
-e ENGINE, -engine ENGINE
Specify the translation engine to use.
Display options:
-verbose
Verbose mode. (default)
-b, -brief
Brief mode.
-d, -dictionary
Dictionary mode.
-identify
Language identification.
-show-original Y/n
Show original text or not.
-show-original-phonetics Y/n
Show phonetic notation of original text or not.
-show-translation Y/n
Show translation or not.
-show-translation-phonetics Y/n
Show phonetic notation of translation or not.
-show-prompt-message Y/n
Show prompt message or not.
-show-languages Y/n
Show source and target languages or not.
-show-original-dictionary y/N
Show dictionary entry of original text or not.
-show-dictionary Y/n
Show dictionary entry of translation or not.
-show-alternatives Y/n
Show alternative translations or not.
-w NUM, -width NUM
Specify the screen width for padding.
-indent NUM
Specify the size of indent (number of spaces).
-theme FILENAME
Specify the theme to use.
-no-theme
Do not use any other theme than default.
-no-ansi
Do not use ANSI escape codes.
-no-autocorrect
Do not autocorrect. (if defaulted by the translation engine)
-no-bidi
Do not convert bidirectional texts.
-bidi
Always convert bidirectional texts.
-no-warn
Do not write warning messages to stderr.
-dump
Print raw API response instead.
Audio options:
-p, -play
Listen to the translation.
-speak
Listen to the original text.
-n VOICE, -narrator VOICE
Specify the narrator, and listen to the translation.
-player PROGRAM
Specify the audio player to use, and listen to the translation.
-no-play
Do not listen to the translation.
-no-translate
Do not translate anything when using -speak.
-download-audio
Download the audio to the current directory.
-download-audio-as FILENAME
Download the audio to the specified file.
Terminal paging and browsing options:
-v, -view
View the translation in a terminal pager.
-pager PROGRAM
Specify the terminal pager to use, and view the translation.
-no-view, -no-pager
Do not view the translation in a terminal pager.
-browser PROGRAM
Specify the web browser to use.
-no-browser
Do not open the web browser.
Networking options:
-x HOST:PORT, -proxy HOST:PORT
Use HTTP proxy on given port.
-u STRING, -user-agent STRING
Specify the User-Agent to identify as.
-4, -ipv4, -inet4-only
Connect only to IPv4 addresses.
-6, -ipv6, -inet6-only
Connect only to IPv6 addresses.
Interactive shell options:
-I, -interactive, -shell
Start an interactive shell.
-E, -emacs
Start the GNU Emacs front-end for an interactive shell.
-no-rlwrap
Do not invoke rlwrap when starting an interactive shell.
I/O options:
-i FILENAME, -input FILENAME
Specify the input file.
-o FILENAME, -output FILENAME
Specify the output file.
Language preference options:
-l CODE, -hl CODE, -lang CODE
Specify your home language.
-s CODES, -sl CODES, -source CODES, -from CODES
Specify the source language(s), joined by '+'.
-t CODES, -tl CODES, -target CODES, -to CODES
Specify the target language(s), joined by '+'.
Text preprocessing options:
-j, -join-sentence
Treat all arguments as one single sentence.
Other options:
-no-init
Do not load any initialization script.
See the man page trans(1) for more information.
```
## Code List
Use `trans -R` or `trans -T` to view the reference table in a terminal.
For more details on languages and corresponding codes, see **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)**.
| Language | Code | Language | Code | Language | Code |
| :------: | :--: | :------: | :--: | :------: | :--: |
| **[Afrikaans](http://en.wikipedia.org/wiki/Afrikaans_language)**
**Afrikaans** | **`af`** | **[Hebrew](http://en.wikipedia.org/wiki/Hebrew_language)**
**עִבְרִית** | **`he`** | **[Portuguese](http://en.wikipedia.org/wiki/Portuguese_language)**
**Português** | **`pt`** |
| **[Albanian](http://en.wikipedia.org/wiki/Albanian_language)**
**Shqip** | **`sq`** | **[Hill Mari](http://en.wikipedia.org/wiki/Hill_Mari)**
**Кырык мары** | **`mrj`** | **[Punjabi](http://en.wikipedia.org/wiki/Punjabi_language)**
**ਪੰਜਾਬੀ** | **`pa`** |
| **[Amharic](http://en.wikipedia.org/wiki/Amharic_language)**
**አማርኛ** | **`am`** | **[Hindi](http://en.wikipedia.org/wiki/Hindi_language)**
**हिन्दी** | **`hi`** | **[Querétaro Otomi](http://en.wikipedia.org/wiki/Querétaro_Otomi)**
**Hñąñho** | **`otq`** |
| **[Arabic](http://en.wikipedia.org/wiki/Arabic_language)**
**العربية** | **`ar`** | **[Hmong](http://en.wikipedia.org/wiki/Hmong_language)**
**Hmoob** | **`hmn`** | **[Romanian](http://en.wikipedia.org/wiki/Romanian_language)**
**Română** | **`ro`** |
| **[Armenian](http://en.wikipedia.org/wiki/Armenian_language)**
**Հայերեն** | **`hy`** | **[Hmong Daw](http://en.wikipedia.org/wiki/Hmong_Daw)**
**Hmoob Daw** | **`mww`** | **[Russian](http://en.wikipedia.org/wiki/Russian_language)**
**Русский** | **`ru`** |
| **[Azerbaijani](http://en.wikipedia.org/wiki/Azerbaijani_language)**
**Azərbaycanca** | **`az`** | **[Hungarian](http://en.wikipedia.org/wiki/Hungarian_language)**
**Magyar** | **`hu`** | **[Samoan](http://en.wikipedia.org/wiki/Samoan_language)**
**Gagana Sāmoa** | **`sm`** |
| **[Bashkir](http://en.wikipedia.org/wiki/Bashkir_language)**
**башҡорт теле** | **`ba`** | **[Icelandic](http://en.wikipedia.org/wiki/Icelandic_language)**
**Íslenska** | **`is`** | **[Scots Gaelic](http://en.wikipedia.org/wiki/Scots_Gaelic)**
**Gàidhlig** | **`gd`** |
| **[Basque](http://en.wikipedia.org/wiki/Basque_language)**
**Euskara** | **`eu`** | **[Igbo](http://en.wikipedia.org/wiki/Igbo_language)**
**Igbo** | **`ig`** | **[Serbian (Cyrillic)](http://en.wikipedia.org/wiki/Serbian_(Cyrillic))**
**српски** | **`sr-Cyrl`** |
| **[Belarusian](http://en.wikipedia.org/wiki/Belarusian_language)**
**беларуская** | **`be`** | **[Indonesian](http://en.wikipedia.org/wiki/Indonesian_language)**
**Bahasa Indonesia** | **`id`** | **[Serbian (Latin)](http://en.wikipedia.org/wiki/Serbian_(Latin))**
**srpski** | **`sr-Latn`** |
| **[Bengali](http://en.wikipedia.org/wiki/Bengali_language)**
**বাংলা** | **`bn`** | **[Irish](http://en.wikipedia.org/wiki/Irish_language)**
**Gaeilge** | **`ga`** | **[Sesotho](http://en.wikipedia.org/wiki/Sesotho_language)**
**Sesotho** | **`st`** |
| **[Bosnian](http://en.wikipedia.org/wiki/Bosnian_language)**
**Bosanski** | **`bs`** | **[Italian](http://en.wikipedia.org/wiki/Italian_language)**
**Italiano** | **`it`** | **[Shona](http://en.wikipedia.org/wiki/Shona_language)**
**chiShona** | **`sn`** |
| **[Bulgarian](http://en.wikipedia.org/wiki/Bulgarian_language)**
**български** | **`bg`** | **[Japanese](http://en.wikipedia.org/wiki/Japanese_language)**
**日本語** | **`ja`** | **[Sindhi](http://en.wikipedia.org/wiki/Sindhi_language)**
**سنڌي** | **`sd`** |
| **[Cantonese](http://en.wikipedia.org/wiki/Cantonese_language)**
**粵語** | **`yue`** | **[Javanese](http://en.wikipedia.org/wiki/Javanese_language)**
**Basa Jawa** | **`jv`** | **[Sinhala](http://en.wikipedia.org/wiki/Sinhala_language)**
**සිංහල** | **`si`** |
| **[Catalan](http://en.wikipedia.org/wiki/Catalan_language)**
**Català** | **`ca`** | **[Kannada](http://en.wikipedia.org/wiki/Kannada_language)**
**ಕನ್ನಡ** | **`kn`** | **[Slovak](http://en.wikipedia.org/wiki/Slovak_language)**
**Slovenčina** | **`sk`** |
| **[Cebuano](http://en.wikipedia.org/wiki/Cebuano_language)**
**Cebuano** | **`ceb`** | **[Kazakh](http://en.wikipedia.org/wiki/Kazakh_language)**
**Қазақ тілі** | **`kk`** | **[Slovenian](http://en.wikipedia.org/wiki/Slovenian_language)**
**Slovenščina** | **`sl`** |
| **[Chichewa](http://en.wikipedia.org/wiki/Chichewa_language)**
**Nyanja** | **`ny`** | **[Khmer](http://en.wikipedia.org/wiki/Khmer_language)**
**ភាសាខ្មែរ** | **`km`** | **[Somali](http://en.wikipedia.org/wiki/Somali_language)**
**Soomaali** | **`so`** |
| **[Chinese Simplified](http://en.wikipedia.org/wiki/Chinese_Simplified)**
**简体中文** | **`zh-CN`** | **[Klingon](http://en.wikipedia.org/wiki/Klingon_language)**
**tlhIngan Hol** | **`tlh`** | **[Spanish](http://en.wikipedia.org/wiki/Spanish_language)**
**Español** | **`es`** |
| **[Chinese Traditional](http://en.wikipedia.org/wiki/Chinese_Traditional)**
**正體中文** | **`zh-TW`** | **[Klingon (pIqaD)](http://en.wikipedia.org/wiki/Klingon_(pIqaD))**
** ** | **`tlh-Qaak`** | **[Sundanese](http://en.wikipedia.org/wiki/Sundanese_language)**
**Basa Sunda** | **`su`** |
| **[Corsican](http://en.wikipedia.org/wiki/Corsican_language)**
**Corsu** | **`co`** | **[Korean](http://en.wikipedia.org/wiki/Korean_language)**
**한국어** | **`ko`** | **[Swahili](http://en.wikipedia.org/wiki/Swahili_language)**
**Kiswahili** | **`sw`** |
| **[Croatian](http://en.wikipedia.org/wiki/Croatian_language)**
**Hrvatski** | **`hr`** | **[Kurdish](http://en.wikipedia.org/wiki/Kurdish_language)**
**Kurdî** | **`ku`** | **[Swedish](http://en.wikipedia.org/wiki/Swedish_language)**
**Svenska** | **`sv`** |
| **[Czech](http://en.wikipedia.org/wiki/Czech_language)**
**Čeština** | **`cs`** | **[Kyrgyz](http://en.wikipedia.org/wiki/Kyrgyz_language)**
**Кыргызча** | **`ky`** | **[Tahitian](http://en.wikipedia.org/wiki/Tahitian_language)**
**Reo Tahiti** | **`ty`** |
| **[Danish](http://en.wikipedia.org/wiki/Danish_language)**
**Dansk** | **`da`** | **[Lao](http://en.wikipedia.org/wiki/Lao_language)**
**ລາວ** | **`lo`** | **[Tajik](http://en.wikipedia.org/wiki/Tajik_language)**
**Тоҷикӣ** | **`tg`** |
| **[Dutch](http://en.wikipedia.org/wiki/Dutch_language)**
**Nederlands** | **`nl`** | **[Latin](http://en.wikipedia.org/wiki/Latin_language)**
**Latina** | **`la`** | **[Tamil](http://en.wikipedia.org/wiki/Tamil_language)**
**தமிழ்** | **`ta`** |
| **[Eastern Mari](http://en.wikipedia.org/wiki/Eastern_Mari)**
**Олык марий** | **`mhr`** | **[Latvian](http://en.wikipedia.org/wiki/Latvian_language)**
**Latviešu** | **`lv`** | **[Tatar](http://en.wikipedia.org/wiki/Tatar_language)**
**татарча** | **`tt`** |
| **[Emoji](http://en.wikipedia.org/wiki/Emoji_language)**
**Emoji** | **`emj`** | **[Lithuanian](http://en.wikipedia.org/wiki/Lithuanian_language)**
**Lietuvių** | **`lt`** | **[Telugu](http://en.wikipedia.org/wiki/Telugu_language)**
**తెలుగు** | **`te`** |
| **[English](http://en.wikipedia.org/wiki/English_language)**
**English** | **`en`** | **[Luxembourgish](http://en.wikipedia.org/wiki/Luxembourgish_language)**
**Lëtzebuergesch** | **`lb`** | **[Thai](http://en.wikipedia.org/wiki/Thai_language)**
**ไทย** | **`th`** |
| **[Esperanto](http://en.wikipedia.org/wiki/Esperanto_language)**
**Esperanto** | **`eo`** | **[Macedonian](http://en.wikipedia.org/wiki/Macedonian_language)**
**Македонски** | **`mk`** | **[Tongan](http://en.wikipedia.org/wiki/Tongan_language)**
**Lea faka-Tonga** | **`to`** |
| **[Estonian](http://en.wikipedia.org/wiki/Estonian_language)**
**Eesti** | **`et`** | **[Malagasy](http://en.wikipedia.org/wiki/Malagasy_language)**
**Malagasy** | **`mg`** | **[Turkish](http://en.wikipedia.org/wiki/Turkish_language)**
**Türkçe** | **`tr`** |
| **[Fijian](http://en.wikipedia.org/wiki/Fijian_language)**
**Vosa Vakaviti** | **`fj`** | **[Malay](http://en.wikipedia.org/wiki/Malay_language)**
**Bahasa Melayu** | **`ms`** | **[Udmurt](http://en.wikipedia.org/wiki/Udmurt_language)**
**удмурт** | **`udm`** |
| **[Filipino](http://en.wikipedia.org/wiki/Filipino_language)**
**Tagalog** | **`tl`** | **[Malayalam](http://en.wikipedia.org/wiki/Malayalam_language)**
**മലയാളം** | **`ml`** | **[Ukrainian](http://en.wikipedia.org/wiki/Ukrainian_language)**
**Українська** | **`uk`** |
| **[Finnish](http://en.wikipedia.org/wiki/Finnish_language)**
**Suomi** | **`fi`** | **[Maltese](http://en.wikipedia.org/wiki/Maltese_language)**
**Malti** | **`mt`** | **[Urdu](http://en.wikipedia.org/wiki/Urdu_language)**
**اُردُو** | **`ur`** |
| **[French](http://en.wikipedia.org/wiki/French_language)**
**Français** | **`fr`** | **[Maori](http://en.wikipedia.org/wiki/Maori_language)**
**Māori** | **`mi`** | **[Uzbek](http://en.wikipedia.org/wiki/Uzbek_language)**
**Oʻzbek tili** | **`uz`** |
| **[Frisian](http://en.wikipedia.org/wiki/Frisian_language)**
**Frysk** | **`fy`** | **[Marathi](http://en.wikipedia.org/wiki/Marathi_language)**
**मराठी** | **`mr`** | **[Vietnamese](http://en.wikipedia.org/wiki/Vietnamese_language)**
**Tiếng Việt** | **`vi`** |
| **[Galician](http://en.wikipedia.org/wiki/Galician_language)**
**Galego** | **`gl`** | **[Mongolian](http://en.wikipedia.org/wiki/Mongolian_language)**
**Монгол** | **`mn`** | **[Welsh](http://en.wikipedia.org/wiki/Welsh_language)**
**Cymraeg** | **`cy`** |
| **[Georgian](http://en.wikipedia.org/wiki/Georgian_language)**
**ქართული** | **`ka`** | **[Myanmar](http://en.wikipedia.org/wiki/Myanmar_language)**
**မြန်မာစာ** | **`my`** | **[Xhosa](http://en.wikipedia.org/wiki/Xhosa_language)**
**isiXhosa** | **`xh`** |
| **[German](http://en.wikipedia.org/wiki/German_language)**
**Deutsch** | **`de`** | **[Nepali](http://en.wikipedia.org/wiki/Nepali_language)**
**नेपाली** | **`ne`** | **[Yiddish](http://en.wikipedia.org/wiki/Yiddish_language)**
**ייִדיש** | **`yi`** |
| **[Greek](http://en.wikipedia.org/wiki/Greek_language)**
**Ελληνικά** | **`el`** | **[Norwegian](http://en.wikipedia.org/wiki/Norwegian_language)**
**Norsk** | **`no`** | **[Yoruba](http://en.wikipedia.org/wiki/Yoruba_language)**
**Yorùbá** | **`yo`** |
| **[Gujarati](http://en.wikipedia.org/wiki/Gujarati_language)**
**ગુજરાતી** | **`gu`** | **[Papiamento](http://en.wikipedia.org/wiki/Papiamento_language)**
**Papiamentu** | **`pap`** | **[Yucatec Maya](http://en.wikipedia.org/wiki/Yucatec_Maya)**
**Màaya T'àan** | **`yua`** |
| **[Haitian Creole](http://en.wikipedia.org/wiki/Haitian_Creole)**
**Kreyòl Ayisyen** | **`ht`** | **[Pashto](http://en.wikipedia.org/wiki/Pashto_language)**
**پښتو** | **`ps`** | **[Zulu](http://en.wikipedia.org/wiki/Zulu_language)**
**isiZulu** | **`zu`** |
| **[Hausa](http://en.wikipedia.org/wiki/Hausa_language)**
**Hausa** | **`ha`** | **[Persian](http://en.wikipedia.org/wiki/Persian_language)**
**فارسی** | **`fa`** |
| **[Hawaiian](http://en.wikipedia.org/wiki/Hawaiian_language)**
**ʻŌlelo Hawaiʻi** | **`haw`** | **[Polish](http://en.wikipedia.org/wiki/Polish_language)**
**Polski** | **`pl`** |
## Wiki
Lists of all languages, writing systems and fonts for reference:
* **[Languages](https://github.com/soimort/translate-shell/wiki/Languages)**
* **[Writing Systems and Fonts](https://github.com/soimort/translate-shell/wiki/Writing-Systems-and-Fonts)**
The following pages demonstrate the advanced usage of **Translate Shell**:
* **[REPL](https://github.com/soimort/translate-shell/wiki/REPL)**
* **[Text Editor Integration](https://github.com/soimort/translate-shell/wiki/Text-Editor-Integration)**
* **[Narrator Selection](https://github.com/soimort/translate-shell/wiki/Narrator-Selection)**
* **[Configuration](https://github.com/soimort/translate-shell/wiki/Configuration)**
* **[Themes](https://github.com/soimort/translate-shell/wiki/Themes)**
* **[AppleScript](https://github.com/soimort/translate-shell/wiki/AppleScript)**
Find out whether your Linux distribution has included **Translate Shell** in its official repository. If not, contribute one:
* **[Distros](https://github.com/soimort/translate-shell/wiki/Distros)**
Frequently Asked Questions, historical stuff, AWK coding style, etc.:
* **[FAQ](https://github.com/soimort/translate-shell/wiki/FAQ)**
* **[History](https://github.com/soimort/translate-shell/wiki/History)**
* **[AWK Style Guide](https://github.com/soimort/translate-shell/wiki/AWK-Style-Guide)**
## Reporting Bugs / Contributing
Please review the [guidelines for contributing](https://github.com/soimort/translate-shell/blob/stable/CONTRIBUTING.md) before reporting an issue or sending a pull request.
## Licensing
This is free and unencumbered software released into the public domain. See **[LICENSE](https://github.com/soimort/translate-shell/blob/stable/LICENSE)** and **[WAIVER](https://github.com/soimort/translate-shell/blob/stable/WAIVER)** for details.
translate-shell-0.9.6.11/README.template.md 0000664 0000000 0000000 00000032550 13516335241 0020151 0 ustar 00root root 0000000 0000000 # Translate Shell
[](https://www.soimort.org/translate-shell)
[](https://circleci.com/gh/soimort/translate-shell)
[](https://github.com/soimort/translate-shell/releases)
[](https://www.soimort.org/translate-shell/trans)
[](https://gitter.im/soimort/translate-shell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**[Translate Shell](https://www.soimort.org/translate-shell)** (formerly _Google Translate CLI_) is a command-line translator powered by **[Google Translate](https://translate.google.com/)** (default), **[Bing Translator](https://www.bing.com/translator)**, **[Yandex.Translate](https://translate.yandex.com/)**, and **[Apertium](https://www.apertium.org/)**. It gives you easy access to one of these translation engines in your terminal:
```
$ trans 'Saluton, Mondo!'
Saluton, Mondo!
Hello, World!
Translations of Saluton, Mondo!
[ Esperanto -> English ]
Saluton ,
Hello,
Mondo !
World!
```
By default, translations with detailed explanations are shown. You can also translate the text briefly: (only the most relevant translation will be shown)
```
$ trans -brief 'Saluton, Mondo!'
Hello, World!
```
**Translate Shell** can also be used like an interactive shell; input the text to be translated line by line:
```
$ trans -shell -brief
> Rien ne réussit comme le succès.
Nothing succeeds like success.
> Was mich nicht umbringt, macht mich stärker.
What does not kill me makes me stronger.
> Юмор есть остроумие глубокого чувства.
Humor has a deep sense of wit.
> 學而不思則罔,思而不學則殆。
Learning without thought is labor lost, thought without learning is perilous.
> 幸福になるためには、人から愛されるのが一番の近道。
In order to be happy, the best way is to be loved by people.
```
## Prerequisites
### System Requirements
**Translate Shell** is known to work on many POSIX-compliant systems, including but not limited to:
* GNU/Linux
* macOS
* *BSD
* Android (through Termux)
* Windows (through WSL, Cygwin, or MSYS2)
### Dependencies
* **[GNU Awk](https://www.gnu.org/software/gawk/)** (**gawk**) **4.0 or later**
* This program relies heavily on GNU extensions of the [AWK language](http://en.wikipedia.org/wiki/AWK), which are non-portable for other AWK implementations (e.g. nawk).
* How to get gawk:
* gawk comes with all GNU/Linux distributions.
* On FreeBSD, gawk is available in the ports.
* On macOS, gawk is available in MacPorts and Homebrew.
* **[GNU Bash](http://www.gnu.org/software/bash/)** or **[Zsh](http://www.zsh.org/)**
* You may use Translate Shell from any Unix shell of your choice (bash, zsh, ksh, tcsh, fish, etc.); however, the wrapper script requires either **bash** or **zsh** installed.
### Recommended Dependencies
These dependencies are optional, but strongly recommended for full functionality:
* **[curl](http://curl.haxx.se/)** with **OpenSSL** support
* **[GNU FriBidi](http://fribidi.org/)**: _an implementation of the Unicode Bidirectional Algorithm (bidi)_
* required for displaying text in Right-to-Left scripts (e.g. Arabic, Hebrew)
* **[mplayer](http://www.mplayerhq.hu/)**, **[mpv](http://mpv.io/)**, **[mpg123](http://mpg123.org/)**, or **[eSpeak](http://espeak.sourceforge.net/)**
* required for the Text-to-Speech functionality
* **[less](http://www.greenwoodsoftware.com/less/)**, **[more](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html)** or **[most](http://www.jedsoft.org/most/)**
* required for terminal paging
* **[rlwrap](http://utopia.knoware.nl/~hlub/uck/rlwrap/#rlwrap)**: *a GNU readline wrapper*
* required for readline-style editing and history in the interactive shell
* **[aspell](http://aspell.net/)** or **[hunspell](http://hunspell.github.io/)**
* required for spell checking
### Environment and Fonts
It is a must to have corresponding fonts for the language(s) / script(s) you wish to display in your terminal. See **[wiki: Writing Systems and Fonts](https://github.com/soimort/translate-shell/wiki/Writing-Systems-and-Fonts#unicode-fonts)** for more details on scripts and recommended Unicode fonts.
## Try It Out!
Start an interactive shell and translate anything you input into your native language: (in **bash** or **zsh**)
$ gawk -f <(curl -Ls git.io/translate) -- -shell
(in **fish**)
$ gawk -f (curl -Ls git.io/translate | psub) -- -shell
## Installation
### Option #1. Direct Download
Download [the self-contained executable](http://git.io/trans) and place it into your path. It's everything you need.
$ wget git.io/trans
$ chmod +x ./trans
There is a [GPG signature](https://www.soimort.org/translate-shell/trans.sig).
### Option #2. From A Package Manager
#### Using [Antigen](https://github.com/zsh-users/antigen) (Recommended for Zsh users)
Add the following line to your `.zshrc`:
antigen bundle soimort/translate-shell
#### Using your favorite package manager
See **[wiki: Distros](https://github.com/soimort/translate-shell/wiki/Distros)** on how to install from a specific package manager on your distro.
### Option #3. From Git (Recommended for seasoned hackers)
$ git clone https://github.com/soimort/translate-shell
$ cd translate-shell/
$ make
$ [sudo] make install
In case you have only zsh but not bash in your system, build with:
$ make TARGET=zsh
The default `PREFIX` of installation is `/usr/local`. To install the program to somewhere else (e.g. `/usr`, `~/.local`), use:
$ [sudo] make PREFIX=/usr install
## Getting Started by Examples
### Translate a Word
#### From any language to your language
Google Translate can identify the language of the source text automatically, and Translate Shell by default translates the source text into the language of your `locale`.
$ trans vorto
#### From any language to one or more specific languages
Translate a word into French:
$ trans :fr word
Translate a word into Chinese and Japanese: (use a plus sign "`+`" as the delimiter)
$ trans :zh+ja word
Alternatively, equals sign ("`=`") can be used in place of the colon ("`:`"). Note that in some shells (e.g. zsh), equals signs may be interpreted differently, therefore the argument specifying languages needs to be protected:
$ trans {=zh+ja} word
$ trans '=zh+ja' word
You can also use the `-target` (`-t`) option to specify the target language(s):
$ trans -t zh+ja word
With the `-t` option, the name of the language may also be used instead of the language code:
$ trans -t japanese word
$ trans -t 日本語 word
#### From a specific language
Google Translate may wrongly identify the source text as some other language than you expected:
$ trans 手紙
In that case, you need to specify its language explicitly:
$ trans ja: 手紙
$ trans zh: 手紙
You can also use the `-source` (`-s`) option to specify the source language:
$ trans -s ja 手紙
### Translate Multiple Words or a Phrase
Translate each word alone:
$ trans en:zh word processor
Put words into one argument, and translate them as a whole:
$ trans en:zh "word processor"
### Translate a Sentence
Translating a sentence is much the same like translating a phrase; you can just quote the sentence into one argument:
$ trans :zh "To-morrow, and to-morrow, and to-morrow,"
$ trans :zh 'To-morrow, and to-morrow, and to-morrow,'
It is also possible to translate multi-line sentences:
$ trans :zh "Creeps in this petty pace from day to day,
> To the last syllable of recorded time;
> And all our yesterdays have lighted fools
> The way to dusty death."
To avoid punctuation marks (e.g. "`!`") or other special characters being interpreted by the shell, use *single quotes*:
$ trans :zh 'Out, out, brief candle!'
There are some cases though, you may still want to use *double quotes*: (e.g. the sentence contains a single quotation mark "`'`")
$ trans :zh "Life's but a walking shadow, a poor player"
Alternatively, use the `-join-sentence` (`-j`) option to treat all arguments as one sentence so that quotes can be omitted:
$ trans -j :zh Life\'s but a walking shadow, a poor player
### Brief Mode
By default, Translate Shell displays translations in a verbose manner. If you prefer to see only the most relevant translation, there is a brief mode available using the `-brief` (`-b`) option:
$ trans -b :fr "Saluton, Mondo"
In brief mode, phonetic notation (if any) is not shown by default. To enable this, put an at sign "`@`" in front of the language code:
$ trans -b :@ja "Saluton, Mondo"
### Dictionary Mode
Google Translate can be used as a dictionary. When translating a word and the target language is the same as the source language, the dictionary entry of the word is shown:
$ trans :en word
To enable dictionary mode no matter whether the source language and the target language are identical, use the `-dictionary` (`-d`) option.
$ trans -d fr: mot
**Note:** Not every language supported by Google Translate has provided dictionary data. See **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)** to find out which language(s) has dictionary support.
### Language Identification
Use the `-identify` (`-id`) option to identify the language of the text:
$ trans -id 言葉
### Text-to-Speech
Use the `-play` (`-p`) option to listen to the translation:
$ trans -b -p :ja "Saluton, Mondo"
Use the `-speak` (`-sp`) option to listen to the original text:
$ trans -sp "你好,世界"
### Terminal Paging
Sometimes the content of translation can be too much for display in one screen. Use the `-view` (`-v`) option to view the translation in a terminal pager such as `less` or `more`:
$ trans -d -v word
### Right-to-Left (RTL) Languages
[Right-to-Left (RTL) languages](http://en.wikipedia.org/wiki/Right-to-left) are well supported via [GNU FriBidi](http://fribidi.org/).
The program will automatically adjust the screen width for padding when displaying right-to-left languages. Alternatively, you may use the `-width` (`-w`) option to specify the screen width:
$ trans -b -w 40 :he "Saluton, Mondo"
See **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)** to find out which language(s) uses a Right-to-Left writing system.
### Pipeline, Input and Output
If no source text is given in command-line arguments, the program will read from standard input, or from the file specified by the `-input` (`-i`) option:
$ echo "Saluton, Mondo" | trans -b :fr
$ trans -b -i input.txt :fr
Translations are written to standard output, or to the file specified by the `-output` (`-o`) option:
$ echo "Saluton, Mondo" | trans -b -o output.txt :fr
### Translate a File
Instead of using the `-input` option, a [file URI scheme](http://en.wikipedia.org/wiki/File_URI_scheme) (`file://` followed by the file name) can be used as a command-line argument:
$ trans :fr file://input.txt
**Note**: Brief mode is used when translating from file URI schemes.
### Translate a Web Page
To translate a web page, an http(s) URI scheme can be used as an argument:
$ trans :fr http://www.w3.org/
A browser session will open for viewing the translation (via Google Translate's web interface). To specify your web browser of choice, use the `-browser` option:
$ trans -browser firefox :fr http://www.w3.org/
### Language Details
Use the `-list` (`-L`) option to view details of one or more languages:
$ trans -L fr
$ trans -L de+en
Some basic information of the language will be displayed: its English name and endonym (language name in the language itself), language family, writing system, canonical Google Translate code and ISO 639-3 code.
### Interactive Translate Shell (REPL)
Start an interactive shell using the `-shell` (or `-interactive`, `-I`) option:
$ trans -shell
You may specify the source language and the target language(s) before starting an interactive shell:
$ trans -shell en:fr
You may also change these settings during an interactive session. See **[wiki: REPL](https://github.com/soimort/translate-shell/wiki/REPL)** for more advanced usage of the interactive Translate Shell.
## Usage
For more details on command-line options, see the man page **[trans(1)](https://www.soimort.org/translate-shell/trans.1.html)** or use `trans -M` in a terminal.
```
$usage$
```
## Code List
Use `trans -R` or `trans -T` to view the reference table in a terminal.
For more details on languages and corresponding codes, see **[wiki: Languages](https://github.com/soimort/translate-shell/wiki/Languages)**.
$code-list$
## Wiki
$wiki-home$
## Reporting Bugs / Contributing
Please review the [guidelines for contributing](https://github.com/soimort/translate-shell/blob/stable/CONTRIBUTING.md) before reporting an issue or sending a pull request.
## Licensing
This is free and unencumbered software released into the public domain. See **[LICENSE](https://github.com/soimort/translate-shell/blob/stable/LICENSE)** and **[WAIVER](https://github.com/soimort/translate-shell/blob/stable/WAIVER)** for details.
translate-shell-0.9.6.11/WAIVER 0000664 0000000 0000000 00000001563 13516335241 0016000 0 ustar 00root root 0000000 0000000 # Copyright waiver for
I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
To the best of my knowledge and belief, my contributions are either
originally authored by me or are derived from prior works which I have
verified are also in the public domain and are not subject to claims
of copyright by other parties.
To the best of my knowledge and belief, no individual, business,
organization, government, or other entity has any copyright interest
in my contributions, and I affirm that I will not make contributions
that are otherwise encumbered.
translate-shell-0.9.6.11/build.awk 0000775 0000000 0000000 00000026521 13516335241 0016667 0 ustar 00root root 0000000 0000000 #!/usr/bin/gawk -f
# Not all 4.x versions of gawk can handle @include without ".awk" extension
# But the build.awk script and the single build should support gawk 4.0+.
@include "include/Commons.awk"
@include "include/Utils.awk"
@include "include/Languages.awk"
@include "metainfo.awk"
function init() {
BuildPath = "build/"
Trans = BuildPath Command
TransAwk = Trans ".awk"
ManPath = "man/"
Man = ManPath Command ".1"
ManTemplate = Man ".template.md"
ManMarkdown = Man ".md"
ManHtmlTemplate = Man ".template.html"
ManHtml = Man ".html"
PagesPath = "gh-pages/"
BadgeDownload = PagesPath "images/badge-download"
BadgeRelease = PagesPath "images/badge-release"
Index = PagesPath "index.md"
ReadmePath = "./"
ReadmeTemplate = ReadmePath "README.template.md"
Readme = ReadmePath "README.md"
WikiPath = "wiki/"
WikiHome = WikiPath "Home.md"
WikiLanguages = WikiPath "Languages.md"
WikiLanguagesHtml = WikiLanguages ".html"
RegistryPath = "registry/"
MainRegistryTemplate = RegistryPath "index.template.trans"
MainRegistry = RegistryPath "index.trans"
}
function man( text) {
text = readFrom(ManTemplate)
gsub(/\$Version\$/, Version, text)
gsub(/\$ReleaseDate\$/, ReleaseDate, text)
writeTo(text, ManMarkdown)
if (fileExists(ManHtmlTemplate))
system("pandoc -s -f markdown-smart -t html --toc --toc-depth 1 --template " ManHtmlTemplate " " ManMarkdown " -o " ManHtml)
return system("pandoc -s -f markdown-smart -t man " ManMarkdown " -o " Man)
}
function readme( code, col, cols, content, group, i, j, num, language, r, rows, text) {
text = readFrom(ReadmeTemplate)
content = getOutput("gawk -f translate.awk -- -no-ansi -h")
gsub(/\$usage\$/, content, text)
initBiDi(); initLocale()
# number of language codes with stable support
num = 0
for (code in Locale)
if (Locale[code]["support"] != "unstable")
num++
rows = int(num / 3) + (num % 3 ? 1 : 0)
cols[0][0] = cols[1][0] = cols[2][0] = NULLSTR
i = 0
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "compName"
for (code in Locale) {
# Ignore unstable languages
if (Locale[code]["support"] == "unstable") continue
col = int(i / rows)
append(cols[col], code)
i++
}
PROCINFO["sorted_in"] = saveSortedIn
r = "| Language | Code | Language | Code | Language | Code |" RS \
"| :------: | :--: | :------: | :--: | :------: | :--: |" RS
for (i = 0; i < rows; i++) {
r = r "| "
for (j = 0; j < 3; j++)
if (cols[j][i]) {
split(getName(cols[j][i]), group, " ")
language = length(group) == 1 ? group[1] "_language" : join(group, "_")
r = r "**[" getName(cols[j][i]) "](" "http://en.wikipedia.org/wiki/" language ")**
**" getEndonym(cols[j][i]) "** | **`" cols[j][i] "`** | "
}
r = r RS
}
gsub(/\$code-list\$/, r, text)
content = readFrom(WikiHome)
gsub(/\$wiki-home\$/, content, text)
writeTo(text, Readme)
return 0
}
function wiki( code, group, iso, language, saveSortedIn) {
initBiDi(); initLocale()
#print "***" length(Locale) "*** *languages in total. "
print "*Generated from the source code of Translate Shell " Version ".*\n" > WikiLanguages
print "*Version: [English](https://github.com/soimort/translate-shell/wiki/Languages) " \
"| [Chinese Simplified](https://github.com/soimort/translate-shell/wiki/Languages-%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29)*\n" > WikiLanguages
print "| Code | Name | Family | [Writing system](https://github.com/soimort/translate-shell/wiki/Writing-Systems-and-Fonts) | Is [RTL](http://en.wikipedia.org/wiki/Right-to-left)? | Has dictionary? |" > WikiLanguages
print "| :--: | ---: | -----: | :------------: | :---------------------------------------------------: | :-------------: |" > WikiLanguages
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "@ind_num_asc"
for (code in Locale) {
# Ignore unstable languages
if (Locale[code]["support"] == "unstable") continue
split(getISO(code), group, "-")
iso = group[1]
split(getName(code), group, " ")
language = length(group) == 1 ? group[1] "_language" :
group[2] ~ /^\(.*\)$/ ? group[1] "_language" : join(group, "_")
print sprintf("| **`%s`**
[`%s`](%s) | **[%s](%s)**
**%s** | %s | `%s` | %s | %s |",
getCode(code), iso, "http://www.ethnologue.com/language/" iso,
getName(code), "http://en.wikipedia.org/wiki/" language, getEndonym(code),
getFamily(code), getScript(code),
isRTL(code) ? "✓" : NULLSTR,
hasDictionary(code) ? "✓" : NULLSTR) > WikiLanguages
}
PROCINFO["sorted_in"] = saveSortedIn
return system("pandoc -s -t html " WikiLanguages " -o " WikiLanguagesHtml)
}
function doc() {
man()
readme()
wiki()
return 0
}
function readSqueezed(fileName, squeezed, group, line, ret) {
if (fileName ~ /\*$/) # glob simulation
return readSqueezed(fileName ".awk", squeezed)
ret = NULLSTR
if (fileExists(fileName))
while (getline line < fileName) {
match(line, /^[[:space:]]*@include[[:space:]]*"(.*)"$/, group)
if (RSTART) { # @include
if (group[1] ~ /\.awk$/)
append(Includes, group[1])
if (ret) ret = ret RS
ret = ret readSqueezed(group[1], squeezed)
} else if (!squeezed || line = squeeze(line)) { # effective LOC
if (ret) ret = ret RS
ret = ret line
}
}
return ret
}
function build(target, type, i, group, inline, line, temp) {
# Default target: bash
if (!target) target = "bash"
("mkdir -p " parameterize(BuildPath)) | getline
if (target == "bash" || target == "zsh") {
print "#!/usr/bin/env " target > Trans
if (fileExists("DISCLAIMER")) {
print "#" > Trans
while (getline line < "DISCLAIMER")
print "# " line > Trans
print "#" > Trans
}
print "export TRANS_ENTRY=\"$0\"" > Trans
print "if [[ ! $LANG =~ (UTF|utf)-?8$ ]]; then export LANG=en_US.UTF-8; fi" > Trans
print "read -r -d '' TRANS_PROGRAM << 'EOF'" > Trans
print readSqueezed(EntryPoint, TRUE) > Trans
print "EOF" > Trans
print "read -r -d '' TRANS_MANPAGE << 'EOF'" > Trans
if (fileExists(Man))
while (getline line < Man)
print line > Trans
print "EOF" > Trans
print "export TRANS_MANPAGE" > Trans
if (type == "release")
print "export TRANS_BUILD=release" temp > Trans
else {
temp = getGitHead()
if (temp)
print "export TRANS_BUILD=git:" temp > Trans
}
print "gawk -f <(echo -E \"$TRANS_PROGRAM\") - \"$@\"" > Trans
("chmod +x " parameterize(Trans)) | getline
# Rebuild EntryScript
print "#!/bin/sh" > EntryScript
print "export TRANS_DIR=`dirname $0`" > EntryScript
print "gawk \\" > EntryScript
for (i = 0; i < length(Includes) - 1; i++)
print "-i \"${TRANS_DIR}/" Includes[i] "\" \\" > EntryScript
print "-f \"${TRANS_DIR}/" Includes[i] "\" -- \"$@\"" > EntryScript
("chmod +x " parameterize(EntryScript)) | getline
return 0
} else if (target == "awk" || target == "gawk") {
"uname -s" | getline temp
print (temp == "Darwin" ?
"#!/usr/bin/env gawk -f" : # macOS
"#!/usr/bin/gawk -f") > TransAwk
print readSqueezed(EntryPoint, TRUE) > TransAwk
("chmod +x " parameterize(TransAwk)) | getline
return 0
} else {
w("[FAILED] Unknown target: " ansi("underline", target))
w(" Supported targets: " \
ansi("underline", "bash") ", " \
ansi("underline", "zsh") ", " \
ansi("underline", "gawk"))
return 1
}
}
function clean() {
("rm -f " BuildPath Command "*") | getline
return 0
}
function release( content, group, sha1, size, temp, text) {
d("Updating registry ...")
# Update registry
text = readFrom(MainRegistryTemplate)
gsub(/\$Version\$/, Version, text)
writeTo(text, MainRegistry)
d("Updating gh-pages/images ...")
# Update gh-pages/images/badge-release
text = readFrom(BadgeRelease ".temp")
gsub(/\$Version\$/, Version, text)
writeTo(text, BadgeRelease)
system("save-to-png " BadgeRelease)
# Update gh-pages/images/badge-download
("wc -c " Trans) | getline temp
split(temp, group)
size = int(group[1] / 1000)
text = readFrom(BadgeDownload ".temp")
gsub(/\$Size\$/, size, text)
writeTo(text, BadgeDownload)
system("save-to-png " BadgeDownload)
d("Updating gh-pages/index.md ...")
# Update gh-pages/index.md
("sha1sum " Trans) | getline temp
split(temp, group)
sha1 = group[1]
content = readFrom(Readme)
text = readFrom(Index ".temp")
gsub(/\$sha1\$/, sha1, text)
gsub(/\$Version\$/, Version, text)
gsub(/\$readme\$/, content, text)
writeTo(text, Index)
return 0
}
function test() {
return 0
}
BEGIN {
init()
pos = 0
while (ARGV[++pos]) {
# -target TARGET
match(ARGV[pos], /^--?target(=(.*)?)?$/, group)
if (RSTART) {
target = tolower(group[2] ? group[2] : ARGV[++pos])
continue
}
# -type TYPE
match(ARGV[pos], /^--?type(=(.*)?)?$/, group)
if (RSTART) {
type = tolower(group[2] ? group[2] : ARGV[++pos])
continue
}
# TASK
match(ARGV[pos], /^[^\-]/, group)
if (RSTART) {
append(tasks, ARGV[pos])
continue
}
}
# Default task: build
if (!anything(tasks)) tasks[0] = "build"
for (i = 0; i < length(tasks); i++) {
task = tasks[i]
status = 0
switch (task) {
case "man":
status = man()
break
case "readme":
status = readme()
break
case "wiki":
status = wiki()
break
case "doc":
status = doc()
break
case "build":
status = build(target, type)
break
case "clean":
status = clean()
break
case "release":
status = release()
break
case "test":
status = test()
break
default: # unknown task
status = -1
}
if (status == 0) {
d("[OK] Task " ansi("bold", task) " completed.")
} else if (status < 0) {
w("[FAILED] Unknown task: " ansi("bold", task))
exit 1
} else {
w("[FAILED] Task " ansi("bold", task) " failed.")
exit 1
}
}
}
translate-shell-0.9.6.11/google-translate-mode.el 0000664 0000000 0000000 00000004136 13516335241 0021572 0 ustar 00root root 0000000 0000000 ;;; google-translate-mode.el --- Google Translate minor mode
;; This file is distributed as part of translate-shell
;; URL: https://github.com/soimort/translate-shell
;; Last-Updated: 2015-04-08 Wed
;; This is free and unencumbered software released into the public domain.
;;; Code:
(defcustom trans-command "trans"
"trans command name."
:type 'string
:group 'google-translate-mode)
(defcustom trans-verbose-p nil
"Is in verbose mode. (default: nil)"
:type 'boolean
:group 'google-translate-mode)
(defcustom trans-source "auto"
"Source language. (default: auto)"
:type 'string
:group 'google-translate-mode)
(defcustom trans-target "en"
"Target language. (default: en)"
:type 'string
:group 'google-translate-mode)
(defun trans (verbose source target text)
(shell-command-to-string
(concat trans-command
(if verbose "" " -b")
(if source (concat " -s " source) "")
(if target (concat " -t " target) "")
" " text)))
(defun show-translation ()
"Show translation of the current word in message buffer."
(interactive)
(message
(trans trans-verbose-p trans-source trans-target (current-word))))
(defun view-translation ()
"View verbose translation of the current word in popup dialog."
(interactive)
(let ((translation
(trans t trans-source trans-target (current-word))))
(x-popup-menu t (list "Translation"
(list "PANE"
(list translation nil))))))
(defun insert-translation ()
"Insert translation of the current word right after."
(interactive)
(insert " ")
(insert
(trans trans-verbose-p trans-source trans-target (current-word))))
(defvar google-translate-mode-keymap
(let
((map (make-sparse-keymap)))
(define-key map (kbd "C-c -") 'show-translation)
(define-key map (kbd "C-c =") 'view-translation)
(define-key map (kbd "C-c +") 'insert-translation)
map)
"Keymap for Google Translate minor mode.")
(define-minor-mode google-translate-mode
"Google Translate"
:keymap google-translate-mode-keymap)
(provide 'google-translate-mode)
translate-shell-0.9.6.11/include/ 0000775 0000000 0000000 00000000000 13516335241 0016476 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/include/Commons.awk 0000664 0000000 0000000 00000037405 13516335241 0020626 0 ustar 00root root 0000000 0000000 ####################################################################
# Commons.awk #
####################################################################
# Initialize constants.
function initConst() {
NULLSTR = ""
NONE = "\0"
TRUE = 1
STDIN = "/dev/stdin"
STDOUT = "/dev/stdout"
STDERR = "/dev/stderr"
SUPOUT = " > /dev/null " # suppress output
SUPERR = " 2> /dev/null " # suppress error
PIPE = " | "
}
## Arrays:
# Return 1 if the array contains anything; otherwise return 0.
function anything(array,
####
i) {
for (i in array)
if (array[i]) return 1
return 0
}
# Return 1 if the value is non-empty or an array that contains anything;
# Otherwise, return 0.
function exists(value) {
if (isarray(value))
return anything(value)
else
return value ? 1 : 0
}
# Return an element if it belongs to the array;
# Otherwise, return a null string.
function belongsTo(element, array,
####
i) {
for (i in array)
if (element == array[i]) return element
return NULLSTR
}
# Return non-zero if two values are identical;
# Otherwise, return 0.
function identical(x, y,
####
i) {
if (!isarray(x) && !isarray(y))
return x == y
else if (isarray(x) && isarray(y)) {
if (length(x) != length(y)) return 0
for (i in x)
if (!identical(x[i], y[i])) return 0
return 1
} else
return 0
}
# Append an element into an array (zero-based).
function append(array, element) {
array[anything(array) ? length(array) : 0] = element
}
# Comparator function used for controlling array scanning order.
# Like @ind_num_asc, but compare on index fields separated by SUBSEP.
function compareByIndexFields(i1, v1, i2, v2,
####
t1, t2, tl, j) {
split(i1, t1, SUBSEP)
split(i2, t2, SUBSEP)
tl = length(t1) < length(t2) ? length(t1) : length(t2)
for (j = 1; j <= tl; j++) {
if (t1[j] < t2[j])
return -1
else if (t1[j] > t2[j])
return 1
}
return 0
}
## Strings:
# Return non-zero if the string represents a numeral;
# Otherwise, return 0.
function isnum(string) {
return string == string + 0
}
# Return one of the substrings if the string starts with it;
# Otherwise, return a null string.
function startsWithAny(string, substrings,
####
i) {
for (i in substrings)
if (index(string, substrings[i]) == 1) return substrings[i]
return NULLSTR
}
# Return one of the patterns if the string matches this pattern at the beginning;
# Otherwise, return a null string.
function matchesAny(string, patterns,
####
i) {
for (i in patterns)
if (string ~ "^" patterns[i]) return patterns[i]
return NULLSTR
}
# Replicate a string.
function replicate(string, len,
####
i, temp) {
temp = NULLSTR
for (i = 0; i < len; i++)
temp = temp string
return temp
}
# Reverse a string.
function reverse(string,
####
i, temp) {
temp = NULLSTR
for (i = length(string); i > 0; i--)
temp = temp substr(string, i, 1);
return temp
}
# Join an array into one string;
# Return the string.
function join(array, separator, sortedIn, preserveNull,
####
i, j, saveSortedIn, temp) {
# Default parameter
if (!sortedIn)
sortedIn = "compareByIndexFields"
temp = NULLSTR
j = 0
if (isarray(array)) {
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = sortedIn
for (i in array)
if (preserveNull || array[i] != NULLSTR)
temp = j++ ? temp separator array[i] : array[i]
PROCINFO["sorted_in"] = saveSortedIn
} else
temp = array
return temp
}
# Split a string into characters.
function explode(string, array) {
split(string, array, NULLSTR)
}
# Return the real character represented by an escape sequence.
# Example: escapeChar("n") returns "\n".
# See:
#
function escapeChar(char) {
switch (char) {
case "b":
return "\b" # Backspace
case "f":
return "\f" # Formfeed
case "n":
return "\n" # Newline (Line Feed)
case "r":
return "\r" # Carriage Return
case "t":
return "\t" # Horizontal Tab
case "v":
return "\v" # Vertical Tab
case "u0026":
return "&" # Unicode Character 'AMPERSAND'
case "u003c":
return "<" # Unicode Character 'LESS-THAN SIGN'
case "u003e":
return ">" # Unicode Character 'GREATER-THAN SIGN'
default:
return char
}
}
# Convert a literal-formatted string into its original string.
function literal(string,
####
c, cc, escaping, i, s) {
if (string !~ /^".*"$/)
return string
explode(string, s)
string = NULLSTR
escaping = 0
for (i = 2; i < length(s); i++) {
c = s[i]
if (escaping) {
if (cc) {
cc = cc c
if (length(cc) == 5) {
string = string escapeChar(cc)
escaping = 0 # escape ends
cc = NULLSTR
}
} else if (c == "u") {
cc = c
} else {
string = string escapeChar(c)
escaping = 0 # escape ends
}
} else {
if (c == "\\")
escaping = 1 # escape begins
else
string = string c
}
}
return string
}
# Return the escaped string.
function escape(string) {
gsub(/\\/, "\\\\", string) # substitute backslashes first
gsub(/"/, "\\\"", string)
return string
}
# Reverse of escape(string).
function unescape(string) {
gsub(/\\"/, "\"", string)
gsub(/\\\\/, "\\", string) # substitute backslashes last
return string
}
# Return the escaped, quoted string.
function parameterize(string, quotationMark) {
if (!quotationMark)
quotationMark = "'"
if (quotationMark == "'") {
gsub(/'/, "'\\''", string)
return "'" string "'"
} else {
return "\"" escape(string) "\""
}
}
# Reverse of parameterize(string, quotationMark).
function unparameterize(string, temp) {
match(string, /^'(.*)'$/, temp)
if (temp[0]) { # use temp[0] (there IS a match for quoted empty string)
string = temp[1]
gsub(/'\\''/, "'", string)
return string
}
match(string, /^"(.*)"$/, temp)
if (temp[0]) {
string = temp[1]
return unescape(string)
}
return string
}
# Convert any value to human-readable string.
function toString(value, inline, heredoc, valOnly, numSub, level, sortedIn,
####
i, items, j, k, p, saveSortedIn, temp, v) {
if (!level) level = 0
if (!sortedIn)
sortedIn = "compareByIndexFields"
if (isarray(value)) {
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = sortedIn
p = 0
for (i in value) {
split(i, j, SUBSEP); k = join(j, ",")
if (!numSub || !isnum(k)) k = parameterize(k, "\"")
v = toString(value[i], inline, heredoc, valOnly, numSub, level + 1, sortedIn)
if (!isarray(value[i])) v = parameterize(v, "\"")
if (valOnly)
items[p++] = inline ? v : (replicate("\t", level) v)
else
items[p++] = inline ? (k ": " v) :
(replicate("\t", level) k "\t" v)
}
PROCINFO["sorted_in"] = saveSortedIn
temp = inline ? join(items, ", ") :
("\n" join(items, "\n") "\n" replicate("\t", level))
temp = valOnly ? ("[" temp "]") : ("{" temp "}")
return temp
} else {
if (heredoc)
return "'''\n" value "\n'''"
else
return value
}
}
# Squeeze a source line of AWK code.
function squeeze(line, preserveIndent) {
# Remove preceding spaces if indentation not preserved
if (!preserveIndent)
gsub(/^[[:space:]]+/, NULLSTR, line)
# Remove comment
gsub(/^[[:space:]]*#.*$/, NULLSTR, line)
# Remove in-line comment
gsub(/#[^"/]*$/, NULLSTR, line)
# Remove trailing spaces
gsub(/[[:space:]]+$/, NULLSTR, line)
gsub(/[[:space:]]+\\$/, "\\", line)
return line
}
# Return 0 if the string starts with '0', 'f', 'n' or 'off';
# Otherwise, return 1.
function yn(string) {
return (tolower(string) ~ /^([0fn]|off)/) ? 0 : 1
}
## Display & Debugging:
# Initialize ANSI escape codes for SGR (Select Graphic Rendition).
# (ANSI X3.64 Standard Control Sequences)
# See:
function initAnsiCode() {
# Dumb terminal: no ANSI escape code whatsoever
if (ENVIRON["TERM"] == "dumb") return
AnsiCode["reset"] = AnsiCode[0] = "\33[0m"
AnsiCode["bold"] = "\33[1m"
AnsiCode["underline"] = "\33[4m"
AnsiCode["negative"] = "\33[7m"
AnsiCode["no bold"] = "\33[22m" # SGR code 21 (bold off) not widely supported
AnsiCode["no underline"] = "\33[24m"
AnsiCode["positive"] = "\33[27m"
AnsiCode["black"] = "\33[30m"
AnsiCode["red"] = "\33[31m"
AnsiCode["green"] = "\33[32m"
AnsiCode["yellow"] = "\33[33m"
AnsiCode["blue"] = "\33[34m"
AnsiCode["magenta"] = "\33[35m"
AnsiCode["cyan"] = "\33[36m"
AnsiCode["gray"] = "\33[37m"
AnsiCode["default"] = "\33[39m"
AnsiCode["dark gray"] = "\33[90m"
AnsiCode["light red"] = "\33[91m"
AnsiCode["light green"] = "\33[92m"
AnsiCode["light yellow"] = "\33[93m"
AnsiCode["light blue"] = "\33[94m"
AnsiCode["light magenta"] = "\33[95m"
AnsiCode["light cyan"] = "\33[96m"
AnsiCode["white"] = "\33[97m"
}
# Return ANSI escaped string.
function ansi(code, text) {
switch (code) {
case "bold":
return AnsiCode[code] text AnsiCode["no bold"]
case "underline":
return AnsiCode[code] text AnsiCode["no underline"]
case "negative":
return AnsiCode[code] text AnsiCode["positive"]
default:
return AnsiCode[code] text AnsiCode[0]
}
}
# Print warning message.
function w(text) {
print ansi("yellow", text) > STDERR
}
# Print error message.
function e(text) {
print ansi("bold", ansi("yellow", text)) > STDERR
}
# What a terrible failure.
function wtf(text) {
print ansi("bold", ansi("red", text)) > STDERR
}
# Print debugging message.
function d(text) {
print ansi("gray", text) > STDERR
}
# Debug any value.
function da(value, name, inline, heredoc, valOnly, numSub, sortedIn,
####
i, j, saveSortedIn) {
# Default parameters
if (!name)
name = "_"
if (!sortedIn)
sortedIn = "compareByIndexFields"
d(name " = " toString(value, inline, heredoc, valOnly, numSub, 0, sortedIn))
#if (isarray(value)) {
# saveSortedIn = PROCINFO["sorted_in"]
# PROCINFO["sorted_in"] = sortedIn
# for (i in value) {
# split(i, j, SUBSEP)
# da(value[i], sprintf(name "[%s]", join(j, ",")), sortedIn)
# }
# PROCINFO["sorted_in"] = saveSortedIn
#} else
# d(name " = " value)
}
# Naive assertion.
function assert(x, message) {
if (!message)
message = "[ERROR] Assertion failed."
if (x)
return x
else
e(message)
}
## URLs:
# Initialize `UrlEncoding`.
# See:
function initUrlEncoding() {
UrlEncoding["\t"] = "%09"
UrlEncoding["\n"] = "%0A"
UrlEncoding[" "] = "%20"
UrlEncoding["!"] = "%21"
UrlEncoding["\""] = "%22"
UrlEncoding["#"] = "%23"
UrlEncoding["$"] = "%24"
UrlEncoding["%"] = "%25"
UrlEncoding["&"] = "%26"
UrlEncoding["'"] = "%27"
UrlEncoding["("] = "%28"
UrlEncoding[")"] = "%29"
UrlEncoding["*"] = "%2A"
UrlEncoding["+"] = "%2B"
UrlEncoding[","] = "%2C"
UrlEncoding["-"] = "%2D"
UrlEncoding["."] = "%2E"
UrlEncoding["/"] = "%2F"
UrlEncoding[":"] = "%3A"
UrlEncoding[";"] = "%3B"
UrlEncoding["<"] = "%3C"
UrlEncoding["="] = "%3D"
UrlEncoding[">"] = "%3E"
UrlEncoding["?"] = "%3F"
UrlEncoding["@"] = "%40"
UrlEncoding["["] = "%5B"
UrlEncoding["\\"] = "%5C"
UrlEncoding["]"] = "%5D"
UrlEncoding["^"] = "%5E"
UrlEncoding["_"] = "%5F"
UrlEncoding["`"] = "%60"
UrlEncoding["{"] = "%7B"
UrlEncoding["|"] = "%7C"
UrlEncoding["}"] = "%7D"
UrlEncoding["~"] = "%7E"
}
# Return the URL-encoded string.
function quote(string, i, r, s) {
r = NULLSTR
explode(string, s)
for (i = 1; i <= length(s); i++)
r = r (s[i] in UrlEncoding ? UrlEncoding[s[i]] : s[i])
return r
}
# Return the URL-decoded string.
function unquote(string, i, k, r, s, temp) {
r = NULLSTR
explode(string, s)
temp = NULLSTR
for (i = 1; i <= length(s); i++)
if (temp) {
temp = temp s[i]
if (length(temp) > 2) {
for (k in UrlEncoding)
if (temp == UrlEncoding[k]) {
r = r k
temp = NULLSTR
break
}
if (temp) {
r = r temp
temp = NULLSTR
}
}
} else {
if (s[i] != "%")
r = r s[i]
else
temp = s[i]
}
if (temp)
r = r temp
return r
}
# Initialize `UriSchemes`.
function initUriSchemes() {
UriSchemes[0] = "file://"
UriSchemes[1] = "http://"
UriSchemes[2] = "https://"
}
## System:
# Read from a file and return its content.
function readFrom(file, line, text) {
if (!file) file = "/dev/stdin"
text = NULLSTR
while (getline line < file)
text = (text ? text "\n" : NULLSTR) line
return text
}
# Write text to file.
function writeTo(text, file) {
if (!file) file = "/dev/stdout"
print text > file
}
# Return the output of a command.
function getOutput(command, content, line) {
content = NULLSTR
while ((command |& getline line) > 0)
content = (content ? content "\n" : NULLSTR) line
close(command)
return content
}
# Return non-zero if file exists; otherwise return 0.
function fileExists(file) {
return !system("test -f " parameterize(file))
}
# Return non-zero if file exists and is a directory; otherwise return 0.
function dirExists(file) {
return !system("test -d " parameterize(file))
}
# Detect whether a program exists in path.
# Return the name (or output) if the program call writes anything to stdout;
# Otherwise, return a null string.
function detectProgram(prog, arg, returnOutput, command, temp) {
command = prog " " arg SUPERR
command | getline temp
close(command)
if (returnOutput)
return temp
if (temp)
return prog
return NULLSTR
}
# Return the HEAD revision if the current directory is a git repo;
# Otherwise return a null string.
function getGitHead( line, group) {
if (fileExists(".git/HEAD")) {
getline line < ".git/HEAD"
match(line, /^ref: (.*)$/, group)
if (fileExists(".git/" group[1])) {
getline line < (".git/" group[1])
return substr(line, 1, 7)
} else
return NULLSTR
} else
return NULLSTR
}
BEGIN {
initConst()
initAnsiCode()
initUrlEncoding()
initUriSchemes()
}
translate-shell-0.9.6.11/include/Help.awk 0000664 0000000 0000000 00000050435 13516335241 0020101 0 ustar 00root root 0000000 0000000 ####################################################################
# Help.awk #
####################################################################
# Return version as a string.
function getVersion( build, gitHead) {
initAudioPlayer()
initPager()
Platform = Platform ? Platform : detectProgram("uname", "-s", 1)
if (ENVIRON["TRANS_BUILD"])
build = "-" ENVIRON["TRANS_BUILD"]
else {
gitHead = getGitHead()
build = gitHead ? "-git:" gitHead : ""
}
return ansi("bold", sprintf("%-22s%s%s\n\n", Name, Version, build)) \
sprintf("%-22s%s\n", "platform", Platform) \
sprintf("%-22s%s\n", "terminal type", ENVIRON["TERM"]) \
sprintf("%-22s%s\n", "bi-di emulator", BiDiTerm ? BiDiTerm :
"[N/A]") \
sprintf("%-22s%s\n", "gawk (GNU Awk)", PROCINFO["version"]) \
sprintf("%s\n", FriBidi ? FriBidi :
"fribidi (GNU FriBidi) [NOT INSTALLED]") \
sprintf("%-22s%s\n", "audio player", AudioPlayer ? AudioPlayer :
"[NOT INSTALLED]") \
sprintf("%-22s%s\n", "terminal pager", Pager ? Pager :
"[NOT INSTALLED]") \
sprintf("%-22s%s\n", "web browser", Option["browser"] != NONE ?
Option["browser"] :"[NONE]") \
sprintf("%-22s%s (%s)\n", "user locale", UserLocale, getName(UserLang)) \
sprintf("%-22s%s\n", "home language", Option["hl"]) \
sprintf("%-22s%s\n", "source language", join(Option["sls"], "+")) \
sprintf("%-22s%s\n", "target language", join(Option["tl"], "+")) \
sprintf("%-22s%s\n", "translation engine", Option["engine"]) \
sprintf("%-22s%s\n", "proxy", Option["proxy"] ? Option["proxy"] :
"[NONE]") \
sprintf("%-22s%s\n", "user-agent", Option["user-agent"] ? Option["user-agent"] :
"[NONE]") \
sprintf("%-22s%s\n", "ip version", Option["ip-version"] ? Option["ip-version"] :
"[DEFAULT]") \
sprintf("%-22s%s\n", "theme", Option["theme"]) \
sprintf("%-22s%s\n", "init file", InitScript ? InitScript : "[NONE]") \
sprintf("\n%-22s%s", "Report bugs to:", "https://github.com/soimort/translate-shell/issues")
}
# Return help message as a string.
function getHelp() {
return "Usage: " ansi("bold", Command) \
" [" ansi("underline", "OPTIONS") "]" \
" [" ansi("underline", "SOURCES") "]" \
":[" ansi("underline", "TARGETS") "]" \
" [" ansi("underline", "TEXT") "]..." RS \
RS "Information options:" RS \
ins(1, ansi("bold", "-V") ", " ansi("bold", "-version")) RS \
ins(2, "Print version and exit.") RS \
ins(1, ansi("bold", "-H") ", " ansi("bold", "-help")) RS \
ins(2, "Print help message and exit.") RS \
ins(1, ansi("bold", "-M") ", " ansi("bold", "-man")) RS \
ins(2, "Show man page and exit.") RS \
ins(1, ansi("bold", "-T") ", " ansi("bold", "-reference")) RS \
ins(2, "Print reference table of languages and exit.") RS \
ins(1, ansi("bold", "-R") ", " ansi("bold", "-reference-english")) RS \
ins(2, "Print reference table of languages (in English names) and exit.") RS \
ins(1, ansi("bold", "-L ") ansi("underline", "CODES") \
", " ansi("bold", "-list ") ansi("underline", "CODES")) RS \
ins(2, "Print details of languages and exit.") RS \
ins(1, ansi("bold", "-S") ", " ansi("bold", "-list-engines")) RS \
ins(2, "List available translation engines and exit.") RS \
ins(1, ansi("bold", "-U") ", " ansi("bold", "-upgrade")) RS \
ins(2, "Check for upgrade of this program.") RS \
RS "Translator options:" RS \
ins(1, ansi("bold", "-e ") ansi("underline", "ENGINE") \
", " ansi("bold", "-engine ") ansi("underline", "ENGINE")) RS \
ins(2, "Specify the translation engine to use.") RS \
RS "Display options:" RS \
ins(1, ansi("bold", "-verbose")) RS \
ins(2, "Verbose mode. (default)") RS \
ins(1, ansi("bold", "-b") ", " ansi("bold", "-brief")) RS \
ins(2, "Brief mode.") RS \
ins(1, ansi("bold", "-d") ", " ansi("bold", "-dictionary")) RS \
ins(2, "Dictionary mode.") RS \
ins(1, ansi("bold", "-identify")) RS \
ins(2, "Language identification.") RS \
ins(1, ansi("bold", "-show-original ") ansi("underline", "Y/n")) RS \
ins(2, "Show original text or not.") RS \
ins(1, ansi("bold", "-show-original-phonetics ") ansi("underline", "Y/n")) RS \
ins(2, "Show phonetic notation of original text or not.") RS \
ins(1, ansi("bold", "-show-translation ") ansi("underline", "Y/n")) RS \
ins(2, "Show translation or not.") RS \
ins(1, ansi("bold", "-show-translation-phonetics ") ansi("underline", "Y/n")) RS \
ins(2, "Show phonetic notation of translation or not.") RS \
ins(1, ansi("bold", "-show-prompt-message ") ansi("underline", "Y/n")) RS \
ins(2, "Show prompt message or not.") RS \
ins(1, ansi("bold", "-show-languages ") ansi("underline", "Y/n")) RS \
ins(2, "Show source and target languages or not.") RS \
ins(1, ansi("bold", "-show-original-dictionary ") ansi("underline", "y/N")) RS \
ins(2, "Show dictionary entry of original text or not.") RS \
ins(1, ansi("bold", "-show-dictionary ") ansi("underline", "Y/n")) RS \
ins(2, "Show dictionary entry of translation or not.") RS \
ins(1, ansi("bold", "-show-alternatives ") ansi("underline", "Y/n")) RS \
ins(2, "Show alternative translations or not.") RS \
ins(1, ansi("bold", "-w ") ansi("underline", "NUM") \
", " ansi("bold", "-width ") ansi("underline", "NUM")) RS \
ins(2, "Specify the screen width for padding.") RS \
ins(1, ansi("bold", "-indent ") ansi("underline", "NUM")) RS \
ins(2, "Specify the size of indent (number of spaces).") RS \
ins(1, ansi("bold", "-theme ") ansi("underline", "FILENAME")) RS \
ins(2, "Specify the theme to use.") RS \
ins(1, ansi("bold", "-no-theme")) RS \
ins(2, "Do not use any other theme than default.") RS \
ins(1, ansi("bold", "-no-ansi")) RS \
ins(2, "Do not use ANSI escape codes.") RS \
ins(1, ansi("bold", "-no-autocorrect")) RS \
ins(2, "Do not autocorrect. (if defaulted by the translation engine)") RS \
ins(1, ansi("bold", "-no-bidi")) RS \
ins(2, "Do not convert bidirectional texts.") RS \
ins(1, ansi("bold", "-bidi")) RS \
ins(2, "Always convert bidirectional texts.") RS \
ins(1, ansi("bold", "-no-warn")) RS \
ins(2, "Do not write warning messages to stderr.") RS \
ins(1, ansi("bold", "-dump")) RS \
ins(2, "Print raw API response instead.") RS \
RS "Audio options:" RS \
ins(1, ansi("bold", "-p, -play")) RS \
ins(2, "Listen to the translation.") RS \
ins(1, ansi("bold", "-speak")) RS \
ins(2, "Listen to the original text.") RS \
ins(1, ansi("bold", "-n ") ansi("underline", "VOICE") \
", " ansi("bold", "-narrator ") ansi("underline", "VOICE")) RS \
ins(2, "Specify the narrator, and listen to the translation.") RS \
ins(1, ansi("bold", "-player ") ansi("underline", "PROGRAM")) RS \
ins(2, "Specify the audio player to use, and listen to the translation.") RS \
ins(1, ansi("bold", "-no-play")) RS \
ins(2, "Do not listen to the translation.") RS \
ins(1, ansi("bold", "-no-translate")) RS \
ins(2, "Do not translate anything when using -speak.") RS \
ins(1, ansi("bold", "-download-audio")) RS \
ins(2, "Download the audio to the current directory.") RS \
ins(1, ansi("bold", "-download-audio-as ") ansi("underline", "FILENAME")) RS \
ins(2, "Download the audio to the specified file.") RS \
RS "Terminal paging and browsing options:" RS \
ins(1, ansi("bold", "-v") ", " ansi("bold", "-view")) RS \
ins(2, "View the translation in a terminal pager.") RS \
ins(1, ansi("bold", "-pager ") ansi("underline", "PROGRAM")) RS \
ins(2, "Specify the terminal pager to use, and view the translation.") RS \
ins(1, ansi("bold", "-no-view") ", " ansi("bold", "-no-pager")) RS \
ins(2, "Do not view the translation in a terminal pager.") RS \
ins(1, ansi("bold", "-browser ") ansi("underline", "PROGRAM")) RS \
ins(2, "Specify the web browser to use.") RS \
ins(1, ansi("bold", "-no-browser")) RS \
ins(2, "Do not open the web browser.") RS \
RS "Networking options:" RS \
ins(1, ansi("bold", "-x ") ansi("underline", "HOST:PORT") \
", " ansi("bold", "-proxy ") ansi("underline", "HOST:PORT")) RS \
ins(2, "Use HTTP proxy on given port.") RS \
ins(1, ansi("bold", "-u ") ansi("underline", "STRING") \
", " ansi("bold", "-user-agent ") ansi("underline", "STRING")) RS \
ins(2, "Specify the User-Agent to identify as.") RS \
ins(1, ansi("bold", "-4") ", " ansi("bold", "-ipv4") \
", " ansi("bold", "-inet4-only")) RS \
ins(2, "Connect only to IPv4 addresses.") RS \
ins(1, ansi("bold", "-6") ", " ansi("bold", "-ipv6") \
", " ansi("bold", "-inet6-only")) RS \
ins(2, "Connect only to IPv6 addresses.") RS \
RS "Interactive shell options:" RS \
ins(1, ansi("bold", "-I") ", " ansi("bold", "-interactive") ", " ansi("bold", "-shell")) RS \
ins(2, "Start an interactive shell.") RS \
ins(1, ansi("bold", "-E") ", " ansi("bold", "-emacs")) RS \
ins(2, "Start the GNU Emacs front-end for an interactive shell.") RS \
ins(1, ansi("bold", "-no-rlwrap")) RS \
ins(2, "Do not invoke rlwrap when starting an interactive shell.") RS \
RS "I/O options:" RS \
ins(1, ansi("bold", "-i ") ansi("underline", "FILENAME") \
", " ansi("bold", "-input ") ansi("underline", "FILENAME")) RS \
ins(2, "Specify the input file.") RS \
ins(1, ansi("bold", "-o ") ansi("underline", "FILENAME") \
", " ansi("bold", "-output ") ansi("underline", "FILENAME")) RS \
ins(2, "Specify the output file.") RS \
RS "Language preference options:" RS \
ins(1, ansi("bold", "-l ") ansi("underline", "CODE") \
", " ansi("bold", "-hl ") ansi("underline", "CODE") \
", " ansi("bold", "-lang ") ansi("underline", "CODE")) RS \
ins(2, "Specify your home language.") RS \
ins(1, ansi("bold", "-s ") ansi("underline", "CODES") \
", " ansi("bold", "-sl ") ansi("underline", "CODES") \
", " ansi("bold", "-source ") ansi("underline", "CODES") \
", " ansi("bold", "-from ") ansi("underline", "CODES")) RS \
ins(2, "Specify the source language(s), joined by '+'.") RS \
ins(1, ansi("bold", "-t ") ansi("underline", "CODES") \
", " ansi("bold", "-tl ") ansi("underline", "CODES") \
", " ansi("bold", "-target ") ansi("underline", "CODES") \
", " ansi("bold", "-to ") ansi("underline", "CODES")) RS \
ins(2, "Specify the target language(s), joined by '+'.") RS \
RS "Text preprocessing options:" RS \
ins(1, ansi("bold", "-j") ", " ansi("bold", "-join-sentence")) RS \
ins(2, "Treat all arguments as one single sentence.") RS \
RS "Other options:" RS \
ins(1, ansi("bold", "-no-init")) RS \
ins(2, "Do not load any initialization script.") RS \
RS "See the man page " Command "(1) for more information."
}
# Show man page.
function showMan( temp) {
if (ENVIRON["TRANS_MANPAGE"]) {
initPager()
Groff = detectProgram("groff", "--version")
if (Pager && Groff) {
temp = "echo -E \"${TRANS_MANPAGE}\""
temp = temp PIPE \
Groff " -Wall -mtty-char -mandoc -Tutf8 " \
"-rLL=" Option["width"] "n -rLT=" Option["width"] "n"
switch (Pager) {
case "less":
temp = temp PIPE \
Pager " -s -P\"\\ \\Manual page " Command "(1) line %lt (press h for help or q to quit)\""
break
case "most":
temp = temp PIPE Pager " -Cs"
break
default: # more
temp = temp PIPE Pager
}
system(temp)
return
}
}
if (fileExists(ENVIRON["TRANS_DIR"] "/man/" Command ".1"))
system("man " parameterize(ENVIRON["TRANS_DIR"] "/man/" Command ".1") SUPERR)
else if (system("man " Command SUPERR))
print getHelp()
}
# Return a reference table of languages as a string.
# Parameters:
# displayName = "endonym" or "name"
function getReference(displayName,
####
code, col, cols, i, j, name, num, r, rows, saveSortedIn,
t1, t2) {
# number of language codes with stable support
num = 0
for (code in Locale)
if (Locale[code]["support"] != "unstable")
num++
rows = int(num / 3) + (num % 3 ? 1 : 0)
cols[0][0] = cols[1][0] = cols[2][0] = NULLSTR
i = 0
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = displayName == "endonym" ? "@ind_num_asc" :
"compName"
for (code in Locale) {
# show languages only with stable support
if (Locale[code]["support"] != "unstable") {
col = int(i / rows)
append(cols[col], code)
i++
}
}
PROCINFO["sorted_in"] = saveSortedIn
if (displayName == "endonym") {
r = "┌" replicate("─", 23) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS
for (i = 0; i < rows; i++) {
r = r "│"
for (j = 0; j < 3; j++) {
if (cols[j][i]) {
t1 = getDisplay(cols[j][i])
switch (cols[j][i]) { # fix rendered text width
case "he":
t1 = sprintf(" %-18s", t1)
break
case "ur":
t1 = sprintf(" %-17s", t1)
break
case "hi": case "gu": case "km": case "kn":
case "my": case "ne": case "pa": case "si":
case "ta": case "te": case "yi":
t1 = sprintf(" %-16s", t1)
break
case "yue":
t1 = sprintf(" %-13s", t1)
break
case "ja": case "ko":
t1 = sprintf(" %-12s", t1)
break
case "zh-CN": case "zh-TW":
t1 = sprintf(" %-11s", t1)
break
default:
if (length(t1) <= 15)
t1 = sprintf(" %-15s", t1)
}
switch (length(cols[j][i])) {
case 1: case 2: case 3: case 4:
t2 = sprintf("- %s │", ansi("bold", sprintf("%4s", cols[j][i])))
break
case 5:
t2 = sprintf("- %s│", ansi("bold", cols[j][i]))
break
case 6:
t2 = sprintf("-%s│", ansi("bold", cols[j][i]))
break
case 7:
t2 = sprintf("-%s", ansi("bold", cols[j][i]))
break
default:
t2 = ansi("bold", cols[j][i])
}
r = r t1 t2
} else
r = r sprintf("%23s│", NULLSTR)
}
r = r RS
}
r = r "└" replicate("─", 23) "┴" replicate("─", 23) "┴" replicate("─", 23) "┘"
} else {
r = "┌" replicate("─", 23) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS
for (i = 0; i < rows; i++) {
r = r "│"
for (j = 0; j < 3; j++) {
if (cols[j][i]) {
t1 = getName(cols[j][i])
if (length(t1) > 15)
t1 = substr(t1, 1, 12) "..."
t1 = sprintf(" %-15s", t1)
switch (length(cols[j][i])) {
case 1: case 2: case 3: case 4:
t2 = sprintf("- %s │", ansi("bold", sprintf("%4s", cols[j][i])))
break
case 5:
t2 = sprintf("- %s│", ansi("bold", cols[j][i]))
break
case 6:
t2 = sprintf("-%s│", ansi("bold", cols[j][i]))
break
case 7:
t2 = sprintf("-%s", ansi("bold", cols[j][i]))
break
default:
t2 = ansi("bold", cols[j][i])
}
r = r t1 t2
} else
r = r sprintf("%23s│", NULLSTR)
}
r = r RS
}
r = r "└" replicate("─", 23) "┴" replicate("─", 23) "┴" replicate("─", 23) "┘"
}
return r
}
# Return detailed information of languages as a string.
function getList(codes, code, i, r, saveSortedIn) {
r = NULLSTR
if (!isarray(codes))
r = getDetails(codes)
else if (anything(codes)) {
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in codes)
r = (r ? r RS prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])) RS \
: r) getDetails(codes[i])
PROCINFO["sorted_in"] = saveSortedIn
} else
r = getDetails(Option["hl"])
return r
}
translate-shell-0.9.6.11/include/Languages.awk 0000664 0000000 0000000 00000274210 13516335241 0021116 0 ustar 00root root 0000000 0000000 ####################################################################
# Languages.awk #
####################################################################
# Initialize all locales supported.
# Mostly ISO 639-1 codes, with a few ISO 639-3 codes.
# "family" : Language family (from Glottolog)
# "iso" : ISO 639-3 code
# "glotto" : Glottocode
# "script" : Writing system (ISO 15924 script code)
# See:
#
#
#
function initLocale() {
#1 Afrikaans
Locale["af"]["name"] = "Afrikaans"
Locale["af"]["endonym"] = "Afrikaans"
Locale["af"]["translations-of"] = "Vertalings van %s"
Locale["af"]["definitions-of"] = "Definisies van %s"
Locale["af"]["synonyms"] = "Sinonieme"
Locale["af"]["examples"] = "Voorbeelde"
Locale["af"]["see-also"] = "Sien ook"
Locale["af"]["family"] = "Indo-European"
Locale["af"]["iso"] = "afr"
Locale["af"]["glotto"] = "afri1274"
Locale["af"]["script"] = "Latn"
#2 Albanian
Locale["sq"]["name"] = "Albanian"
Locale["sq"]["endonym"] = "Shqip"
Locale["sq"]["translations-of"] = "Përkthimet e %s"
Locale["sq"]["definitions-of"] = "Përkufizime të %s"
Locale["sq"]["synonyms"] = "Sinonime"
Locale["sq"]["examples"] = "Shembuj"
Locale["sq"]["see-also"] = "Shihni gjithashtu"
Locale["sq"]["family"] = "Indo-European"
Locale["sq"]["iso"] = "sqi"
Locale["sq"]["glotto"] = "alba1267"
Locale["sq"]["script"] = "Latn"
#3 Amharic
Locale["am"]["name"] = "Amharic"
Locale["am"]["endonym"] = "አማርኛ"
Locale["am"]["translations-of"] = "የ %s ትርጉሞች"
Locale["am"]["definitions-of"] = "የ %s ቃላት ፍችዎች"
Locale["am"]["synonyms"] = "ተመሳሳይ ቃላት"
Locale["am"]["examples"] = "ምሳሌዎች"
Locale["am"]["see-also"] = "የሚከተለውንም ይመልከቱ"
Locale["am"]["family"] = "Afro-Asiatic"
Locale["am"]["iso"] = "amh"
Locale["am"]["glotto"] = "amha1245"
Locale["am"]["script"] = "Ethi"
#4 Arabic (Standard Arabic)
Locale["ar"]["name"] = "Arabic"
Locale["ar"]["endonym"] = "العربية"
Locale["ar"]["translations-of"] = "ترجمات %s"
Locale["ar"]["definitions-of"] = "تعريفات %s"
Locale["ar"]["synonyms"] = "مرادفات"
Locale["ar"]["examples"] = "أمثلة"
Locale["ar"]["see-also"] = "انظر أيضًا"
Locale["ar"]["family"] = "Afro-Asiatic"
Locale["ar"]["iso"] = "ara"
Locale["ar"]["glotto"] = "stan1318"
Locale["ar"]["script"] = "Arab"
Locale["ar"]["rtl"] = "true" # RTL language
#5 Armenian (Modern Armenian)
Locale["hy"]["name"] = "Armenian"
Locale["hy"]["endonym"] = "Հայերեն"
Locale["hy"]["translations-of"] = "%s-ի թարգմանությունները"
Locale["hy"]["definitions-of"] = "%s-ի սահմանումները"
Locale["hy"]["synonyms"] = "Հոմանիշներ"
Locale["hy"]["examples"] = "Օրինակներ"
Locale["hy"]["see-also"] = "Տես նաև"
Locale["hy"]["family"] = "Indo-European"
Locale["hy"]["iso"] = "hye"
Locale["hy"]["glotto"] = "nucl1235"
Locale["hy"]["script"] = "Armn"
#6 Azerbaijani (North Azerbaijani)
Locale["az"]["name"] = "Azerbaijani"
Locale["az"]["endonym"] = "Azərbaycanca"
Locale["az"]["translations-of"] = "%s sözünün tərcüməsi"
Locale["az"]["definitions-of"] = "%s sözünün tərifləri"
Locale["az"]["synonyms"] = "Sinonimlər"
Locale["az"]["examples"] = "Nümunələr"
Locale["az"]["see-also"] = "Həmçinin, baxın:"
Locale["az"]["family"] = "Turkic"
Locale["az"]["iso"] = "aze"
Locale["az"]["glotto"] = "nort2697"
Locale["az"]["script"] = "Latn"
#7 Basque
Locale["eu"]["name"] = "Basque"
Locale["eu"]["endonym"] = "Euskara"
Locale["eu"]["translations-of"] = "%s esapidearen itzulpena"
Locale["eu"]["definitions-of"] = "Honen definizioak: %s"
Locale["eu"]["synonyms"] = "Sinonimoak"
Locale["eu"]["examples"] = "Adibideak"
Locale["eu"]["see-also"] = "Ikusi hauek ere"
Locale["eu"]["family"] = "Language Isolate"
Locale["eu"]["iso"] = "eus"
Locale["eu"]["glotto"] = "basq1248"
Locale["eu"]["script"] = "Latn"
#8 Belarusian, Cyrillic alphabet
Locale["be"]["name"] = "Belarusian"
Locale["be"]["endonym"] = "беларуская"
Locale["be"]["translations-of"] = "Пераклады %s"
Locale["be"]["definitions-of"] = "Вызначэннi %s"
Locale["be"]["synonyms"] = "Сінонімы"
Locale["be"]["examples"] = "Прыклады"
Locale["be"]["see-also"] = "Гл. таксама"
Locale["be"]["family"] = "Indo-European"
Locale["be"]["iso"] = "bel"
Locale["be"]["glotto"] = "bela1254"
Locale["be"]["script"] = "Cyrl"
#9 Bengali
Locale["bn"]["name"] = "Bengali"
Locale["bn"]["endonym"] = "বাংলা"
Locale["bn"]["translations-of"] = "%s এর অনুবাদ"
Locale["bn"]["definitions-of"] = "%s এর সংজ্ঞা"
Locale["bn"]["synonyms"] = "প্রতিশব্দ"
Locale["bn"]["examples"] = "উদাহরণ"
Locale["bn"]["see-also"] = "আরো দেখুন"
Locale["bn"]["family"] = "Indo-European"
Locale["bn"]["iso"] = "ben"
Locale["bn"]["glotto"] = "beng1280"
Locale["bn"]["script"] = "Beng"
#10 Bosnian, Latin alphabet
Locale["bs"]["name"] = "Bosnian"
Locale["bs"]["endonym"] = "Bosanski"
Locale["bs"]["translations-of"] = "Prijevod za: %s"
Locale["bs"]["definitions-of"] = "Definicije za %s"
Locale["bs"]["synonyms"] = "Sinonimi"
Locale["bs"]["examples"] = "Primjeri"
Locale["bs"]["see-also"] = "Pogledajte i"
Locale["bs"]["family"] = "Indo-European"
Locale["bs"]["iso"] = "bos"
Locale["bs"]["glotto"] = "bosn1245"
Locale["bs"]["script"] = "Latn"
#11 Bulgarian
Locale["bg"]["name"] = "Bulgarian"
Locale["bg"]["endonym"] = "български"
Locale["bg"]["translations-of"] = "Преводи на %s"
Locale["bg"]["definitions-of"] = "Дефиниции за %s"
Locale["bg"]["synonyms"] = "Синоними"
Locale["bg"]["examples"] = "Примери"
Locale["bg"]["see-also"] = "Вижте също"
Locale["bg"]["family"] = "Indo-European"
Locale["bg"]["iso"] = "bul"
Locale["bg"]["glotto"] = "bulg1262"
Locale["bg"]["script"] = "Cyrl"
#12 Catalan (Standard Catalan)
Locale["ca"]["name"] = "Catalan"
Locale["ca"]["endonym"] = "Català"
Locale["ca"]["translations-of"] = "Traduccions per a %s"
Locale["ca"]["definitions-of"] = "Definicions de: %s"
Locale["ca"]["synonyms"] = "Sinònims"
Locale["ca"]["examples"] = "Exemples"
Locale["ca"]["see-also"] = "Vegeu també"
Locale["ca"]["family"] = "Indo-European"
Locale["ca"]["iso"] = "cat"
Locale["ca"]["glotto"] = "stan1289"
Locale["ca"]["script"] = "Latn"
#13 Cebuano
Locale["ceb"]["name"] = "Cebuano"
Locale["ceb"]["endonym"] = "Cebuano"
Locale["ceb"]["translations-of"] = "%s Mga Paghubad sa PULONG_O_HUGPONG SA PAMULONG"
Locale["ceb"]["definitions-of"] = "Mga kahulugan sa %s"
Locale["ceb"]["synonyms"] = "Mga Kapulong"
Locale["ceb"]["examples"] = "Mga pananglitan:"
Locale["ceb"]["see-also"] = "Kitaa pag-usab"
Locale["ceb"]["family"] = "Austronesian"
Locale["ceb"]["iso"] = "ceb"
Locale["ceb"]["glotto"] = "cebu1242"
Locale["ceb"]["script"] = "Latn"
#14 Chichewa
Locale["ny"]["name"] = "Chichewa"
Locale["ny"]["endonym"] = "Nyanja"
Locale["ny"]["translations-of"] = "Matanthauzidwe a %s"
Locale["ny"]["definitions-of"] = "Mamasulidwe a %s"
Locale["ny"]["synonyms"] = "Mau ofanana"
Locale["ny"]["examples"] = "Zitsanzo"
Locale["ny"]["see-also"] = "Onaninso"
Locale["ny"]["family"] = "Atlantic-Congo"
Locale["ny"]["iso"] = "nya"
Locale["ny"]["glotto"] = "nyan1308"
Locale["ny"]["script"] = "Latn"
#15a Chinese (Mandarin), Simplified
Locale["zh-CN"]["name"] = "Chinese Simplified"
Locale["zh-CN"]["endonym"] = "简体中文"
Locale["zh-CN"]["translations-of"] = "%s 的翻译"
Locale["zh-CN"]["definitions-of"] = "%s的定义"
Locale["zh-CN"]["synonyms"] = "同义词"
Locale["zh-CN"]["examples"] = "示例"
Locale["zh-CN"]["see-also"] = "另请参阅"
Locale["zh-CN"]["family"] = "Sino-Tibetan"
Locale["zh-CN"]["iso"] = "zho-CN"
Locale["zh-CN"]["glotto"] = "mand1415"
Locale["zh-CN"]["script"] = "Hans"
Locale["zh-CN"]["dictionary"] = "true" # has dictionary
#15b Chinese (Mandarin), Traditional
Locale["zh-TW"]["name"] = "Chinese Traditional"
Locale["zh-TW"]["endonym"] = "正體中文"
Locale["zh-TW"]["translations-of"] = "「%s」的翻譯"
Locale["zh-TW"]["definitions-of"] = "「%s」的定義"
Locale["zh-TW"]["synonyms"] = "同義詞"
Locale["zh-TW"]["examples"] = "例句"
Locale["zh-TW"]["see-also"] = "另請參閱"
Locale["zh-TW"]["family"] = "Sino-Tibetan"
Locale["zh-TW"]["iso"] = "zho-TW"
Locale["zh-TW"]["glotto"] = "mand1415"
Locale["zh-TW"]["script"] = "Hant"
Locale["zh-TW"]["dictionary"] = "true" # has dictionary
#16 Corsican
Locale["co"]["name"] = "Corsican"
Locale["co"]["endonym"] = "Corsu"
Locale["co"]["translations-of"] = "Traductions de %s"
Locale["co"]["definitions-of"] = "Définitions de %s"
Locale["co"]["synonyms"] = "Synonymes"
Locale["co"]["examples"] = "Exemples"
Locale["co"]["see-also"] = "Voir aussi"
Locale["co"]["family"] = "Indo-European"
Locale["co"]["iso"] = "cos"
Locale["co"]["glotto"] = "cors1242"
Locale["co"]["script"] = "Latn"
#17 Croatian
Locale["hr"]["name"] = "Croatian"
Locale["hr"]["endonym"] = "Hrvatski"
Locale["hr"]["translations-of"] = "Prijevodi riječi ili izraza %s"
Locale["hr"]["definitions-of"] = "Definicije riječi ili izraza %s"
Locale["hr"]["synonyms"] = "Sinonimi"
Locale["hr"]["examples"] = "Primjeri"
Locale["hr"]["see-also"] = "Također pogledajte"
Locale["hr"]["family"] = "Indo-European"
Locale["hr"]["iso"] = "hrv"
Locale["hr"]["glotto"] = "croa1245"
Locale["hr"]["script"] = "Latn"
#18 Czech
Locale["cs"]["name"] = "Czech"
Locale["cs"]["endonym"] = "Čeština"
Locale["cs"]["translations-of"] = "Překlad výrazu %s"
Locale["cs"]["definitions-of"] = "Definice výrazu %s"
Locale["cs"]["synonyms"] = "Synonyma"
Locale["cs"]["examples"] = "Příklady"
Locale["cs"]["see-also"] = "Viz také"
Locale["cs"]["family"] = "Indo-European"
Locale["cs"]["iso"] = "ces"
Locale["cs"]["glotto"] = "czec1258"
Locale["cs"]["script"] = "Latn"
#19 Danish
Locale["da"]["name"] = "Danish"
Locale["da"]["endonym"] = "Dansk"
Locale["da"]["translations-of"] = "Oversættelser af %s"
Locale["da"]["definitions-of"] = "Definitioner af %s"
Locale["da"]["synonyms"] = "Synonymer"
Locale["da"]["examples"] = "Eksempler"
Locale["da"]["see-also"] = "Se også"
Locale["da"]["family"] = "Indo-European"
Locale["da"]["iso"] = "dan"
Locale["da"]["glotto"] = "dani1285"
Locale["da"]["script"] = "Latn"
#20 Dutch
Locale["nl"]["name"] = "Dutch"
Locale["nl"]["endonym"] = "Nederlands"
Locale["nl"]["translations-of"] = "Vertalingen van %s"
Locale["nl"]["definitions-of"] = "Definities van %s"
Locale["nl"]["synonyms"] = "Synoniemen"
Locale["nl"]["examples"] = "Voorbeelden"
Locale["nl"]["see-also"] = "Zie ook"
Locale["nl"]["family"] = "Indo-European"
Locale["nl"]["iso"] = "nld"
Locale["nl"]["glotto"] = "dutc1256"
Locale["nl"]["script"] = "Latn"
Locale["nl"]["dictionary"] = "true" # has dictionary
#21 English (Standard English)
Locale["en"]["name"] = "English"
Locale["en"]["endonym"] = "English"
Locale["en"]["translations-of"] = "Translations of %s"
Locale["en"]["definitions-of"] = "Definitions of %s"
Locale["en"]["synonyms"] = "Synonyms"
Locale["en"]["examples"] = "Examples"
Locale["en"]["see-also"] = "See also"
Locale["en"]["family"] = "Indo-European"
Locale["en"]["iso"] = "eng"
Locale["en"]["glotto"] = "stan1293"
Locale["en"]["script"] = "Latn"
Locale["en"]["dictionary"] = "true" # has dictionary
#22 Esperanto
Locale["eo"]["name"] = "Esperanto"
Locale["eo"]["endonym"] = "Esperanto"
Locale["eo"]["translations-of"] = "Tradukoj de %s"
Locale["eo"]["definitions-of"] = "Difinoj de %s"
Locale["eo"]["synonyms"] = "Sinonimoj"
Locale["eo"]["examples"] = "Ekzemploj"
Locale["eo"]["see-also"] = "Vidu ankaŭ"
Locale["eo"]["family"] = "Artificial Language"
Locale["eo"]["iso"] = "epo"
Locale["eo"]["glotto"] = "espe1235"
Locale["eo"]["script"] = "Latn"
#23 Estonian
Locale["et"]["name"] = "Estonian"
Locale["et"]["endonym"] = "Eesti"
Locale["et"]["translations-of"] = "Sõna(de) %s tõlked"
Locale["et"]["definitions-of"] = "Sõna(de) %s definitsioonid"
Locale["et"]["synonyms"] = "Sünonüümid"
Locale["et"]["examples"] = "Näited"
Locale["et"]["see-also"] = "Vt ka"
Locale["et"]["family"] = "Uralic"
Locale["et"]["iso"] = "est"
Locale["et"]["glotto"] = "esto1258"
Locale["et"]["script"] = "Latn"
#24 Filipino / Tagalog
Locale["tl"]["name"] = "Filipino"
Locale["tl"]["endonym"] = "Tagalog"
Locale["tl"]["translations-of"] = "Mga pagsasalin ng %s"
Locale["tl"]["definitions-of"] = "Mga kahulugan ng %s"
Locale["tl"]["synonyms"] = "Mga Kasingkahulugan"
Locale["tl"]["examples"] = "Mga Halimbawa"
Locale["tl"]["see-also"] = "Tingnan rin ang"
Locale["tl"]["family"] = "Austronesian"
Locale["tl"]["iso"] = "tgl"
Locale["tl"]["glotto"] = "taga1270"
Locale["tl"]["script"] = "Latn"
#25 Finnish
Locale["fi"]["name"] = "Finnish"
Locale["fi"]["endonym"] = "Suomi"
Locale["fi"]["translations-of"] = "Käännökset tekstille %s"
Locale["fi"]["definitions-of"] = "Määritelmät kohteelle %s"
Locale["fi"]["synonyms"] = "Synonyymit"
Locale["fi"]["examples"] = "Esimerkkejä"
Locale["fi"]["see-also"] = "Katso myös"
Locale["fi"]["family"] = "Uralic"
Locale["fi"]["iso"] = "fin"
Locale["fi"]["glotto"] = "finn1318"
Locale["fi"]["script"] = "Latn"
#26 French (Standard French)
Locale["fr"]["name"] = "French"
Locale["fr"]["endonym"] = "Français"
Locale["fr"]["translations-of"] = "Traductions de %s"
Locale["fr"]["definitions-of"] = "Définitions de %s"
Locale["fr"]["synonyms"] = "Synonymes"
Locale["fr"]["examples"] = "Exemples"
Locale["fr"]["see-also"] = "Voir aussi"
Locale["fr"]["family"] = "Indo-European"
Locale["fr"]["iso"] = "fra"
Locale["fr"]["glotto"] = "stan1290"
Locale["fr"]["script"] = "Latn"
Locale["fr"]["dictionary"] = "true" # has dictionary
#27 Galician
Locale["gl"]["name"] = "Galician"
Locale["gl"]["endonym"] = "Galego"
Locale["gl"]["translations-of"] = "Traducións de %s"
Locale["gl"]["definitions-of"] = "Definicións de %s"
Locale["gl"]["synonyms"] = "Sinónimos"
Locale["gl"]["examples"] = "Exemplos"
Locale["gl"]["see-also"] = "Ver tamén"
Locale["gl"]["family"] = "Indo-European"
Locale["gl"]["iso"] = "glg"
Locale["gl"]["glotto"] = "gali1258"
Locale["gl"]["script"] = "Latn"
#28 Georgian (Modern Georgian)
Locale["ka"]["name"] = "Georgian"
Locale["ka"]["endonym"] = "ქართული"
Locale["ka"]["translations-of"] = "%s-ის თარგმანები"
Locale["ka"]["definitions-of"] = "%s-ის განსაზღვრებები"
Locale["ka"]["synonyms"] = "სინონიმები"
Locale["ka"]["examples"] = "მაგალითები"
Locale["ka"]["see-also"] = "ასევე იხილეთ"
Locale["ka"]["family"] = "Kartvelian"
Locale["ka"]["iso"] = "kat"
Locale["ka"]["glotto"] = "nucl1302"
Locale["ka"]["script"] = "Geor"
#29 German (Standard German)
Locale["de"]["name"] = "German"
Locale["de"]["endonym"] = "Deutsch"
Locale["de"]["translations-of"] = "Übersetzungen für %s"
Locale["de"]["definitions-of"] = "Definitionen von %s"
Locale["de"]["synonyms"] = "Synonyme"
Locale["de"]["examples"] = "Beispiele"
Locale["de"]["see-also"] = "Siehe auch"
Locale["de"]["family"] = "Indo-European"
Locale["de"]["iso"] = "deu"
Locale["de"]["glotto"] = "stan1295"
Locale["de"]["script"] = "Latn"
Locale["de"]["dictionary"] = "true" # has dictionary
#30 Greek (Modern Greek)
Locale["el"]["name"] = "Greek"
Locale["el"]["endonym"] = "Ελληνικά"
Locale["el"]["translations-of"] = "Μεταφράσεις του %s"
Locale["el"]["definitions-of"] = "Όρισμοί %s"
Locale["el"]["synonyms"] = "Συνώνυμα"
Locale["el"]["examples"] = "Παραδείγματα"
Locale["el"]["see-also"] = "Δείτε επίσης"
Locale["el"]["family"] = "Indo-European"
Locale["el"]["iso"] = "ell"
Locale["el"]["glotto"] = "mode1248"
Locale["el"]["script"] = "Grek"
#31 Gujarati
Locale["gu"]["name"] = "Gujarati"
Locale["gu"]["endonym"] = "ગુજરાતી"
Locale["gu"]["translations-of"] = "%s ના અનુવાદ"
Locale["gu"]["definitions-of"] = "%s ની વ્યાખ્યાઓ"
Locale["gu"]["synonyms"] = "સમાનાર્થી"
Locale["gu"]["examples"] = "ઉદાહરણો"
Locale["gu"]["see-also"] = "આ પણ જુઓ"
Locale["gu"]["family"] = "Indo-European"
Locale["gu"]["iso"] = "guj"
Locale["gu"]["glotto"] = "guja1252"
Locale["gu"]["script"] = "Gujr"
#32 Haitian Creole
Locale["ht"]["name"] = "Haitian Creole"
Locale["ht"]["endonym"] = "Kreyòl Ayisyen"
Locale["ht"]["translations-of"] = "Tradiksyon %s"
Locale["ht"]["definitions-of"] = "Definisyon nan %s"
Locale["ht"]["synonyms"] = "Sinonim"
Locale["ht"]["examples"] = "Egzanp:"
Locale["ht"]["see-also"] = "Wè tou"
Locale["ht"]["family"] = "Indo-European"
Locale["ht"]["iso"] = "hat"
Locale["ht"]["glotto"] = "hait1244"
Locale["ht"]["script"] = "Latn"
#33 Hawaiian
Locale["haw"]["name"] = "Hawaiian"
Locale["haw"]["endonym"] = "ʻŌlelo Hawaiʻi"
#Locale["haw"]["translations-of"]
#Locale["haw"]["definitions-of"]
#Locale["haw"]["synonyms"]
#Locale["haw"]["examples"]
#Locale["haw"]["see-also"]
Locale["haw"]["family"] = "Austronesian"
Locale["haw"]["iso"] = "haw"
Locale["haw"]["glotto"] = "hawa1245"
Locale["haw"]["script"] = "Latn"
#34 Hausa, Latin alphabet
Locale["ha"]["name"] = "Hausa"
Locale["ha"]["endonym"] = "Hausa"
Locale["ha"]["translations-of"] = "Fassarar %s"
Locale["ha"]["definitions-of"] = "Ma'anoni na %s"
Locale["ha"]["synonyms"] = "Masu kamancin ma'ana"
Locale["ha"]["examples"] = "Misalai"
Locale["ha"]["see-also"] = "Duba kuma"
Locale["ha"]["family"] = "Afro-Asiatic"
Locale["ha"]["iso"] = "hau"
Locale["ha"]["glotto"] = "haus1257"
Locale["ha"]["script"] = "Latn"
#35 Hebrew
Locale["he"]["name"] = "Hebrew"
Locale["he"]["endonym"] = "עִבְרִית"
Locale["he"]["translations-of"] = "תרגומים של %s"
Locale["he"]["definitions-of"] = "הגדרות של %s"
Locale["he"]["synonyms"] = "מילים נרדפות"
Locale["he"]["examples"] = "דוגמאות"
Locale["he"]["see-also"] = "ראה גם"
Locale["he"]["family"] = "Afro-Asiatic"
Locale["he"]["iso"] = "heb"
Locale["he"]["glotto"] = "hebr1245"
Locale["he"]["script"] = "Hebr"
Locale["he"]["rtl"] = "true" # RTL language
#36 Hindi
Locale["hi"]["name"] = "Hindi"
Locale["hi"]["endonym"] = "हिन्दी"
Locale["hi"]["translations-of"] = "%s के अनुवाद"
Locale["hi"]["definitions-of"] = "%s की परिभाषाएं"
Locale["hi"]["synonyms"] = "समानार्थी"
Locale["hi"]["examples"] = "उदाहरण"
Locale["hi"]["see-also"] = "यह भी देखें"
Locale["hi"]["family"] = "Indo-European"
Locale["hi"]["iso"] = "hin"
Locale["hi"]["glotto"] = "hind1269"
Locale["hi"]["script"] = "Deva"
#37 Hmong (First Vernacular Hmong)
Locale["hmn"]["name"] = "Hmong"
Locale["hmn"]["endonym"] = "Hmoob"
Locale["hmn"]["translations-of"] = "Lus txhais: %s"
#Locale["hmn"]["definitions-of"]
#Locale["hmn"]["synonyms"]
#Locale["hmn"]["examples"]
#Locale["hmn"]["see-also"]
Locale["hmn"]["family"] = "Hmong-Mien"
Locale["hmn"]["iso"] = "hmn"
Locale["hmn"]["glotto"] = "firs1234"
Locale["hmn"]["script"] = "Latn"
#38 Hungarian
Locale["hu"]["name"] = "Hungarian"
Locale["hu"]["endonym"] = "Magyar"
Locale["hu"]["translations-of"] = "%s fordításai"
Locale["hu"]["definitions-of"] = "%s jelentései"
Locale["hu"]["synonyms"] = "Szinonimák"
Locale["hu"]["examples"] = "Példák"
Locale["hu"]["see-also"] = "Lásd még"
Locale["hu"]["family"] = "Uralic"
Locale["hu"]["iso"] = "hun"
Locale["hu"]["glotto"] = "hung1274"
Locale["hu"]["script"] = "Latn"
#39 Icelandic
Locale["is"]["name"] = "Icelandic"
Locale["is"]["endonym"] = "Íslenska"
Locale["is"]["translations-of"] = "Þýðingar á %s"
Locale["is"]["definitions-of"] = "Skilgreiningar á"
Locale["is"]["synonyms"] = "Samheiti"
Locale["is"]["examples"] = "Dæmi"
Locale["is"]["see-also"] = "Sjá einnig"
Locale["is"]["family"] = "Indo-European"
Locale["is"]["iso"] = "isl"
Locale["is"]["glotto"] = "icel1247"
Locale["is"]["script"] = "Latn"
#40 Igbo
Locale["ig"]["name"] = "Igbo"
Locale["ig"]["endonym"] = "Igbo"
Locale["ig"]["translations-of"] = "Ntụgharị asụsụ nke %s"
Locale["ig"]["definitions-of"] = "Nkọwapụta nke %s"
Locale["ig"]["synonyms"] = "Okwu oyiri"
Locale["ig"]["examples"] = "Ọmụmaatụ"
Locale["ig"]["see-also"] = "Hụkwuo"
Locale["ig"]["family"] = "Atlantic-Congo"
Locale["ig"]["iso"] = "ibo"
Locale["ig"]["glotto"] = "nucl1417"
Locale["ig"]["script"] = "Latn"
#41 Indonesian
Locale["id"]["name"] = "Indonesian"
Locale["id"]["endonym"] = "Bahasa Indonesia"
Locale["id"]["translations-of"] = "Terjemahan dari %s"
Locale["id"]["definitions-of"] = "Definisi %s"
Locale["id"]["synonyms"] = "Sinonim"
Locale["id"]["examples"] = "Contoh"
Locale["id"]["see-also"] = "Lihat juga"
Locale["id"]["family"] = "Austronesian"
Locale["id"]["iso"] = "ind"
Locale["id"]["glotto"] = "indo1316"
Locale["id"]["script"] = "Latn"
#42 Irish
Locale["ga"]["name"] = "Irish"
Locale["ga"]["endonym"] = "Gaeilge"
Locale["ga"]["translations-of"] = "Aistriúcháin ar %s"
Locale["ga"]["definitions-of"] = "Sainmhínithe ar %s"
Locale["ga"]["synonyms"] = "Comhchiallaigh"
Locale["ga"]["examples"] = "Samplaí"
Locale["ga"]["see-also"] = "féach freisin"
Locale["ga"]["family"] = "Indo-European"
Locale["ga"]["iso"] = "gle"
Locale["ga"]["glotto"] = "iris1253"
Locale["ga"]["script"] = "Latn"
#43 Italian
Locale["it"]["name"] = "Italian"
Locale["it"]["endonym"] = "Italiano"
Locale["it"]["translations-of"] = "Traduzioni di %s"
Locale["it"]["definitions-of"] = "Definizioni di %s"
Locale["it"]["synonyms"] = "Sinonimi"
Locale["it"]["examples"] = "Esempi"
Locale["it"]["see-also"] = "Vedi anche"
Locale["it"]["family"] = "Indo-European"
Locale["it"]["iso"] = "ita"
Locale["it"]["glotto"] = "ital1282"
Locale["it"]["script"] = "Latn"
Locale["it"]["dictionary"] = "true" # has dictionary
#44 Japanese
Locale["ja"]["name"] = "Japanese"
Locale["ja"]["endonym"] = "日本語"
Locale["ja"]["translations-of"] = "「%s」の翻訳"
Locale["ja"]["definitions-of"] = "%s の定義"
Locale["ja"]["synonyms"] = "同義語"
Locale["ja"]["examples"] = "例"
Locale["ja"]["see-also"] = "関連項目"
Locale["ja"]["family"] = "Japonic"
Locale["ja"]["iso"] = "jpn"
Locale["ja"]["glotto"] = "nucl1643"
Locale["ja"]["script"] = "Jpan"
Locale["ja"]["dictionary"] = "true" # has dictionary
#45 Javanese, Latin alphabet
Locale["jv"]["name"] = "Javanese"
Locale["jv"]["endonym"] = "Basa Jawa"
Locale["jv"]["translations-of"] = "Terjemahan %s"
Locale["jv"]["definitions-of"] = "Arti %s"
Locale["jv"]["synonyms"] = "Sinonim"
Locale["jv"]["examples"] = "Conto"
Locale["jv"]["see-also"] = "Deleng uga"
Locale["jv"]["family"] = "Austronesian"
Locale["jv"]["iso"] = "jav"
Locale["jv"]["glotto"] = "java1254"
Locale["jv"]["script"] = "Latn"
#46 Kannada (Modern Kannada)
Locale["kn"]["name"] = "Kannada"
Locale["kn"]["endonym"] = "ಕನ್ನಡ"
Locale["kn"]["translations-of"] = "%s ನ ಅನುವಾದಗಳು"
Locale["kn"]["definitions-of"] = "%s ನ ವ್ಯಾಖ್ಯಾನಗಳು"
Locale["kn"]["synonyms"] = "ಸಮಾನಾರ್ಥಕಗಳು"
Locale["kn"]["examples"] = "ಉದಾಹರಣೆಗಳು"
Locale["kn"]["see-also"] = "ಇದನ್ನೂ ಗಮನಿಸಿ"
Locale["kn"]["family"] = "Dravidian"
Locale["kn"]["iso"] = "kan"
Locale["kn"]["glotto"] = "nucl1305"
Locale["kn"]["script"] = "Knda"
#47 Kazakh, Cyrillic alphabet
Locale["kk"]["name"] = "Kazakh"
Locale["kk"]["endonym"] = "Қазақ тілі"
Locale["kk"]["translations-of"] = "%s аудармалары"
Locale["kk"]["definitions-of"] = "%s анықтамалары"
Locale["kk"]["synonyms"] = "Синонимдер"
Locale["kk"]["examples"] = "Мысалдар"
Locale["kk"]["see-also"] = "Келесі тізімді де көріңіз:"
Locale["kk"]["family"] = "Turkic"
Locale["kk"]["iso"] = "kaz"
Locale["kk"]["glotto"] = "kaza1248"
Locale["kk"]["script"] = "Cyrl"
#48 Khmer (Central Khmer)
Locale["km"]["name"] = "Khmer"
Locale["km"]["endonym"] = "ភាសាខ្មែរ"
Locale["km"]["translations-of"] = "ការបកប្រែនៃ %s"
Locale["km"]["definitions-of"] = "និយមន័យនៃ %s"
Locale["km"]["synonyms"] = "សទិសន័យ"
Locale["km"]["examples"] = "ឧទាហរណ៍"
Locale["km"]["see-also"] = "មើលផងដែរ"
Locale["km"]["family"] = "Austroasiatic"
Locale["km"]["iso"] = "khm"
Locale["km"]["glotto"] = "cent1989"
Locale["km"]["script"] = "Khmr"
#49 Korean
Locale["ko"]["name"] = "Korean"
Locale["ko"]["endonym"] = "한국어"
Locale["ko"]["translations-of"] = "%s의 번역"
Locale["ko"]["definitions-of"] = "%s의 정의"
Locale["ko"]["synonyms"] = "동의어"
Locale["ko"]["examples"] = "예문"
Locale["ko"]["see-also"] = "참조"
Locale["ko"]["family"] = "Koreanic"
Locale["ko"]["iso"] = "kor"
Locale["ko"]["glotto"] = "kore1280"
Locale["ko"]["script"] = "Kore"
Locale["ko"]["dictionary"] = "true" # has dictionary
#50 Kurdish (Central Kurdish, Sorani), Latin alphabet
Locale["ku"]["name"] = "Kurdish"
Locale["ku"]["endonym"] = "Kurdî"
#Locale["ku"]["translations-of"]
#Locale["ku"]["definitions-of"]
#Locale["ku"]["synonyms"]
#Locale["ku"]["examples"]
#Locale["ku"]["see-also"]
Locale["ku"]["family"] = "Indo-European"
Locale["ku"]["iso"] = "kur"
Locale["ku"]["glotto"] = "kurd1259"
Locale["ku"]["script"] = "Latn"
#51 Kyrgyz
Locale["ky"]["name"] = "Kyrgyz"
Locale["ky"]["endonym"] = "Кыргызча"
Locale["ky"]["translations-of"] = "%s котормосу"
Locale["ky"]["definitions-of"] = "%s аныктамасы"
Locale["ky"]["synonyms"] = "Синонимдер"
Locale["ky"]["examples"] = "Мисалдар"
Locale["ky"]["see-also"] = "Дагы караңыз"
Locale["ky"]["family"] = "Turkic"
Locale["ky"]["iso"] = "kir"
Locale["ky"]["glotto"] = "kirg1245"
Locale["ky"]["script"] = "Cyrl"
#52 Lao
Locale["lo"]["name"] = "Lao"
Locale["lo"]["endonym"] = "ລາວ"
Locale["lo"]["translations-of"] = "ຄຳແປສຳລັບ %s"
Locale["lo"]["definitions-of"] = "ຄວາມໝາຍຂອງ %s"
Locale["lo"]["synonyms"] = "ຄຳທີ່ຄ້າຍກັນ %s"
Locale["lo"]["examples"] = "ຕົວຢ່າງ"
Locale["lo"]["see-also"] = "ເບິ່ງເພີ່ມເຕີມ"
Locale["lo"]["family"] = "Tai-Kadai"
Locale["lo"]["iso"] = "lao"
Locale["lo"]["glotto"] = "laoo1244"
Locale["lo"]["script"] = "Laoo"
#53 Latin
Locale["la"]["name"] = "Latin"
Locale["la"]["endonym"] = "Latina"
Locale["la"]["translations-of"] = "Versio de %s"
#Locale["la"]["definitions-of"]
#Locale["la"]["synonyms"]
#Locale["la"]["examples"]
#Locale["la"]["see-also"]
Locale["la"]["family"] = "Indo-European"
Locale["la"]["iso"] = "lat"
Locale["la"]["glotto"] = "lati1261"
Locale["la"]["script"] = "Latn"
#54 Latvian
Locale["lv"]["name"] = "Latvian"
Locale["lv"]["endonym"] = "Latviešu"
Locale["lv"]["translations-of"] = "%s tulkojumi"
Locale["lv"]["definitions-of"] = "%s definīcijas"
Locale["lv"]["synonyms"] = "Sinonīmi"
Locale["lv"]["examples"] = "Piemēri"
Locale["lv"]["see-also"] = "Skatiet arī"
Locale["lv"]["family"] = "Indo-European"
Locale["lv"]["iso"] = "lav"
Locale["lv"]["glotto"] = "latv1249"
Locale["lv"]["script"] = "Latn"
#55 Lithuanian
Locale["lt"]["name"] = "Lithuanian"
Locale["lt"]["endonym"] = "Lietuvių"
Locale["lt"]["translations-of"] = "„%s“ vertimai"
Locale["lt"]["definitions-of"] = "„%s“ apibrėžimai"
Locale["lt"]["synonyms"] = "Sinonimai"
Locale["lt"]["examples"] = "Pavyzdžiai"
Locale["lt"]["see-also"] = "Taip pat žiūrėkite"
Locale["lt"]["family"] = "Indo-European"
Locale["lt"]["iso"] = "lit"
Locale["lt"]["glotto"] = "lith1251"
Locale["lt"]["script"] = "Latn"
#56 Luxembourgish
Locale["lb"]["name"] = "Luxembourgish"
Locale["lb"]["endonym"] = "Lëtzebuergesch"
#Locale["lb"]["translations-of"]
#Locale["lb"]["definitions-of"]
#Locale["lb"]["synonyms"]
#Locale["lb"]["examples"]
#Locale["lb"]["see-also"]
Locale["lb"]["family"] = "Indo-European"
Locale["lb"]["iso"] = "ltz"
Locale["lb"]["glotto"] = "luxe1241"
Locale["lb"]["script"] = "Latn"
#57 Macedonian
Locale["mk"]["name"] = "Macedonian"
Locale["mk"]["endonym"] = "Македонски"
Locale["mk"]["translations-of"] = "Преводи на %s"
Locale["mk"]["definitions-of"] = "Дефиниции на %s"
Locale["mk"]["synonyms"] = "Синоними"
Locale["mk"]["examples"] = "Примери"
Locale["mk"]["see-also"] = "Види и"
Locale["mk"]["family"] = "Indo-European"
Locale["mk"]["iso"] = "mkd"
Locale["mk"]["glotto"] = "mace1250"
Locale["mk"]["script"] = "Cyrl"
#58 Malagasy (Plateau Malagasy)
Locale["mg"]["name"] = "Malagasy"
Locale["mg"]["endonym"] = "Malagasy"
Locale["mg"]["translations-of"] = "Dikan'ny %s"
Locale["mg"]["definitions-of"] = "Famaritana ny %s"
Locale["mg"]["synonyms"] = "Mitovy hevitra"
Locale["mg"]["examples"] = "Ohatra"
Locale["mg"]["see-also"] = "Jereo ihany koa"
Locale["mg"]["family"] = "Austronesian"
Locale["mg"]["iso"] = "mlg"
Locale["mg"]["glotto"] = "plat1254"
Locale["mg"]["script"] = "Latn"
#59 Malay (Standard Malay)
Locale["ms"]["name"] = "Malay"
Locale["ms"]["endonym"] = "Bahasa Melayu"
Locale["ms"]["translations-of"] = "Terjemahan %s"
Locale["ms"]["definitions-of"] = "Takrif %s"
Locale["ms"]["synonyms"] = "Sinonim"
Locale["ms"]["examples"] = "Contoh"
Locale["ms"]["see-also"] = "Lihat juga"
Locale["ms"]["family"] = "Austronesian"
Locale["ms"]["iso"] = "msa"
Locale["ms"]["glotto"] = "stan1306"
Locale["ms"]["script"] = "Latn"
#60 Malayalam
Locale["ml"]["name"] = "Malayalam"
Locale["ml"]["endonym"] = "മലയാളം"
Locale["ml"]["translations-of"] = "%s എന്നതിന്റെ വിവർത്തനങ്ങൾ"
Locale["ml"]["definitions-of"] = "%s എന്നതിന്റെ നിർവ്വചനങ്ങൾ"
Locale["ml"]["synonyms"] = "പര്യായങ്ങള്"
Locale["ml"]["examples"] = "ഉദാഹരണങ്ങള്"
Locale["ml"]["see-also"] = "ഇതും കാണുക"
Locale["ml"]["family"] = "Dravidian"
Locale["ml"]["iso"] = "mal"
Locale["ml"]["glotto"] = "mala1464"
Locale["ml"]["script"] = "Mlym"
#61 Maltese
Locale["mt"]["name"] = "Maltese"
Locale["mt"]["endonym"] = "Malti"
Locale["mt"]["translations-of"] = "Traduzzjonijiet ta' %s"
Locale["mt"]["definitions-of"] = "Definizzjonijiet ta' %s"
Locale["mt"]["synonyms"] = "Sinonimi"
Locale["mt"]["examples"] = "Eżempji"
Locale["mt"]["see-also"] = "Ara wkoll"
Locale["mt"]["family"] = "Afro-Asiatic"
Locale["mt"]["iso"] = "mlt"
Locale["mt"]["glotto"] = "malt1254"
Locale["mt"]["script"] = "Latn"
#62 Maori
Locale["mi"]["name"] = "Maori"
Locale["mi"]["endonym"] = "Māori"
Locale["mi"]["translations-of"] = "Ngā whakamāoritanga o %s"
Locale["mi"]["definitions-of"] = "Ngā whakamārama o %s"
Locale["mi"]["synonyms"] = "Ngā Kupu Taurite"
Locale["mi"]["examples"] = "Ngā Tauira:"
Locale["mi"]["see-also"] = "Tiro hoki:"
Locale["mi"]["family"] = "Austronesian"
Locale["mi"]["iso"] = "mri"
Locale["mi"]["glotto"] = "maor1246"
Locale["mi"]["script"] = "Latn"
#63 Marathi
Locale["mr"]["name"] = "Marathi"
Locale["mr"]["endonym"] = "मराठी"
Locale["mr"]["translations-of"] = "%s ची भाषांतरे"
Locale["mr"]["definitions-of"] = "%s च्या व्याख्या"
Locale["mr"]["synonyms"] = "समानार्थी शब्द"
Locale["mr"]["examples"] = "उदाहरणे"
Locale["mr"]["see-also"] = "हे देखील पहा"
Locale["mr"]["family"] = "Indo-European"
Locale["mr"]["iso"] = "mar"
Locale["mr"]["glotto"] = "mara1378"
Locale["mr"]["script"] = "Deva"
#64 Mongolian, Cyrillic alphabet
Locale["mn"]["name"] = "Mongolian"
Locale["mn"]["endonym"] = "Монгол"
Locale["mn"]["translations-of"] = "%s-н орчуулга"
Locale["mn"]["definitions-of"] = "%s үгийн тодорхойлолт"
Locale["mn"]["synonyms"] = "Ойролцоо утгатай"
Locale["mn"]["examples"] = "Жишээнүүд"
Locale["mn"]["see-also"] = "Мөн харах"
Locale["mn"]["family"] = "Mongolic"
Locale["mn"]["iso"] = "mon"
Locale["mn"]["glotto"] = "mong1331"
Locale["mn"]["script"] = "Cyrl"
#65 Myanmar / Burmese
Locale["my"]["name"] = "Myanmar"
Locale["my"]["endonym"] = "မြန်မာစာ"
Locale["my"]["translations-of"] = "%s၏ ဘာသာပြန်ဆိုချက်များ"
Locale["my"]["definitions-of"] = "%s၏ အနက်ဖွင့်ဆိုချက်များ"
Locale["my"]["synonyms"] = "ကြောင်းတူသံကွဲများ"
Locale["my"]["examples"] = "ဥပမာ"
Locale["my"]["see-also"] = "ဖော်ပြပါများကိုလဲ ကြည့်ပါ"
Locale["my"]["family"] = "Sino-Tibetan"
Locale["my"]["iso"] = "mya"
Locale["my"]["glotto"] = "nucl1310"
Locale["my"]["script"] = "Mymr"
#66 Nepali
Locale["ne"]["name"] = "Nepali"
Locale["ne"]["endonym"] = "नेपाली"
Locale["ne"]["translations-of"] = "%sका अनुवाद"
Locale["ne"]["definitions-of"] = "%sको परिभाषा"
Locale["ne"]["synonyms"] = "समानार्थीहरू"
Locale["ne"]["examples"] = "उदाहरणहरु"
Locale["ne"]["see-also"] = "यो पनि हेर्नुहोस्"
Locale["ne"]["family"] = "Indo-European"
Locale["ne"]["iso"] = "nep"
Locale["ne"]["glotto"] = "nepa1254"
Locale["ne"]["script"] = "Deva"
#67 Norwegian
Locale["no"]["name"] = "Norwegian"
Locale["no"]["endonym"] = "Norsk"
Locale["no"]["translations-of"] = "Oversettelser av %s"
Locale["no"]["definitions-of"] = "Definisjoner av %s"
Locale["no"]["synonyms"] = "Synonymer"
Locale["no"]["examples"] = "Eksempler"
Locale["no"]["see-also"] = "Se også"
Locale["no"]["family"] = "Indo-European"
Locale["no"]["iso"] = "nor"
Locale["no"]["glotto"] = "norw1258"
Locale["no"]["script"] = "Latn"
#68 Pashto
Locale["ps"]["name"] = "Pashto"
Locale["ps"]["endonym"] = "پښتو"
Locale["ps"]["translations-of"] = "د %sژباړې"
Locale["ps"]["definitions-of"] = "د%s تعریفونه"
Locale["ps"]["synonyms"] = "مترادف لغتونه"
Locale["ps"]["examples"] = "بېلګې"
Locale["ps"]["see-also"] = "دا هم ووینئ"
Locale["ps"]["family"] = "Indo-European"
Locale["ps"]["iso"] = "pus"
Locale["ps"]["glotto"] = "pash1269"
Locale["ps"]["script"] = "Arab"
Locale["ps"]["rtl"] = "true" # RTL language
#69 Persian (Western Farsi)
Locale["fa"]["name"] = "Persian"
Locale["fa"]["endonym"] = "فارسی"
Locale["fa"]["translations-of"] = "ترجمههای %s"
Locale["fa"]["definitions-of"] = "تعریفهای %s"
Locale["fa"]["synonyms"] = "مترادفها"
Locale["fa"]["examples"] = "مثالها"
Locale["fa"]["see-also"] = "همچنین مراجعه کنید به"
Locale["fa"]["family"] = "Indo-European"
Locale["fa"]["iso"] = "fas"
Locale["fa"]["glotto"] = "west2369"
Locale["fa"]["script"] = "Arab"
Locale["fa"]["rtl"] = "true" # RTL language
#70 Polish
Locale["pl"]["name"] = "Polish"
Locale["pl"]["endonym"] = "Polski"
Locale["pl"]["translations-of"] = "Tłumaczenia %s"
Locale["pl"]["definitions-of"] = "%s – definicje"
Locale["pl"]["synonyms"] = "Synonimy"
Locale["pl"]["examples"] = "Przykłady"
Locale["pl"]["see-also"] = "Zobacz też"
Locale["pl"]["family"] = "Indo-European"
Locale["pl"]["iso"] = "pol"
Locale["pl"]["glotto"] = "poli1260"
Locale["pl"]["script"] = "Latn"
#71 Portuguese
Locale["pt"]["name"] = "Portuguese"
Locale["pt"]["endonym"] = "Português"
Locale["pt"]["translations-of"] = "Traduções de %s"
Locale["pt"]["definitions-of"] = "Definições de %s"
Locale["pt"]["synonyms"] = "Sinônimos"
Locale["pt"]["examples"] = "Exemplos"
Locale["pt"]["see-also"] = "Veja também"
Locale["pt"]["family"] = "Indo-European"
Locale["pt"]["iso"] = "por"
Locale["pt"]["glotto"] = "port1283"
Locale["pt"]["script"] = "Latn"
Locale["pt"]["dictionary"] = "true" # has dictionary
#72 Punjabi, Gurmukhī alphabet
Locale["pa"]["name"] = "Punjabi"
Locale["pa"]["endonym"] = "ਪੰਜਾਬੀ"
Locale["pa"]["translations-of"] = "ਦੇ ਅਨੁਵਾਦ%s"
Locale["pa"]["definitions-of"] = "ਦੀਆਂ ਪਰਿਭਾਸ਼ਾ %s"
Locale["pa"]["synonyms"] = "ਸਮਾਨਾਰਥਕ ਸ਼ਬਦ"
Locale["pa"]["examples"] = "ਉਦਾਹਰਣਾਂ"
Locale["pa"]["see-also"] = "ਇਹ ਵੀ ਵੇਖੋ"
Locale["pa"]["family"] = "Indo-European"
Locale["pa"]["iso"] = "pan"
Locale["pa"]["glotto"] = "panj1256"
Locale["pa"]["script"] = "Guru"
#73 Romanian
Locale["ro"]["name"] = "Romanian"
Locale["ro"]["endonym"] = "Română"
Locale["ro"]["translations-of"] = "Traduceri pentru %s"
Locale["ro"]["definitions-of"] = "Definiții pentru %s"
Locale["ro"]["synonyms"] = "Sinonime"
Locale["ro"]["examples"] = "Exemple"
Locale["ro"]["see-also"] = "Vedeți și"
Locale["ro"]["family"] = "Indo-European"
Locale["ro"]["iso"] = "ron"
Locale["ro"]["glotto"] = "roma1327"
Locale["ro"]["script"] = "Latn"
#74 Russian
Locale["ru"]["name"] = "Russian"
Locale["ru"]["endonym"] = "Русский"
Locale["ru"]["translations-of"] = "%s: варианты перевода"
Locale["ru"]["definitions-of"] = "%s – определения"
Locale["ru"]["synonyms"] = "Синонимы"
Locale["ru"]["examples"] = "Примеры"
Locale["ru"]["see-also"] = "Похожие слова"
Locale["ru"]["family"] = "Indo-European"
Locale["ru"]["iso"] = "rus"
Locale["ru"]["glotto"] = "russ1263"
Locale["ru"]["script"] = "Cyrl"
Locale["ru"]["dictionary"] = "true" # has dictionary
#75 Samoan
Locale["sm"]["name"] = "Samoan"
Locale["sm"]["endonym"] = "Gagana Sāmoa"
#Locale["sm"]["translations-of"]
#Locale["sm"]["definitions-of"]
#Locale["sm"]["synonyms"]
#Locale["sm"]["examples"]
#Locale["sm"]["see-also"]
Locale["sm"]["family"] = "Austronesian"
Locale["sm"]["iso"] = "smo"
Locale["sm"]["glotto"] = "samo1305"
Locale["sm"]["script"] = "Latn"
#76 Scots Gaelic
Locale["gd"]["name"] = "Scots Gaelic"
Locale["gd"]["endonym"] = "Gàidhlig"
Locale["gd"]["translations-of"] = "Eadar-theangachadh airson %s"
Locale["gd"]["definitions-of"] = "Deifiniseanan airson %s"
Locale["gd"]["synonyms"] = "Co-fhaclan"
Locale["gd"]["examples"] = "Buill-eisimpleir"
Locale["gd"]["see-also"] = "Faic na leanas cuideachd"
Locale["gd"]["family"] = "Indo-European"
Locale["gd"]["iso"] = "gla"
Locale["gd"]["glotto"] = "scot1245"
Locale["gd"]["script"] = "Latn"
#77a Serbian, Cyrillic alphabet
Locale["sr-Cyrl"]["name"] = "Serbian (Cyrillic)"
Locale["sr-Cyrl"]["endonym"] = "српски"
Locale["sr-Cyrl"]["translations-of"] = "Преводи за „%s“"
Locale["sr-Cyrl"]["definitions-of"] = "Дефиниције за %s"
Locale["sr-Cyrl"]["synonyms"] = "Синоними"
Locale["sr-Cyrl"]["examples"] = "Примери"
Locale["sr-Cyrl"]["see-also"] = "Погледајте такође"
Locale["sr-Cyrl"]["family"] = "Indo-European"
Locale["sr-Cyrl"]["iso"] = "srp-Cyrl"
Locale["sr-Cyrl"]["glotto"] = "serb1264"
Locale["sr-Cyrl"]["script"] = "Cyrl"
#77b Serbian, Latin alphabet
Locale["sr-Latn"]["name"] = "Serbian (Latin)"
Locale["sr-Latn"]["endonym"] = "srpski"
Locale["sr-Latn"]["translations-of"] = "Prevodi za „%s“"
Locale["sr-Latn"]["definitions-of"] = "Definicije za %s"
Locale["sr-Latn"]["synonyms"] = "Sinonimi"
Locale["sr-Latn"]["examples"] = "Primeri"
Locale["sr-Latn"]["see-also"] = "Pogledajte takođe"
Locale["sr-Latn"]["family"] = "Indo-European"
Locale["sr-Latn"]["iso"] = "srp-Latn"
Locale["sr-Latn"]["glotto"] = "serb1264"
Locale["sr-Latn"]["script"] = "Latn"
#78 Sesotho (Southern Sotho)
Locale["st"]["name"] = "Sesotho"
Locale["st"]["endonym"] = "Sesotho"
Locale["st"]["translations-of"] = "Liphetolelo tsa %s"
Locale["st"]["definitions-of"] = "Meelelo ea %s"
Locale["st"]["synonyms"] = "Mantsoe a tšoanang ka moelelo"
Locale["st"]["examples"] = "Mehlala"
Locale["st"]["see-also"] = "Bona hape"
Locale["st"]["family"] = "Atlantic-Congo"
Locale["st"]["iso"] = "sot"
Locale["st"]["glotto"] = "sout2807"
Locale["st"]["script"] = "Latn"
#79 Shona
Locale["sn"]["name"] = "Shona"
Locale["sn"]["endonym"] = "chiShona"
Locale["sn"]["translations-of"] = "Shanduro dze %s"
Locale["sn"]["definitions-of"] = "Zvinoreva %s"
Locale["sn"]["synonyms"] = "Mashoko anoreva zvakafana nemamwe"
Locale["sn"]["examples"] = "Mienzaniso"
Locale["sn"]["see-also"] = "Onawo"
Locale["sn"]["family"] = "Atlantic-Congo"
Locale["sn"]["iso"] = "sna"
Locale["sn"]["glotto"] = "core1255"
Locale["sn"]["script"] = "Latn"
#80 Sindhi
Locale["sd"]["name"] = "Sindhi"
Locale["sd"]["endonym"] = "سنڌي"
Locale["sd"]["translations-of"] = "%s جو ترجمو"
Locale["sd"]["definitions-of"] = "%s جون وصفون"
Locale["sd"]["synonyms"] = "هم معني"
Locale["sd"]["examples"] = "مثالون"
Locale["sd"]["see-also"] = "به ڏسو"
Locale["sd"]["family"] = "Indo-European"
Locale["sd"]["iso"] = "snd"
Locale["sd"]["glotto"] = "sind1272"
Locale["sd"]["script"] = "Arab"
Locale["sd"]["rtl"] = "true" # RTL language
#81 Sinhala
Locale["si"]["name"] = "Sinhala"
Locale["si"]["endonym"] = "සිංහල"
Locale["si"]["translations-of"] = "%s හි පරිවර්තන"
Locale["si"]["definitions-of"] = "%s හි නිර්වචන"
Locale["si"]["synonyms"] = "සමානාර්ථ පද"
Locale["si"]["examples"] = "උදාහරණ"
Locale["si"]["see-also"] = "මෙයත් බලන්න"
Locale["si"]["family"] = "Indo-European"
Locale["si"]["iso"] = "sin"
Locale["si"]["glotto"] = "sinh1246"
Locale["si"]["script"] = "Sinh"
#82 Slovak
Locale["sk"]["name"] = "Slovak"
Locale["sk"]["endonym"] = "Slovenčina"
Locale["sk"]["translations-of"] = "Preklady výrazu: %s"
Locale["sk"]["definitions-of"] = "Definície výrazu %s"
Locale["sk"]["synonyms"] = "Synonymá"
Locale["sk"]["examples"] = "Príklady"
Locale["sk"]["see-also"] = "Pozrite tiež"
Locale["sk"]["family"] = "Indo-European"
Locale["sk"]["iso"] = "slk"
Locale["sk"]["glotto"] = "slov1269"
Locale["sk"]["script"] = "Latn"
#83 Slovenian / Slovene
Locale["sl"]["name"] = "Slovenian"
Locale["sl"]["endonym"] = "Slovenščina"
Locale["sl"]["translations-of"] = "Prevodi za %s"
Locale["sl"]["definitions-of"] = "Razlage za %s"
Locale["sl"]["synonyms"] = "Sopomenke"
Locale["sl"]["examples"] = "Primeri"
Locale["sl"]["see-also"] = "Glejte tudi"
Locale["sl"]["family"] = "Indo-European"
Locale["sl"]["iso"] = "slv"
Locale["sl"]["glotto"] = "slov1268"
Locale["sl"]["script"] = "Latn"
#84 Somali
Locale["so"]["name"] = "Somali"
Locale["so"]["endonym"] = "Soomaali"
Locale["so"]["translations-of"] = "Turjumaada %s"
Locale["so"]["definitions-of"] = "Qeexitaannada %s"
Locale["so"]["synonyms"] = "La micne ah"
Locale["so"]["examples"] = "Tusaalooyin"
Locale["so"]["see-also"] = "Sidoo kale eeg"
Locale["so"]["family"] = "Afro-Asiatic"
Locale["so"]["iso"] = "som"
Locale["so"]["glotto"] = "soma1255"
Locale["so"]["script"] = "Latn"
#85 Spanish
Locale["es"]["name"] = "Spanish"
Locale["es"]["endonym"] = "Español"
Locale["es"]["translations-of"] = "Traducciones de %s"
Locale["es"]["definitions-of"] = "Definiciones de %s"
Locale["es"]["synonyms"] = "Sinónimos"
Locale["es"]["examples"] = "Ejemplos"
Locale["es"]["see-also"] = "Ver también"
Locale["es"]["family"] = "Indo-European"
Locale["es"]["iso"] = "spa"
Locale["es"]["glotto"] = "stan1288"
Locale["es"]["script"] = "Latn"
Locale["es"]["dictionary"] = "true" # has dictionary
#86 Sundanese, Latin alphabet
Locale["su"]["name"] = "Sundanese"
Locale["su"]["endonym"] = "Basa Sunda"
Locale["su"]["translations-of"] = "Tarjamahan tina %s"
Locale["su"]["definitions-of"] = "Panjelasan tina %s"
Locale["su"]["synonyms"] = "Sinonim"
Locale["su"]["examples"] = "Conto"
Locale["su"]["see-also"] = "Tingali ogé"
Locale["su"]["family"] = "Austronesian"
Locale["su"]["iso"] = "sun"
Locale["su"]["glotto"] = "sund1252"
Locale["su"]["script"] = "Latn"
#87 Swahili
Locale["sw"]["name"] = "Swahili"
Locale["sw"]["endonym"] = "Kiswahili"
Locale["sw"]["translations-of"] = "Tafsiri ya %s"
Locale["sw"]["definitions-of"] = "Ufafanuzi wa %s"
Locale["sw"]["synonyms"] = "Visawe"
Locale["sw"]["examples"] = "Mifano"
Locale["sw"]["see-also"] = "Angalia pia"
Locale["sw"]["family"] = "Atlantic-Congo"
Locale["sw"]["iso"] = "swa"
Locale["sw"]["glotto"] = "swah1253"
Locale["sw"]["script"] = "Latn"
#88 Swedish
Locale["sv"]["name"] = "Swedish"
Locale["sv"]["endonym"] = "Svenska"
Locale["sv"]["translations-of"] = "Översättningar av %s"
Locale["sv"]["definitions-of"] = "Definitioner av %s"
Locale["sv"]["synonyms"] = "Synonymer"
Locale["sv"]["examples"] = "Exempel"
Locale["sv"]["see-also"] = "Se även"
Locale["sv"]["family"] = "Indo-European"
Locale["sv"]["iso"] = "swe"
Locale["sv"]["glotto"] = "swed1254"
Locale["sv"]["script"] = "Latn"
#89 Tajik, Cyrillic alphabet
Locale["tg"]["name"] = "Tajik"
Locale["tg"]["endonym"] = "Тоҷикӣ"
Locale["tg"]["translations-of"] = "Тарҷумаҳои %s"
Locale["tg"]["definitions-of"] = "Таърифҳои %s"
Locale["tg"]["synonyms"] = "Муродифҳо"
Locale["tg"]["examples"] = "Намунаҳо:"
Locale["tg"]["see-also"] = "Ҳамчунин Бинед"
Locale["tg"]["family"] = "Indo-European"
Locale["tg"]["iso"] = "tgk"
Locale["tg"]["glotto"] = "taji1245"
Locale["tg"]["script"] = "Cyrl"
#90 Tamil
Locale["ta"]["name"] = "Tamil"
Locale["ta"]["endonym"] = "தமிழ்"
Locale["ta"]["translations-of"] = "%s இன் மொழிபெயர்ப்புகள்"
Locale["ta"]["definitions-of"] = "%s இன் வரையறைகள்"
Locale["ta"]["synonyms"] = "இணைச்சொற்கள்"
Locale["ta"]["examples"] = "எடுத்துக்காட்டுகள்"
Locale["ta"]["see-also"] = "இதையும் காண்க"
Locale["ta"]["family"] = "Dravidian"
Locale["ta"]["iso"] = "tam"
Locale["ta"]["glotto"] = "tami1289"
Locale["ta"]["script"] = "Taml"
#91 Telugu
Locale["te"]["name"] = "Telugu"
Locale["te"]["endonym"] = "తెలుగు"
Locale["te"]["translations-of"] = "%s యొక్క అనువాదాలు"
Locale["te"]["definitions-of"] = "%s యొక్క నిర్వచనాలు"
Locale["te"]["synonyms"] = "పర్యాయపదాలు"
Locale["te"]["examples"] = "ఉదాహరణలు"
Locale["te"]["see-also"] = "వీటిని కూడా చూడండి"
Locale["te"]["family"] = "Dravidian"
Locale["te"]["iso"] = "tel"
Locale["te"]["glotto"] = "telu1262"
Locale["te"]["script"] = "Telu"
#92 Thai
Locale["th"]["name"] = "Thai"
Locale["th"]["endonym"] = "ไทย"
Locale["th"]["translations-of"] = "คำแปลของ %s"
Locale["th"]["definitions-of"] = "คำจำกัดความของ %s"
Locale["th"]["synonyms"] = "คำพ้องความหมาย"
Locale["th"]["examples"] = "ตัวอย่าง"
Locale["th"]["see-also"] = "ดูเพิ่มเติม"
Locale["th"]["family"] = "Tai-Kadai"
Locale["th"]["iso"] = "tha"
Locale["th"]["glotto"] = "thai1261"
Locale["th"]["script"] = "Thai"
#93 Turkish
Locale["tr"]["name"] = "Turkish"
Locale["tr"]["endonym"] = "Türkçe"
Locale["tr"]["translations-of"] = "%s çevirileri"
Locale["tr"]["definitions-of"] = "%s için tanımlar"
Locale["tr"]["synonyms"] = "Eş anlamlılar"
Locale["tr"]["examples"] = "Örnekler"
Locale["tr"]["see-also"] = "Ayrıca bkz."
Locale["tr"]["family"] = "Turkic"
Locale["tr"]["iso"] = "tur"
Locale["tr"]["glotto"] = "nucl1301"
Locale["tr"]["script"] = "Latn"
#94 Ukrainian
Locale["uk"]["name"] = "Ukrainian"
Locale["uk"]["endonym"] = "Українська"
Locale["uk"]["translations-of"] = "Переклади слова або виразу \"%s\""
Locale["uk"]["definitions-of"] = "\"%s\" – визначення"
Locale["uk"]["synonyms"] = "Синоніми"
Locale["uk"]["examples"] = "Приклади"
Locale["uk"]["see-also"] = "Дивіться також"
Locale["uk"]["family"] = "Indo-European"
Locale["uk"]["iso"] = "ukr"
Locale["uk"]["glotto"] = "ukra1253"
Locale["uk"]["script"] = "Cyrl"
#95 Urdu
Locale["ur"]["name"] = "Urdu"
Locale["ur"]["endonym"] = "اُردُو"
Locale["ur"]["translations-of"] = "کے ترجمے %s"
Locale["ur"]["definitions-of"] = "کی تعریفات %s"
Locale["ur"]["synonyms"] = "مترادفات"
Locale["ur"]["examples"] = "مثالیں"
Locale["ur"]["see-also"] = "نیز دیکھیں"
Locale["ur"]["family"] = "Indo-European"
Locale["ur"]["iso"] = "urd"
Locale["ur"]["glotto"] = "urdu1245"
Locale["ur"]["script"] = "Arab"
Locale["ur"]["rtl"] = "true" # RTL language
#96 Uzbek, Latin alphabet
Locale["uz"]["name"] = "Uzbek"
Locale["uz"]["endonym"] = "Oʻzbek tili"
Locale["uz"]["translations-of"] = "%s: tarjima variantlari"
Locale["uz"]["definitions-of"] = "%s – ta’riflar"
Locale["uz"]["synonyms"] = "Sinonimlar"
Locale["uz"]["examples"] = "Namunalar"
Locale["uz"]["see-also"] = "O‘xshash so‘zlar"
Locale["uz"]["family"] = "Turkic"
Locale["uz"]["iso"] = "uzb"
Locale["uz"]["glotto"] = "uzbe1247"
Locale["uz"]["script"] = "Latn"
#97 Vietnamese
Locale["vi"]["name"] = "Vietnamese"
Locale["vi"]["endonym"] = "Tiếng Việt"
Locale["vi"]["translations-of"] = "Bản dịch của %s"
Locale["vi"]["definitions-of"] = "Nghĩa của %s"
Locale["vi"]["synonyms"] = "Từ đồng nghĩa"
Locale["vi"]["examples"] = "Ví dụ"
Locale["vi"]["see-also"] = "Xem thêm"
Locale["vi"]["family"] = "Austroasiatic"
Locale["vi"]["iso"] = "vie"
Locale["vi"]["glotto"] = "viet1252"
Locale["vi"]["script"] = "Latn"
#98 Welsh
Locale["cy"]["name"] = "Welsh"
Locale["cy"]["endonym"] = "Cymraeg"
Locale["cy"]["translations-of"] = "Cyfieithiadau %s"
Locale["cy"]["definitions-of"] = "Diffiniadau %s"
Locale["cy"]["synonyms"] = "Cyfystyron"
Locale["cy"]["examples"] = "Enghreifftiau"
Locale["cy"]["see-also"] = "Gweler hefyd"
Locale["cy"]["family"] = "Indo-European"
Locale["cy"]["iso"] = "cym"
Locale["cy"]["glotto"] = "wels1247"
Locale["cy"]["script"] = "Latn"
#99 West Frisian
Locale["fy"]["name"] = "Frisian"
Locale["fy"]["endonym"] = "Frysk"
Locale["fy"]["translations-of"] = "Oersettings fan %s"
Locale["fy"]["definitions-of"] = "Definysjes fan %s"
Locale["fy"]["synonyms"] = "Synonimen"
Locale["fy"]["examples"] = "Foarbylden"
Locale["fy"]["see-also"] = "Sjoch ek"
Locale["fy"]["family"] = "Indo-European"
Locale["fy"]["iso"] = "fry"
Locale["fy"]["glotto"] = "west2354"
Locale["fy"]["script"] = "Latn"
#100 Xhosa
Locale["xh"]["name"] = "Xhosa"
Locale["xh"]["endonym"] = "isiXhosa"
Locale["xh"]["translations-of"] = "Iinguqulelo zika-%s"
Locale["xh"]["definitions-of"] = "Iingcaciso zika-%s"
Locale["xh"]["synonyms"] = "Izithethantonye"
Locale["xh"]["examples"] = "Imizekelo"
Locale["xh"]["see-also"] = "Kwakhona bona"
Locale["xh"]["family"] = "Atlantic-Congo"
Locale["xh"]["iso"] = "xho"
Locale["xh"]["glotto"] = "xhos1239"
Locale["xh"]["script"] = "Latn"
#101 Yiddish
Locale["yi"]["name"] = "Yiddish"
Locale["yi"]["endonym"] = "ייִדיש"
Locale["yi"]["translations-of"] = "איבערזעצונגען פון %s"
Locale["yi"]["definitions-of"] = "דפיניציונען %s"
Locale["yi"]["synonyms"] = "סינאָנימען"
Locale["yi"]["examples"] = "ביישפילע"
Locale["yi"]["see-also"] = "זייען אויך"
Locale["yi"]["family"] = "Indo-European"
Locale["yi"]["iso"] = "yid"
Locale["yi"]["glotto"] = "yidd1255"
Locale["yi"]["script"] = "Hebr"
Locale["yi"]["rtl"] = "true" # RTL language
#102 Yoruba
Locale["yo"]["name"] = "Yoruba"
Locale["yo"]["endonym"] = "Yorùbá"
Locale["yo"]["translations-of"] = "Awọn itumọ ti %s"
Locale["yo"]["definitions-of"] = "Awọn itumọ ti %s"
Locale["yo"]["synonyms"] = "Awọn ọrọ onitumọ"
Locale["yo"]["examples"] = "Awọn apẹrẹ"
Locale["yo"]["see-also"] = "Tun wo"
Locale["yo"]["family"] = "Atlantic-Congo"
Locale["yo"]["iso"] = "yor"
Locale["yo"]["glotto"] = "yoru1245"
Locale["yo"]["script"] = "Latn"
#103 Zulu
Locale["zu"]["name"] = "Zulu"
Locale["zu"]["endonym"] = "isiZulu"
Locale["zu"]["translations-of"] = "Ukuhumusha i-%s"
Locale["zu"]["definitions-of"] = "Izincazelo ze-%s"
Locale["zu"]["synonyms"] = "Amagama afanayo"
Locale["zu"]["examples"] = "Izibonelo"
Locale["zu"]["see-also"] = "Bheka futhi"
Locale["zu"]["family"] = "Atlantic-Congo"
Locale["zu"]["iso"] = "zul"
Locale["zu"]["glotto"] = "zulu1248"
Locale["zu"]["script"] = "Latn"
#* Cantonese
Locale["yue"]["support"] = "bing-only"
Locale["yue"]["name"] = "Cantonese"
Locale["yue"]["endonym"] = "粵語"
Locale["yue"]["family"] = "Sino-Tibetan"
Locale["yue"]["iso"] = "yue"
Locale["yue"]["glotto"] = "cant1236"
Locale["yue"]["script"] = "Hant"
#* Fijian
Locale["fj"]["support"] = "bing-only"
Locale["fj"]["name"] = "Fijian"
Locale["fj"]["endonym"] = "Vosa Vakaviti"
Locale["fj"]["family"] = "Austronesian"
Locale["fj"]["iso"] = "fij"
Locale["fj"]["glotto"] = "fiji1243"
Locale["fj"]["script"] = "Latn"
#* Hmong Daw
Locale["mww"]["support"] = "bing-only"
Locale["mww"]["name"] = "Hmong Daw"
Locale["mww"]["endonym"] = "Hmoob Daw"
Locale["mww"]["family"] = "Hmong-Mien"
Locale["mww"]["iso"] = "mww"
Locale["mww"]["glotto"] = "hmon1333"
Locale["mww"]["script"] = "Latn"
#* Querétaro Otomi
Locale["otq"]["support"] = "bing-only"
Locale["otq"]["name"] = "Querétaro Otomi"
Locale["otq"]["endonym"] = "Hñąñho"
Locale["otq"]["family"] = "Oto-Manguean"
Locale["otq"]["iso"] = "otq"
Locale["otq"]["glotto"] = "quer1236"
Locale["otq"]["script"] = "Latn"
#* Tahitian
Locale["ty"]["support"] = "bing-only"
Locale["ty"]["name"] = "Tahitian"
Locale["ty"]["endonym"] = "Reo Tahiti"
Locale["ty"]["family"] = "Austronesian"
Locale["ty"]["iso"] = "tah"
Locale["ty"]["glotto"] = "tahi1242"
Locale["ty"]["script"] = "Latn"
#* Tongan
Locale["to"]["support"] = "bing-only"
Locale["to"]["name"] = "Tongan"
Locale["to"]["endonym"] = "Lea faka-Tonga"
Locale["to"]["family"] = "Austronesian"
Locale["to"]["iso"] = "ton"
Locale["to"]["glotto"] = "tong1325"
Locale["to"]["script"] = "Latn"
#* Yucatec Maya
Locale["yua"]["support"] = "bing-only"
Locale["yua"]["name"] = "Yucatec Maya"
Locale["yua"]["endonym"] = "Màaya T'àan"
Locale["yua"]["family"] = "Mayan"
Locale["yua"]["iso"] = "yua"
Locale["yua"]["glotto"] = "yuca1254"
Locale["yua"]["script"] = "Latn"
#* Klingon, Latin alphabet
Locale["tlh"]["support"] = "bing-only"
Locale["tlh"]["name"] = "Klingon"
Locale["tlh"]["endonym"] = "tlhIngan Hol"
Locale["tlh"]["family"] = "Artificial Language"
Locale["tlh"]["iso"] = "tlh"
#Locale["tlh"]["glotto"]
Locale["tlh"]["script"] = "Latn"
#* Klingon, pIqaD
Locale["tlh-Qaak"]["support"] = "bing-only"
Locale["tlh-Qaak"]["name"] = "Klingon (pIqaD)"
Locale["tlh-Qaak"]["endonym"] = " "
Locale["tlh-Qaak"]["family"] = "Artificial Language"
Locale["tlh-Qaak"]["iso"] = "tlh"
#Locale["tlh-Qaak"]["glotto"]
Locale["tlh-Qaak"]["script"] = "Piqd"
#? Assamese
Locale["as"]["support"] = "unstable"
Locale["as"]["name"] = "Assamese"
Locale["as"]["endonym"] = "অসমীয়া"
#Locale["as"]["translations-of"]
#Locale["as"]["definitions-of"]
#Locale["as"]["synonyms"]
#Locale["as"]["examples"]
#Locale["as"]["see-also"]
Locale["as"]["family"] = "Indo-European"
Locale["as"]["iso"] = "asm"
Locale["as"]["glotto"] = "assa1263"
Locale["as"]["script"] = "Beng"
#? Bashkir
Locale["ba"]["support"] = "yandex-only"
Locale["ba"]["name"] = "Bashkir"
Locale["ba"]["endonym"] = "башҡорт теле"
#Locale["ba"]["translations-of"]
#Locale["ba"]["definitions-of"]
#Locale["ba"]["synonyms"]
#Locale["ba"]["examples"]
#Locale["ba"]["see-also"]
Locale["ba"]["family"] = "Turkic"
Locale["ba"]["iso"] = "bak"
Locale["ba"]["glotto"] = "bash1264"
Locale["ba"]["script"] = "Cyrl"
#? Breton
Locale["br"]["support"] = "unstable"
Locale["br"]["name"] = "Breton"
Locale["br"]["endonym"] = "Brezhoneg"
#Locale["br"]["translations-of"]
#Locale["br"]["definitions-of"]
#Locale["br"]["synonyms"]
#Locale["br"]["examples"]
#Locale["br"]["see-also"]
Locale["br"]["family"] = "Indo-European"
Locale["br"]["iso"] = "bre"
Locale["br"]["glotto"] = "bret1244"
Locale["br"]["script"] = "Latn"
#? Dzongkha
Locale["dz"]["support"] = "unstable"
Locale["dz"]["name"] = "Dzongkha"
Locale["dz"]["endonym"] = "རྫོང་ཁ"
#Locale["dz"]["translations-of"]
#Locale["dz"]["definitions-of"]
#Locale["dz"]["synonyms"]
#Locale["dz"]["examples"]
#Locale["dz"]["see-also"]
Locale["dz"]["family"] = "Sino-Tibetan"
Locale["dz"]["iso"] = "dzo"
Locale["dz"]["glotto"] = "nucl1307"
Locale["dz"]["script"] = "Tibt"
#? Eastern Mari
Locale["mhr"]["support"] = "yandex-only"
Locale["mhr"]["name"] = "Eastern Mari"
Locale["mhr"]["endonym"] = "Олык марий"
#Locale["mhr"]["translations-of"]
#Locale["mhr"]["definitions-of"]
#Locale["mhr"]["synonyms"]
#Locale["mhr"]["examples"]
#Locale["mhr"]["see-also"]
Locale["mhr"]["family"] = "Uralic"
Locale["mhr"]["iso"] = "mhr"
Locale["mhr"]["glotto"] = "east2328"
Locale["mhr"]["script"] = "Cyrl"
#? Faroese
Locale["fo"]["support"] = "unstable"
Locale["fo"]["name"] = "Faroese"
Locale["fo"]["endonym"] = "Føroyskt"
#Locale["fo"]["translations-of"]
#Locale["fo"]["definitions-of"]
#Locale["fo"]["synonyms"]
#Locale["fo"]["examples"]
#Locale["fo"]["see-also"]
Locale["fo"]["family"] = "Indo-European"
Locale["fo"]["iso"] = "fao"
Locale["fo"]["glotto"] = "faro1244"
Locale["fo"]["script"] = "Latn"
#? Guarani
Locale["gn"]["support"] = "unstable"
Locale["gn"]["name"] = "Guarani"
Locale["gn"]["endonym"] = "Avañe'ẽ"
#Locale["gn"]["translations-of"]
#Locale["gn"]["definitions-of"]
#Locale["gn"]["synonyms"]
#Locale["gn"]["examples"]
#Locale["gn"]["see-also"]
Locale["gn"]["family"] = "Tupian"
Locale["gn"]["iso"] = "grn"
Locale["gn"]["glotto"] = "para1311"
Locale["gn"]["script"] = "Latn"
#? Hill Mari
Locale["mrj"]["support"] = "yandex-only"
Locale["mrj"]["name"] = "Hill Mari"
Locale["mrj"]["endonym"] = "Кырык мары"
#Locale["mrj"]["translations-of"]
#Locale["mrj"]["definitions-of"]
#Locale["mrj"]["synonyms"]
#Locale["mrj"]["examples"]
#Locale["mrj"]["see-also"]
Locale["mrj"]["family"] = "Uralic"
Locale["mrj"]["iso"] = "mrj"
Locale["mrj"]["glotto"] = "west2392"
Locale["mrj"]["script"] = "Cyrl"
#? Interlingue
Locale["ie"]["support"] = "unstable"
Locale["ie"]["name"] = "Interlingue"
Locale["ie"]["endonym"] = "Interlingue"
#Locale["ie"]["translations-of"]
#Locale["ie"]["definitions-of"]
#Locale["ie"]["synonyms"]
#Locale["ie"]["examples"]
#Locale["ie"]["see-also"]
Locale["ie"]["family"] = "Artificial Language"
Locale["ie"]["iso"] = "ile"
Locale["ie"]["glotto"] = "occi1241"
Locale["ie"]["script"] = "Latn"
#? Kinyarwanda
Locale["rw"]["support"] = "unstable"
Locale["rw"]["name"] = "Kinyarwanda"
Locale["rw"]["endonym"] = "Ikinyarwanda"
#Locale["rw"]["translations-of"]
#Locale["rw"]["definitions-of"]
#Locale["rw"]["synonyms"]
#Locale["rw"]["examples"]
#Locale["rw"]["see-also"]
Locale["rw"]["family"] = "Atlantic-Congo"
Locale["rw"]["iso"] = "kin"
Locale["rw"]["glotto"] = "kiny1244"
Locale["rw"]["script"] = "Latn"
#? Occitan
Locale["oc"]["support"] = "unstable"
Locale["oc"]["name"] = "Occitan"
Locale["oc"]["endonym"] = "Occitan"
#Locale["oc"]["translations-of"]
#Locale["oc"]["definitions-of"]
#Locale["oc"]["synonyms"]
#Locale["oc"]["examples"]
#Locale["oc"]["see-also"]
Locale["oc"]["family"] = "Indo-European"
Locale["oc"]["iso"] = "oci"
Locale["oc"]["glotto"] = "occi1239"
Locale["oc"]["script"] = "Latn"
#? Oromo
Locale["om"]["support"] = "unstable"
Locale["om"]["name"] = "Oromo"
Locale["om"]["endonym"] = "Afaan Oromoo"
#Locale["om"]["translations-of"]
#Locale["om"]["definitions-of"]
#Locale["om"]["synonyms"]
#Locale["om"]["examples"]
#Locale["om"]["see-also"]
Locale["om"]["family"] = "Afro-Asiatic"
Locale["om"]["iso"] = "orm"
Locale["om"]["glotto"] = "nucl1736"
Locale["om"]["script"] = "Latn"
#? Oriya
Locale["or"]["support"] = "unstable"
Locale["or"]["name"] = "Oriya"
Locale["or"]["endonym"] = "ଓଡ଼ିଆ"
#Locale["or"]["translations-of"]
#Locale["or"]["definitions-of"]
#Locale["or"]["synonyms"]
#Locale["or"]["examples"]
#Locale["or"]["see-also"]
Locale["or"]["family"] = "Indo-European"
Locale["or"]["iso"] = "ori"
Locale["or"]["glotto"] = "macr1269"
Locale["or"]["script"] = "Orya"
#? Papiamento
Locale["pap"]["support"] = "yandex-only"
Locale["pap"]["name"] = "Papiamento"
Locale["pap"]["endonym"] = "Papiamentu"
#Locale["pap"]["translations-of"]
#Locale["pap"]["definitions-of"]
#Locale["pap"]["synonyms"]
#Locale["pap"]["examples"]
#Locale["pap"]["see-also"]
Locale["pap"]["family"] = "Indo-European"
Locale["pap"]["iso"] = "pap"
Locale["pap"]["glotto"] = "papi1253"
Locale["pap"]["script"] = "Latn"
#? Romansh
Locale["rm"]["support"] = "unstable"
Locale["rm"]["name"] = "Romansh"
Locale["rm"]["endonym"] = "Rumantsch"
#Locale["rm"]["translations-of"]
#Locale["rm"]["definitions-of"]
#Locale["rm"]["synonyms"]
#Locale["rm"]["examples"]
#Locale["rm"]["see-also"]
Locale["rm"]["family"] = "Indo-European"
Locale["rm"]["iso"] = "roh"
Locale["rm"]["glotto"] = "roma1326"
Locale["rm"]["script"] = "Latn"
#? Tigrinya
Locale["ti"]["support"] = "unstable"
Locale["ti"]["name"] = "Tigrinya"
Locale["ti"]["endonym"] = "ትግርኛ"
#Locale["ti"]["translations-of"]
#Locale["ti"]["definitions-of"]
#Locale["ti"]["synonyms"]
#Locale["ti"]["examples"]
#Locale["ti"]["see-also"]
Locale["ti"]["family"] = "Afro-Asiatic"
Locale["ti"]["iso"] = "tir"
Locale["ti"]["glotto"] = "tigr1271"
Locale["ti"]["script"] = "Ethi"
#? Tibetan (Standard Tibetan)
Locale["bo"]["support"] = "unstable"
Locale["bo"]["name"] = "Tibetan"
Locale["bo"]["endonym"] = "བོད་ཡིག"
#Locale["bo"]["translations-of"]
#Locale["bo"]["definitions-of"]
#Locale["bo"]["synonyms"]
#Locale["bo"]["examples"]
#Locale["bo"]["see-also"]
Locale["bo"]["family"] = "Sino-Tibetan"
Locale["bo"]["iso"] = "bod"
Locale["bo"]["glotto"] = "tibe1272"
Locale["bo"]["script"] = "Tibt"
#? Turkmen
Locale["tk"]["support"] = "unstable"
Locale["tk"]["name"] = "Turkmen"
Locale["tk"]["endonym"] = "Türkmen"
#Locale["tk"]["translations-of"]
#Locale["tk"]["definitions-of"]
#Locale["tk"]["synonyms"]
#Locale["tk"]["examples"]
#Locale["tk"]["see-also"]
Locale["tk"]["family"] = "Turkic"
Locale["tk"]["iso"] = "tuk"
Locale["tk"]["glotto"] = "turk1304"
Locale["tk"]["script"] = "Latn"
#? Tatar
Locale["tt"]["support"] = "yandex-only"
Locale["tt"]["name"] = "Tatar"
Locale["tt"]["endonym"] = "татарча"
#Locale["tt"]["translations-of"]
#Locale["tt"]["definitions-of"]
#Locale["tt"]["synonyms"]
#Locale["tt"]["examples"]
#Locale["tt"]["see-also"]
Locale["tt"]["family"] = "Turkic"
Locale["tt"]["iso"] = "tat"
Locale["tt"]["glotto"] = "tata1255"
Locale["tt"]["script"] = "Cyrl"
#? Udmurt
Locale["udm"]["support"] = "yandex-only"
Locale["udm"]["name"] = "Udmurt"
Locale["udm"]["endonym"] = "удмурт"
#Locale["udm"]["translations-of"]
#Locale["udm"]["definitions-of"]
#Locale["udm"]["synonyms"]
#Locale["udm"]["examples"]
#Locale["udm"]["see-also"]
Locale["udm"]["family"] = "Uralic"
Locale["udm"]["iso"] = "udm"
Locale["udm"]["glotto"] = "udmu1245"
Locale["udm"]["script"] = "Cyrl"
#? Uyghur
Locale["ug"]["support"] = "unstable"
Locale["ug"]["name"] = "Uyghur"
Locale["ug"]["endonym"] = "ئۇيغۇر تىلى"
#Locale["ug"]["translations-of"]
#Locale["ug"]["definitions-of"]
#Locale["ug"]["synonyms"]
#Locale["ug"]["examples"]
#Locale["ug"]["see-also"]
Locale["ug"]["family"] = "Turkic"
Locale["ug"]["iso"] = "uig"
Locale["ug"]["glotto"] = "uigh1240"
Locale["ug"]["script"] = "Arab"
Locale["ug"]["rtl"] = "true" # RTL language
#? Volapük
Locale["vo"]["support"] = "unstable"
Locale["vo"]["name"] = "Volapük"
Locale["vo"]["endonym"] = "Volapük"
#Locale["vo"]["translations-of"]
#Locale["vo"]["definitions-of"]
#Locale["vo"]["synonyms"]
#Locale["vo"]["examples"]
#Locale["vo"]["see-also"]
Locale["vo"]["family"] = "Artificial Language"
Locale["vo"]["iso"] = "vol"
#Locale["vo"]["glotto"]
Locale["vo"]["script"] = "Latn"
#? Wolof
Locale["wo"]["support"] = "unstable"
Locale["wo"]["name"] = "Wolof"
Locale["wo"]["endonym"] = "Wollof"
#Locale["wo"]["translations-of"]
#Locale["wo"]["definitions-of"]
#Locale["wo"]["synonyms"]
#Locale["wo"]["examples"]
#Locale["wo"]["see-also"]
Locale["wo"]["family"] = "Atlantic-Congo"
Locale["wo"]["iso"] = "wol"
Locale["wo"]["glotto"] = "wolo1247"
Locale["wo"]["script"] = "Latn"
#? Cherokee
Locale["chr"]["support"] = "unstable"
Locale["chr"]["name"] = "Cherokee"
Locale["chr"]["endonym"] = "ᏣᎳᎩ"
#Locale["chr"]["translations-of"]
#Locale["chr"]["definitions-of"]
#Locale["chr"]["synonyms"]
#Locale["chr"]["examples"]
#Locale["chr"]["see-also"]
Locale["chr"]["family"] = "Iroquoian"
Locale["chr"]["iso"] = "chr"
Locale["chr"]["glotto"] = "cher1273"
Locale["chr"]["script"] = "Cher"
#? Emoji
Locale["emj"]["support"] = "yandex-only"
Locale["emj"]["name"] = "Emoji"
Locale["emj"]["endonym"] = "Emoji"
}
# Initialize aliases of all locales supported.
function initLocaleAlias( i) {
for (i in Locale) {
# ISO 639-3 codes as aliases
LocaleAlias[Locale[i]["iso"]] = i
# Names and endonyms as aliases
LocaleAlias[tolower(Locale[i]["name"])] = i
LocaleAlias[tolower(Locale[i]["endonym"])] = i
}
# Other aliases
# See:
LocaleAlias["in"] = "id" # withdrawn language code for Indonesian
LocaleAlias["iw"] = "he" # withdrawn language code for Hebrew
LocaleAlias["ji"] = "yi" # withdrawn language code for Yiddish
LocaleAlias["jw"] = "jv" # withdrawn language code for Javanese
LocaleAlias["mo"] = "ro" # Moldavian or Moldovan considered a variant of the Romanian language
LocaleAlias["nb"] = "no" # Google Translate does not distinguish between Bokmål and Nynorsk
LocaleAlias["nn"] = "no"
LocaleAlias["sh"] = "sr-Cyrl" # Serbo-Croatian: default to Serbian
LocaleAlias["sr"] = "sr-Cyrl" # Serbian: default to Serbian Cyrillic
LocaleAlias["srp"] = "sr-Cyrl"
LocaleAlias["serbian"] = "sr-Cyrl"
LocaleAlias["zh"] = "zh-CN" # Chinese: default to Chinese Simplified
LocaleAlias["zh-CHS"] = "zh-CN"
LocaleAlias["zh-CHT"] = "zh-TW"
LocaleAlias["zh-Hans"] = "zh-CN"
LocaleAlias["zh-Hant"] = "zh-TW"
LocaleAlias["zho"] = "zh-CN"
LocaleAlias["chinese"] = "zh-CN"
LocaleAlias["tlh-Latn"] = "tlh"
LocaleAlias["tlh-Piqd"] = "tlh-Qaak"
# TODO: more aliases
}
# Initialize strings for displaying endonyms of all locales supported.
function initLocaleDisplay( i) {
for (i in Locale) {
Locale[i]["display"] = show(Locale[i]["endonym"], i)
}
}
# Get locale key by language code or alias.
function getCode(code, group) {
if (code == "auto" || code in Locale)
return code
else if (code in LocaleAlias)
return LocaleAlias[code]
else if (tolower(code) in LocaleAlias)
return LocaleAlias[tolower(code)]
# Remove unidentified region or script code
match(code, /^([[:alpha:]][[:alpha:]][[:alpha:]]?)-(.*)$/, group)
if (group[1])
return group[1]
return # return nothing if not found
}
# Return the name of a language.
function getName(code) {
return Locale[getCode(code)]["name"]
}
# Return the endonym of a language.
function getEndonym(code) {
return Locale[getCode(code)]["endonym"]
}
# Return the string for displaying the endonym of a language.
function getDisplay(code) {
return Locale[getCode(code)]["display"]
}
# Return formatted text for "translations of".
function showTranslationsOf(code, text, fmt) {
fmt = Locale[getCode(code)]["translations-of"]
if (!fmt) fmt = Locale["en"]["translations-of"]
return sprintf(fmt, text)
}
# Return formatted text for "definitions of".
function showDefinitionsOf(code, text, fmt) {
fmt = Locale[getCode(code)]["definitions-of"]
if (!fmt) fmt = Locale["en"]["definitions-of"]
return sprintf(fmt, text)
}
# Return a string of "synonyms".
function showSynonyms(code, tmp) {
tmp = Locale[getCode(code)]["synonyms"]
if (!tmp) tmp = Locale["en"]["synonyms"]
return tmp
}
# Return a string of "examples".
function showExamples(code, tmp) {
tmp = Locale[getCode(code)]["examples"]
if (!tmp) tmp = Locale["en"]["examples"]
return tmp
}
# Return a string of "see also".
function showSeeAlso(code, tmp) {
tmp = Locale[getCode(code)]["see-also"]
if (!tmp) tmp = Locale["en"]["see-also"]
return tmp
}
# Return the family of a language.
function getFamily(code) {
return Locale[getCode(code)]["family"]
}
# Return the ISO 639-3 code of a language.
function getISO(code) {
return Locale[getCode(code)]["iso"]
}
# Return the Glottocode of a language.
function getGlotto(code) {
return Locale[getCode(code)]["glotto"]
}
# Return the ISO 15924 script code of a language.
function getScript(code) {
return Locale[getCode(code)]["script"]
}
# Return 1 if a language is R-to-L; otherwise return 0.
function isRTL(code) {
return Locale[getCode(code)]["rtl"] ? 1 : 0
}
# Return 1 if Google provides dictionary data for a language; otherwise return 0.
function hasDictionary(code) {
return Locale[getCode(code)]["dictionary"] ? 1 : 0
}
# Comparator using getName().
function compName(i1, v1, i2, v2) {
if (getName(i1) < getName(i2))
return -1
else
return (getName(i1) != getName(i2))
}
# Return the name of script (writing system).
# See:
#
function scriptName(code) {
switch (code) {
case "Arab": return "Arabic"
case "Armn": return "Armenian"
case "Beng": return "Bengali"
case "Cher": return "Cherokee"
case "Cyrl": return "Cyrillic"
case "Deva": return "Devanagari"
case "Ethi": return "Ethiopic (Geʻez)"
case "Geor": return "Georgian (Mkhedruli)"
case "Grek": return "Greek"
case "Gujr": return "Gujarati"
case "Guru": return "Gurmukhi"
case "Hani": return "Han"
case "Hans": return "Han (Simplified)"
case "Hant": return "Han (Traditional)"
case "Hebr": return "Hebrew"
case "Jpan": return "Japanese (Han + Hiragana + Katakana)"
case "Khmr": return "Khmer"
case "Knda": return "Kannada"
case "Kore": return "Korean (Hangul + Han)"
case "Laoo": return "Lao"
case "Latn": return "Latin"
case "Mlym": return "Malayalam"
case "Mymr": return "Myanmar"
case "Orya": return "Oriya"
case "Piqd": return "Klingon (pIqaD)"
case "Sinh": return "Sinhala"
case "Taml": return "Tamil"
case "Telu": return "Telugu"
case "Thai": return "Thai"
case "Tibt": return "Tibetan"
default: return "Unknown"
}
}
# Return detailed information of a language as a string.
function getDetails(code, group, iso, language, script) {
if (code == "auto" || !getCode(code)) {
e("[ERROR] Language not found: " code "\n" \
" Run '-reference / -R' to see a list of available languages.")
exit 1
}
script = scriptName(getScript(code))
if (isRTL(code)) script = script " (R-to-L)"
split(getISO(code), group, "-")
iso = group[1]
split(getName(code), group, " ")
language = length(group) == 1 ? group[1] "_language" :
group[2] ~ /^\(.*\)$/ ? group[1] "_language" : join(group, "_")
return ansi("bold", sprintf("%s\n", getDisplay(code))) \
sprintf("%-22s%s\n", "Name", ansi("bold", getName(code))) \
sprintf("%-22s%s\n", "Family", ansi("bold", getFamily(code))) \
sprintf("%-22s%s\n", "Writing system", ansi("bold", script)) \
sprintf("%-22s%s\n", "Code", ansi("bold", getCode(code))) \
sprintf("%-22s%s\n", "ISO 639-3", ansi("bold", iso)) \
sprintf("%-22s%s\n", "SIL", ansi("bold", "http://www-01.sil.org/iso639-3/documentation.asp?id=" iso)) \
sprintf("%-22s%s\n", "Glottolog", getGlotto(code) ?
ansi("bold", "http://glottolog.org/resource/languoid/id/" getGlotto(code)) : "") \
sprintf("%-22s%s", "Wikipedia", ansi("bold", "http://en.wikipedia.org/wiki/" language))
}
# Add /slashes/ for IPA phonemic notations and (parentheses) for others.
# Parameters:
# code
function showPhonetics(phonetics, code) {
if (code && getCode(code) == "en")
return "/" phonetics "/"
else
return "(" phonetics ")"
}
# Convert a logical string to visual; don't right justify RTL lines.
# Parameters:
# code: ignore to apply bidirectional algorithm on every string
function show(text, code, command, temp) {
if (!code || isRTL(code)) {
if (Cache[text][0])
return Cache[text][0]
else {
if ((FriBidi || (code && isRTL(code))) && BiDiNoPad) {
command = "echo " parameterize(text) PIPE BiDiNoPad
command | getline temp
close(command)
} else # non-RTL language, or FriBidi not installed
temp = text
return Cache[text][0] = temp
}
} else
return text
}
# Convert a logical string to visual and right justify RTL lines.
# Parameters:
# code: ignore to apply bidirectional algorithm on every string
# width: ignore to use default width for padding
function s(text, code, width, command, temp) {
if (!code || isRTL(code)) {
if (!width) width = Option["width"]
if (Cache[text][width])
return Cache[text][width]
else {
if ((FriBidi || (code && isRTL(code))) && BiDi) {
command = "echo " parameterize(text) PIPE sprintf(BiDi, width)
command | getline temp
close(command)
} else # non-RTL language, or FriBidi not installed
temp = text
return Cache[text][width] = temp
}
} else
return text
}
# Convert a logical string to visual with a certain level of indentation.
# Parameters:
# level: level of indentation
# code: ignore to apply left indentation
# width: ignore to use default width for padding
function ins(level, text, code, width, i, temp) {
if (code && isRTL(code)) {
if (!width) width = Option["width"]
return s(text, code, width - Option["indent"] * level)
} else
return replicate(" ", Option["indent"] * level) text
}
# Parse a POSIX locale identifier and return the language code;
# Identified by both language identifier and region identifier.
# Parameters:
# lang = [language[_territory][.codeset][@modifier]]
# See:
function parseLang(lang, code, group) {
match(lang, /^([a-z][a-z][a-z]?)(_|$)/, group)
code = getCode(group[1])
# Detect region identifier
## Regions using Chinese Simplified: China, Singapore
if (lang ~ /^zh_(CN|SG)/) code = "zh-CN"
## Regions using Chinese Traditional: Taiwan, Hong Kong
else if (lang ~ /^zh_(TW|HK)/) code = "zh-TW"
# FIXME: handle unrecognized language code
if (!code) code = "en"
return code
}
# Initialize `UserLang`.
function initUserLang( lang, utf) {
if (lang = ENVIRON["LC_ALL"]) {
if (!UserLocale) UserLocale = lang
utf = utf || tolower(lang) ~ /utf-?8$/
}
if (lang = ENVIRON["LANG"]) {
if (!UserLocale) UserLocale = lang
utf = utf || tolower(lang) ~ /utf-?8$/
}
if (!UserLocale) {
UserLocale = "en_US.UTF-8"
utf = 1
}
if (!utf)
w("[WARNING] Your locale codeset (" UserLocale ") is not UTF-8.")
UserLang = parseLang(UserLocale)
}
translate-shell-0.9.6.11/include/Main.awk 0000664 0000000 0000000 00000056164 13516335241 0020102 0 ustar 00root root 0000000 0000000 ####################################################################
# Main.awk #
####################################################################
# Initialization.
function init() {
initGawk()
initBiDiTerm()
initBiDi()
# (Languages.awk)
initLocale()
initLocaleAlias()
initUserLang()
RS = "\n"
ExitCode = 0
Option["debug"] = 0
# Translation engine
Option["engine"] = "google"
# Display
Option["verbose"] = 1
Option["show-original"] = 1
Option["show-original-phonetics"] = 1
Option["show-translation"] = 1
Option["show-translation-phonetics"] = 1
Option["show-prompt-message"] = 1
Option["show-languages"] = 1
Option["show-original-dictionary"] = 0
Option["show-dictionary"] = 1
Option["show-alternatives"] = 1
Option["width"] = ENVIRON["COLUMNS"] ? ENVIRON["COLUMNS"] - 2 : 0
Option["indent"] = 4
Option["no-ansi"] = 0
Option["no-autocorrect"] = 0
Option["no-bidi"] = 0
Option["force-bidi"] = 0
Option["no-warn"] = 0
Option["theme"] = "default"
Option["dump"] = 0
# Audio
Option["play"] = 0
Option["narrator"] = "female"
Option["player"] = ENVIRON["PLAYER"]
Option["no-translate"] = 0
Option["download-audio"] = 0
Option["download-audio-as"] = NULLSTR
# Terminal paging and browsing
Option["view"] = 0
Option["pager"] = ENVIRON["PAGER"]
Option["browser"] = ENVIRON["BROWSER"]
# Networking
Option["proxy"] = ENVIRON["HTTP_PROXY"] ? ENVIRON["HTTP_PROXY"] : ENVIRON["http_proxy"]
Option["user-agent"] = ENVIRON["USER_AGENT"] ? ENVIRON["USER_AGENT"] :
"Mozilla/5.0 (X11; Linux x86_64) " \
"AppleWebKit/602.1 (KHTML, like Gecko) Version/8.0 " \
"Safari/602.1 Epiphany/3.18.2"
Option["ip-version"] = 0
# Interactive shell
Option["no-rlwrap"] = 0
Option["interactive"] = 0
Option["emacs"] = 0
# I/O
Option["input"] = NULLSTR
Option["output"] = STDOUT
# Language preference
Option["hl"] = ENVIRON["HOME_LANG"] ? ENVIRON["HOME_LANG"] : UserLang
Option["sl"] = ENVIRON["SOURCE_LANG"] ? ENVIRON["SOURCE_LANG"] : "auto"
Option["sls"][1] = Option["sl"]
Option["tl"][1] = ENVIRON["TARGET_LANG"] ? ENVIRON["TARGET_LANG"] : UserLang
# Text preprocessing
Option["join-sentence"] = 0
}
# Initialization script.
function initScript( file, line, script, temp) {
# Find the initialization file
file = ".trans"
if (!fileExists(file)) {
file = ENVIRON["HOME"] "/.translate-shell/init.trans"
if (!fileExists(file)) {
file = ENVIRON["XDG_CONFIG_HOME"] "/translate-shell/init.trans"
if (!fileExists(file)) {
file = ENVIRON["HOME"] "/.config/translate-shell/init.trans"
if (!fileExists(file)) {
file = "/etc/translate-shell"
if (!fileExists(file)) return
}
}
}
}
InitScript = file
script = NULLSTR
while (getline line < InitScript)
script = script "\n" line
loadOptions(script)
# HACK: Option["tl"] must be an array
if (!isarray(Option["tl"])) {
temp = Option["tl"]
delete Option["tl"]
Option["tl"][1] = temp
}
}
# Miscellany initialization.
function initMisc( command, group, temp) {
# (Translate.awk)
initHttpService()
# Initialize screen width if not set
if (!Option["width"] && detectProgram("tput", "-V")) {
command = "tput cols" SUPERR
command | getline temp
close(command)
Option["width"] = temp > 5 ? temp - 2 : 64 # minimum screen width: 4
}
# Disable ANSI escape codes if required
if (Option["no-ansi"])
delete AnsiCode
# Disable conversion of bidirectional texts if required or supported by emulator
if (Option["no-bidi"] || BiDiTerm == "mlterm")
# mlterm implements its own padding
BiDi = BiDiNoPad = NULLSTR
else if (!Option["force-bidi"] && BiDiTerm == "konsole") {
# konsole implements no padding; we should handle this
BiDiNoPad = NULLSTR
BiDi = "sed \"s/'/\\\\\\'/\" | xargs -0 printf '%%%ss'"
}
# (Languages.awk)
initLocaleDisplay()
# Disable everything stderr
if (Option["no-warn"])
STDERR = "/dev/null"
# Initialize audio player or speech synthesizer
if (Option["play"]) {
if (!Option["player"]) {
initAudioPlayer()
Option["player"] = AudioPlayer ? AudioPlayer : Option["player"]
if (!Option["player"])
initSpeechSynthesizer()
}
if (!Option["player"] && !SpeechSynthesizer) {
w("[WARNING] No available audio player or speech synthesizer.")
Option["play"] = 0
}
}
# Initialize pager
if (Option["view"]) {
if (!Option["pager"]) {
initPager()
Option["pager"] = Pager
}
if (!Option["pager"]) {
w("[WARNING] No available terminal pager.")
Option["view"] = 0
}
}
# Initialize browser
if (!Option["browser"]) {
Platform = detectProgram("uname", "-s", 1)
Option["browser"] = Platform == "Darwin" ? "open" : "xdg-open"
}
}
# Main entry point.
BEGIN {
init()
if (!(belongsTo("-no-init", ARGV) || belongsTo("--no-init", ARGV)))
initScript() # initialization script overrides default setting
# Command-line options override initialization script
pos = 0
noargc = 0
while (ARGV[++pos]) {
## Information options
# -V, -version
match(ARGV[pos], /^--?(V|vers(i(on?)?)?)$/)
if (RSTART) {
InfoOnly = "version"
continue
}
# -H, -help
match(ARGV[pos], /^--?(H|h(e(lp?)?)?)$/)
if (RSTART) {
InfoOnly = "help"
continue
}
# -M, -man
match(ARGV[pos], /^--?(M|m(a(n(u(al?)?)?)?)?)$/)
if (RSTART) {
InfoOnly = "manual"
continue
}
# -T, -reference
match(ARGV[pos], /^--?(T|ref(e(r(e(n(ce?)?)?)?)?)?)$/)
if (RSTART) {
InfoOnly = "reference"
continue
}
# FIXME[1.0]: to be removed
match(ARGV[pos], /^--?r$/)
if (RSTART) {
w("[WARNING] Option '-r' has been deprecated since version 0.9.\n" \
" Use option '-T' or '-reference' instead.")
exit 1
}
# -R, -reference-english
match(ARGV[pos], /^--?(R|reference-e(n(g(l(i(sh?)?)?)?)?)?)$/)
if (RSTART) {
InfoOnly = "reference-english"
continue
}
# -L CODES, -list CODES
match(ARGV[pos], /^--?(L|list)(=(.*)?)?$/, group)
if (RSTART) {
InfoOnly = "list"
if (group[2]) {
if (group[3]) split(group[3], Option["tl"], "+")
} else
split(ARGV[++pos], Option["tl"], "+")
continue
}
# -S, -list-engines
match(ARGV[pos], /^--?(S|list-e(n(g(i(n(es?)?)?)?)?)?)$/)
if (RSTART) {
InfoOnly = "list-engines"
continue
}
# -U, -upgrade
match(ARGV[pos], /^--?(U|upgrade)$/)
if (RSTART) {
InfoOnly = "upgrade"
continue
}
# -N, -nothing
match(ARGV[pos], /^--?(N|nothing)$/)
if (RSTART) {
InfoOnly = "nothing"
continue
}
## Translator options
# -e ENGINE, -engine ENGINE
match(ARGV[pos], /^--?(e|engine)(=(.*)?)?$/, group)
if (RSTART) {
Option["engine"] = group[2] ?
(group[3] ? group[3] : Option["engine"]) :
ARGV[++pos]
continue
}
# Shortcut format
# '/ENGINE'
match(ARGV[pos], /^\/(.*)$/, group)
if (RSTART) {
Option["engine"] = group[1]
continue
}
## Display options
# -verbose
match(ARGV[pos], /^--?verbose$/)
if (RSTART) {
Option["verbose"] = 1 # default value
continue
}
# -b, -brief
match(ARGV[pos], /^--?b(r(i(ef?)?)?)?$/)
if (RSTART) {
Option["verbose"] = 0
continue
}
# -d, -dictionary
match(ARGV[pos], /^--?d(i(c(t(i(o(n(a(ry?)?)?)?)?)?)?)?)?$/)
if (RSTART) {
Option["show-original-dictionary"] = 1
Option["show-dictionary"] = 0
Option["show-alternatives"] = 0
continue
}
# -identify
match(ARGV[pos], /^--?id(e(n(t(i(fy?)?)?)?)?)?$/)
if (RSTART) {
Option["verbose"] = Option["verbose"] - 2
continue
}
# -show-original Y/n
match(ARGV[pos], /^--?show-original(=(.*)?)?$/, group)
if (RSTART) {
Option["show-original"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-original-phonetics Y/n
match(ARGV[pos], /^--?show-original-phonetics(=(.*)?)?$/, group)
if (RSTART) {
Option["show-original-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-translation Y/n
match(ARGV[pos], /^--?show-translation(=(.*)?)?$/, group)
if (RSTART) {
Option["show-translation"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-translation-phonetics Y/n
match(ARGV[pos], /^--?show-translation-phonetics(=(.*)?)?$/, group)
if (RSTART) {
Option["show-translation-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-prompt-message Y/n
match(ARGV[pos], /^--?show-prompt-message(=(.*)?)?$/, group)
if (RSTART) {
Option["show-prompt-message"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-languages Y/n
match(ARGV[pos], /^--?show-languages(=(.*)?)?$/, group)
if (RSTART) {
Option["show-languages"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-original-dictionary y/N
match(ARGV[pos], /^--?show-original-dictionary(=(.*)?)?$/, group)
if (RSTART) {
Option["show-original-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-dictionary Y/n
match(ARGV[pos], /^--?show-dictionary(=(.*)?)?$/, group)
if (RSTART) {
Option["show-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -show-alternatives Y/n
match(ARGV[pos], /^--?show-alternatives(=(.*)?)?$/, group)
if (RSTART) {
Option["show-alternatives"] = yn(group[1] ? group[2] : ARGV[++pos])
continue
}
# -w NUM, -width NUM
match(ARGV[pos], /^--?w(i(d(th?)?)?)?(=(.*)?)?$/, group)
if (RSTART) {
Option["width"] = group[4] ?
(group[5] ? group[5] : Option["width"]) :
ARGV[++pos]
continue
}
# -indent NUM
match(ARGV[pos], /^--?indent(=(.*)?)?$/, group)
if (RSTART) {
Option["indent"] = group[1] ?
(group[2] ? group[2] : Option["indent"]) :
ARGV[++pos]
continue
}
# -theme FILENAME
match(ARGV[pos], /^--?theme(=(.*)?)?$/, group)
if (RSTART) {
Option["theme"] = group[1] ?
(group[2] ? group[2] : Option["theme"]) :
ARGV[++pos]
continue
}
# -no-theme
match(ARGV[pos], /^--?no-theme$/)
if (RSTART) {
Option["theme"] = NULLSTR
continue
}
# -no-ansi
match(ARGV[pos], /^--?no-ansi$/)
if (RSTART) {
Option["no-ansi"] = 1
continue
}
# -no-autocorrect
match(ARGV[pos], /^--?no-auto(correct)?$/)
if (RSTART) {
Option["no-autocorrect"] = 1
continue
}
# -no-bidi
match(ARGV[pos], /^--?no-bidi/)
if (RSTART) {
Option["no-bidi"] = 1
continue
}
# -bidi
match(ARGV[pos], /^--?bidi/)
if (RSTART) {
Option["force-bidi"] = 1
continue
}
# -no-warn
match(ARGV[pos], /^--?no-warn/)
if (RSTART) {
Option["no-warn"] = 1
continue
}
# -dump
match(ARGV[pos], /^--?dump/)
if (RSTART) {
Option["dump"] = 1
continue
}
## Audio options
# -p, -play
match(ARGV[pos], /^--?p(l(ay?)?)?$/)
if (RSTART) {
Option["play"] = 1
continue
}
# -speak
match(ARGV[pos], /^--?sp(e(ak?)?)?$/)
if (RSTART) {
Option["play"] = 2
continue
}
# -n VOICE, -narrator VOICE
match(ARGV[pos], /^--?(n|narrator)(=(.*)?)?$/, group)
if (RSTART) {
if (!Option["play"]) Option["play"] = 1 # -play by default
Option["narrator"] = group[2] ?
(group[3] ? group[3] : Option["narrator"]) :
ARGV[++pos]
continue
}
# -player PROGRAM
match(ARGV[pos], /^--?player(=(.*)?)?$/, group)
if (RSTART) {
if (!Option["play"]) Option["play"] = 1 # -play by default
Option["player"] = group[1] ?
(group[2] ? group[2] : Option["player"]) :
ARGV[++pos]
continue
}
# -no-play
match(ARGV[pos], /^--?no-play$/)
if (RSTART) {
Option["play"] = 0
continue
}
# -no-translate
match(ARGV[pos], /^--?no-tran(s(l(a(te?)?)?)?)?$/)
if (RSTART) {
Option["no-translate"] = 1
continue
}
# -download-audio
match(ARGV[pos], /^--?download-a(u(d(io?)?)?)?$/)
if (RSTART) {
Option["download-audio"] = 1
continue
}
# -download-audio-as
match(ARGV[pos], /^--?download-audio-as(=(.*)?)?$/, group)
if (RSTART) {
if (!Option["download-audio"]) Option["download-audio"] = 1
Option["download-audio-as"] = group[1] ?
(group[2] ? group[2] : Option["download-audio-as"]) :
ARGV[++pos]
continue
}
## Terminal paging and browsing options
# -v, -view
match(ARGV[pos], /^--?v(i(ew?)?)?$/)
if (RSTART) {
Option["view"] = 1
continue
}
# -pager PROGRAM
match(ARGV[pos], /^--?pager(=(.*)?)?$/, group)
if (RSTART) {
Option["view"] = 1
Option["pager"] = group[1] ?
(group[2] ? group[2] : Option["pager"]) :
ARGV[++pos]
continue
}
# -no-view, -no-pager
match(ARGV[pos], /^--?no-(view|pager)$/)
if (RSTART) {
Option["view"] = 0
continue
}
# -browser PROGRAM
match(ARGV[pos], /^--?browser(=(.*)?)?$/, group)
if (RSTART) {
Option["browser"] = group[1] ?
(group[2] ? group[2] : Option["browser"]) :
ARGV[++pos]
continue
}
# -no-browser
match(ARGV[pos], /^--?no-browser$/)
if (RSTART) {
Option["browser"] = NONE
continue
}
## Networking options
# -x HOST:PORT, -proxy HOST:PORT
match(ARGV[pos], /^--?(x|proxy)(=(.*)?)?$/, group)
if (RSTART) {
Option["proxy"] = group[2] ?
(group[3] ? group[3] : Option["proxy"]) :
ARGV[++pos]
continue
}
# -u STRING, -user-agent STRING
match(ARGV[pos], /^--?(u|user-agent)(=(.*)?)?$/, group)
if (RSTART) {
Option["user-agent"] = group[2] ?
(group[3] ? group[3] : Option["user-agent"]) :
ARGV[++pos]
continue
}
# -4, -ipv4, -inet4-only
match(ARGV[pos], /^--?(4|ipv4|inet4-only)$/)
if (RSTART) {
Option["ip-version"] = 4
continue
}
# -6, -ipv6, -inet6-only
match(ARGV[pos], /^--?(6|ipv6|inet6-only)$/)
if (RSTART) {
Option["ip-version"] = 6
continue
}
## Interactive shell options
# -I, -interactive, -shell
match(ARGV[pos], /^--?(I|int(e(r(a(c(t(i(ve?)?)?)?)?)?)?)?|shell)$/)
if (RSTART) {
Option["interactive"] = 1
continue
}
# -E, -emacs
match(ARGV[pos], /^--?(E|emacs)$/)
if (RSTART) {
Option["emacs"] = 1
continue
}
# -no-rlwrap
match(ARGV[pos], /^--?no-rlwrap$/)
if (RSTART) {
Option["no-rlwrap"] = 1
continue
}
# FIXME[1.0]: to be removed
# -prompt PROMPT_STRING
match(ARGV[pos], /^--?prompt(=(.*)?)?$/, group)
if (RSTART) {
w("[ERROR] Option '-prompt' has been deprecated since version 0.9.\n" \
" Use configuration variable 'fmt-prompt' instead.")
exit 1
}
# FIXME[1.0]: to be removed
# -prompt-color COLOR_CODE
match(ARGV[pos], /^--?prompt-color(=(.*)?)?$/, group)
if (RSTART) {
w("[ERROR] Option '-prompt-color' has been deprecated since version 0.9.\n" \
" Use configuration variable 'sgr-prompt' instead.")
exit 1
}
## I/O options
# -i FILENAME, -input FILENAME
match(ARGV[pos], /^--?i(n(p(ut?)?)?)?(=(.*)?)?$/, group)
if (RSTART) {
Option["input"] = group[4] ?
(group[5] ? group[5] : Option["input"]) :
ARGV[++pos]
continue
}
# -o FILENAME, -output FILENAME
match(ARGV[pos], /^--?o(u(t(p(ut?)?)?)?)?(=(.*)?)?$/, group)
if (RSTART) {
Option["output"] = group[5] ?
(group[6] ? group[6] : Option["output"]) :
ARGV[++pos]
continue
}
## Language preference options
# -l CODE, -hl CODE, -lang CODE
match(ARGV[pos], /^--?(l(a(ng?)?)?|hl)(=(.*)?)?$/, group)
if (RSTART) {
Option["hl"] = group[4] ?
(group[5] ? group[5] : Option["hl"]) :
ARGV[++pos]
continue
}
# -s CODES, -sl CODES, -source CODES, -f CODES, -from CODES
match(ARGV[pos], /^--?(s(o(u(r(ce?)?)?)?|l)?|f|from)(=(.*)?)?$/, group)
if (RSTART) {
if (group[6]) {
if (group[7]) split(group[7], Option["sls"], "+")
} else
split(ARGV[++pos], Option["sls"], "+")
Option["sl"] = Option["sls"][1]
continue
}
# -t CODES, -tl CODES, -target CODES, -to CODES
match(ARGV[pos], /^--?t(a(r(g(et?)?)?)?|l|o)?(=(.*)?)?$/, group)
if (RSTART) {
if (group[5]) {
if (group[6]) split(group[6], Option["tl"], "+")
} else
split(ARGV[++pos], Option["tl"], "+")
continue
}
# Shortcut format
# 'CODE:CODE+...' or 'CODE=CODE+...'
match(ARGV[pos], /^[{(\[]?((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)[})\]]?$/, group)
if (RSTART) {
if (group[1]) {
split(group[1], Option["sls"], "+")
Option["sl"] = Option["sls"][1]
}
if (group[7]) split(group[7], Option["tl"], "+")
continue
}
## Text preprocessing options
# -j, -join-sentence
match(ARGV[pos], /^--?j(o(i(n(-(s(e(n(t(e(n(ce?)?)?)?)?)?)?)?)?)?)?)?$/)
if (RSTART) {
Option["join-sentence"] = 1
continue
}
## Other options
# -D, -debug
match(ARGV[pos], /^--?(D|debug)$/)
if (RSTART) {
Option["debug"] = 1
continue
}
# -no-init
match(ARGV[pos], /^--?no-init/)
if (RSTART) continue # skip
# -, -no-op
match(ARGV[pos], /^-(-?no-op)?$/)
if (RSTART) continue # no operation, skip
# --
match(ARGV[pos], /^--$/)
if (RSTART) {
++pos # skip the end-of-options option
break # no more option from here
}
# non-option argument
noargv[noargc++] = ARGV[pos]
}
# Handle interactive shell
if (Option["interactive"] && !Option["no-rlwrap"])
rlwrapMe() # interactive mode
else if (Option["emacs"] && !Option["interactive"] && !Option["no-rlwrap"])
if (emacsMe()) # emacs front-end
Option["interactive"] = 1 # fallback to interactive mode
# Get started
initMisc()
# Information-only session
switch (InfoOnly) {
case "version":
print getVersion()
exit ExitCode
case "help":
print getHelp()
exit ExitCode
case "manual":
showMan()
exit ExitCode
case "reference":
print getReference("endonym")
exit ExitCode
case "reference-english":
print getReference("name")
exit ExitCode
case "list":
print getList(Option["tl"])
exit ExitCode
case "list-engines":
for (translator in Translator)
print (Option["engine"] == translator ? "* " : " ") translator
exit ExitCode
case "upgrade":
upgrade()
exit ExitCode
case "nothing":
exit ExitCode
}
# Load theme (overrides command-line options) - slow
setTheme()
if (Option["interactive"])
welcome()
# More remaining non-option arguments
if (pos < ARGC)
for (i = pos; i < ARGC; i++)
noargv[noargc++] = ARGV[i]
# Text preprocessing: join all arguments if required
if (noargc > 1 && Option["join-sentence"]) {
noargv[0] = join(noargv, " ")
noargc = 1
}
if (noargc) {
# Translate all non-option arguments
for (i = 0; i < noargc; i++) {
# Verbose mode: separator between sources
if (Option["verbose"] && i > pos)
p(prettify("source-seperator", replicate(Option["chr-source-seperator"], Option["width"])))
translates(noargv[i], 1) # inline mode
}
# If input not specified, we're done
} else {
# If input not specified, use stdin
if (!Option["input"]) Option["input"] = STDIN
}
# If input specified, start translating
if (Option["input"])
translateMain()
exit ExitCode
}
translate-shell-0.9.6.11/include/Parser.awk 0000664 0000000 0000000 00000025052 13516335241 0020442 0 ustar 00root root 0000000 0000000 ####################################################################
# Parser.awk #
####################################################################
# Tokenize a string and return a token list.
function tokenize(returnTokens, string,
delimiters,
newlines,
quotes,
escapeChars,
leftBlockComments,
rightBlockComments,
lineComments,
reservedOperators,
reservedPatterns,
####
blockCommenting,
c,
currentToken,
escaping,
i,
lineCommenting,
p,
quoting,
r,
s,
tempGroup,
tempPattern,
tempString) {
# Default parameters
if (!delimiters[0]) {
delimiters[0] = " " # whitespace
delimiters[1] = "\t" # horizontal tab
delimiters[2] = "\v" # vertical tab
}
if (!newlines[0]) {
newlines[0] = "\n" # line feed
newlines[1] = "\r" # carriage return
}
if (!quotes[0]) {
quotes[0] = "\"" # double quote
}
if (!escapeChars[0]) {
escapeChars[0] = "\\" # backslash
}
if (!leftBlockComments[0]) {
leftBlockComments[0] = "#|" # Lisp-style extended comment (open)
leftBlockComments[1] = "/*" # C-style comment (open)
leftBlockComments[2] = "(*" # ML-style comment (open)
}
if (!rightBlockComments[0]) {
rightBlockComments[0] = "|#" # Lisp-style extended comment (close)
rightBlockComments[1] = "*/" # C-style comment (close)
rightBlockComments[2] = "*)" # ML-style comment (close)
}
if (!lineComments[0]) {
lineComments[0] = ";" # Lisp-style line comment
lineComments[1] = "//" # C++-style line comment
lineComments[2] = "#" # hash comment
}
if (!reservedOperators[0]) {
reservedOperators[0] = "(" # left parenthesis
reservedOperators[1] = ")" # right parenthesis
reservedOperators[2] = "[" # left bracket
reservedOperators[3] = "]" # right bracket
reservedOperators[4] = "{" # left brace
reservedOperators[5] = "}" # right brace
reservedOperators[6] = "," # comma
}
if (!reservedPatterns[0]) {
reservedPatterns[0] = "[+-]?((0|[1-9][0-9]*)|[.][0-9]*|(0|[1-9][0-9]*)[.][0-9]*)([Ee][+-]?[0-9]+)?" # numeric literal (scientific notation possible)
reservedPatterns[1] = "[+-]?0[0-7]+([.][0-7]*)?" # numeric literal (octal)
reservedPatterns[2] = "[+-]?0[Xx][0-9A-Fa-f]+([.][0-9A-Fa-f]*)?" # numeric literal (hexadecimal)
}
split(string, s, "")
currentToken = ""
quoting = escaping = blockCommenting = lineCommenting = 0
p = 0
i = 1
while (i <= length(s)) {
c = s[i]
r = substr(string, i)
if (blockCommenting) {
if (tempString = startsWithAny(r, rightBlockComments))
blockCommenting = 0 # block comment ends
i++
} else if (lineCommenting) {
if (belongsTo(c, newlines))
lineCommenting = 0 # line comment ends
i++
} else if (quoting) {
currentToken = currentToken c
if (escaping) {
escaping = 0 # escape ends
} else {
if (belongsTo(c, quotes)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
quoting = 0 # quotation ends
} else if (belongsTo(c, escapeChars)) {
escaping = 1 # escape begins
} else {
# Continue
}
}
i++
} else {
if (belongsTo(c, delimiters) || belongsTo(c, newlines)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
i++
} else if (belongsTo(c, quotes)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
}
currentToken = c
quoting = 1 # quotation begins
i++
} else if (tempString = startsWithAny(r, leftBlockComments)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
blockCommenting = 1 # block comment begins
i += length(tempString)
} else if (tempString = startsWithAny(r, lineComments)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
lineCommenting = 1 # line comment begins
i += length(tempString)
} else if (tempString = startsWithAny(r, reservedOperators)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
# Reserve token
returnTokens[p++] = tempString
i += length(tempString)
} else if (tempPattern = matchesAny(r, reservedPatterns)) {
# Finish the current token
if (currentToken) {
returnTokens[p++] = currentToken
currentToken = ""
}
# Reserve token
match(r, "^" tempPattern, tempGroup)
returnTokens[p++] = tempGroup[0]
i += length(tempGroup[0])
} else {
# Continue with the current token
currentToken = currentToken c
i++
}
}
}
# Finish the last token
if (currentToken)
returnTokens[p++] = currentToken
}
# Parse a token list of JSON array and return an AST.
function parseJsonArray(returnAST, tokens,
leftBrackets,
rightBrackets,
separators,
####
i, j, key, p, stack, token) {
# Default parameters
if (!leftBrackets[0]) {
leftBrackets[0] = "(" # left parenthesis
leftBrackets[1] = "[" # left bracket
leftBrackets[2] = "{" # left brace
}
if (!rightBrackets[0]) {
rightBrackets[0] = ")" # right parenthesis
rightBrackets[1] = "]" # right bracket
rightBrackets[2] = "}" # right brace
}
if (!separators[0]) {
separators[0] = "," # comma
}
stack[p = 0] = 0
for (i = 0; i < length(tokens); i++) {
token = tokens[i]
if (belongsTo(token, leftBrackets))
stack[++p] = 0
else if (belongsTo(token, rightBrackets))
--p
else if (belongsTo(token, separators))
stack[p]++
else {
key = stack[0]
for (j = 1; j <= p; j++)
key = key SUBSEP stack[j]
returnAST[key] = token
}
}
}
# JSON parser.
function parseJson(returnAST, tokens,
arrayStartTokens, arrayEndTokens,
objectStartTokens, objectEndTokens,
commas, colons,
####
flag, i, j, key, name, p, stack, token) {
# Default parameters
if (!arrayStartTokens[0]) arrayStartTokens[0] = "["
if (!arrayEndTokens[0]) arrayEndTokens[0] = "]"
if (!objectStartTokens[0]) objectStartTokens[0] = "{"
if (!objectEndTokens[0]) objectEndTokens[0] = "}"
if (!commas[0]) commas[0] = ","
if (!colons[0]) colons[0] = ":"
stack[p = 0] = 0
flag = 0 # ready to read key
for (i = 0; i < length(tokens); i++) {
token = tokens[i]
if (belongsTo(token, arrayStartTokens)) {
stack[++p] = 0
} else if (belongsTo(token, objectStartTokens)) {
stack[++p] = NULLSTR
flag = 0 # ready to read key
} else if (belongsTo(token, objectEndTokens) ||
belongsTo(token, arrayEndTokens)) {
--p
} else if (belongsTo(token, commas)) {
if (isnum(stack[p])) # array
stack[p]++ # increase index
else # object
flag = 0 # ready to read key
} else if (belongsTo(token, colons)) {
flag = 1 # ready to read value
} else if (isnum(stack[p]) || flag) {
# Read a value
key = stack[0]
for (j = 1; j <= p; j++)
key = key SUBSEP stack[j]
returnAST[key] = token
flag = 0 # ready to read key
} else {
# Read a key
stack[p] = unparameterize(token)
}
}
}
# S-expr parser.
function parseList(returnAST, tokens,
leftBrackets,
rightBrackets,
separators,
####
i, j, key, p, stack, token) {
# Default parameters
if (!leftBrackets[0]) {
leftBrackets[0] = "(" # left parenthesis
leftBrackets[1] = "[" # left bracket
leftBrackets[2] = "{" # left brace
}
if (!rightBrackets[0]) {
rightBrackets[0] = ")" # right parenthesis
rightBrackets[1] = "]" # right bracket
rightBrackets[2] = "}" # right brace
}
if (!separators[0]) {
separators[0] = "," # comma
}
stack[p = 0] = 0
for (i = 0; i < length(tokens); i++) {
token = tokens[i]
if (belongsTo(token, leftBrackets)) {
stack[++p] = 0
} else if (belongsTo(token, rightBrackets)) {
stack[--p]++
} else if (belongsTo(token, separators)) {
# skip
} else {
key = NULLSTR
if (p > 0) {
for (j = 0; j < p - 1; j++)
key = key SUBSEP stack[j]
returnAST[key][stack[p - 1]] = NULLSTR
key = key SUBSEP stack[p - 1]
}
returnAST[key][stack[p]] = token
stack[p]++
}
}
}
translate-shell-0.9.6.11/include/REPL.awk 0000664 0000000 0000000 00000014703 13516335241 0017751 0 ustar 00root root 0000000 0000000 ####################################################################
# REPL.awk #
####################################################################
# Welcome message.
function welcome() {
if (Option["fmt-welcome-message"])
print prettify("welcome-message", Option["fmt-welcome-message"]) > STDERR
if (Option["fmt-welcome-submessage"])
print prettify("welcome-submessage", Option["fmt-welcome-submessage"]) > STDERR
}
# Prompt for interactive session.
function prompt( i, p, temp) {
p = Option["fmt-prompt"]
# Format specifiers supported by strftime().
# Roughly following ISO 8601:1988, with the notable exception of "%S", "%t" and "%T".
# GNU libc extensions like "%l", "%s" and "%_*" are not supported.
# See:
#
if (p ~ /%a/) gsub(/%a/, strftime("%a"), p)
if (p ~ /%A/) gsub(/%A/, strftime("%A"), p)
if (p ~ /%b/) gsub(/%b/, strftime("%b"), p)
if (p ~ /%B/) gsub(/%B/, strftime("%B"), p)
if (p ~ /%c/) gsub(/%c/, strftime("%c"), p)
if (p ~ /%C/) gsub(/%C/, strftime("%C"), p)
if (p ~ /%d/) gsub(/%d/, strftime("%d"), p)
if (p ~ /%D/) gsub(/%D/, strftime("%D"), p)
if (p ~ /%e/) gsub(/%e/, strftime("%e"), p)
if (p ~ /%F/) gsub(/%F/, strftime("%F"), p)
if (p ~ /%g/) gsub(/%g/, strftime("%g"), p)
if (p ~ /%G/) gsub(/%G/, strftime("%G"), p)
if (p ~ /%h/) gsub(/%h/, strftime("%h"), p)
if (p ~ /%H/) gsub(/%H/, strftime("%H"), p)
if (p ~ /%I/) gsub(/%I/, strftime("%I"), p)
if (p ~ /%j/) gsub(/%j/, strftime("%j"), p)
if (p ~ /%m/) gsub(/%m/, strftime("%m"), p)
if (p ~ /%M/) gsub(/%M/, strftime("%M"), p)
if (p ~ /%n/) gsub(/%n/, strftime("%n"), p)
if (p ~ /%p/) gsub(/%p/, strftime("%p"), p)
if (p ~ /%r/) gsub(/%r/, strftime("%r"), p)
if (p ~ /%R/) gsub(/%R/, strftime("%R"), p)
if (p ~ /%u/) gsub(/%u/, strftime("%u"), p)
if (p ~ /%U/) gsub(/%U/, strftime("%U"), p)
if (p ~ /%V/) gsub(/%V/, strftime("%V"), p)
if (p ~ /%w/) gsub(/%w/, strftime("%w"), p)
if (p ~ /%W/) gsub(/%W/, strftime("%W"), p)
if (p ~ /%x/) gsub(/%x/, strftime("%x"), p)
if (p ~ /%X/) gsub(/%X/, strftime("%X"), p)
if (p ~ /%y/) gsub(/%y/, strftime("%y"), p)
if (p ~ /%Y/) gsub(/%Y/, strftime("%Y"), p)
if (p ~ /%z/) gsub(/%z/, strftime("%z"), p)
if (p ~ /%Z/) gsub(/%Z/, strftime("%Z"), p)
# %_ : prompt message
if (p ~ /%_/)
gsub(/%_/, showTranslationsOf(Option["hl"]), p)
# %l : home language
if (p ~ /%l/)
gsub(/%l/, getDisplay(Option["hl"]), p)
# %L : home language (English name)
if (p ~ /%L/)
gsub(/%L/, getName(Option["hl"]), p)
# %s : source languages, separated by "+"
# 's' is the format-control character for string
# %S : source languages (English names), seperated by "+"
if (p ~ /%S/) {
temp = getName(Option["sls"][1])
for (i = 2; i <= length(Option["sls"]); i++)
temp = temp "+" getName(Option["sls"][i])
gsub(/%S/, temp, p)
}
# TODO: source languages separated by "," and "/"
# %t : target languages, separated by "+"
if (p ~ /%t/) {
temp = getDisplay(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "+" getDisplay(Option["tl"][i])
gsub(/%t/, temp, p)
}
# %T : target languages (English names), separated by "+"
if (p ~ /%T/) {
temp = getName(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "+" getName(Option["tl"][i])
gsub(/%T/, temp, p)
}
# %, : target languages, separated by ","
if (p ~ /%,/) {
temp = getDisplay(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "," getDisplay(Option["tl"][i])
gsub(/%,/, temp, p)
}
# %< : target languages (English names), separated by ","
if (p ~ /%) {
temp = getName(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "," getName(Option["tl"][i])
gsub(/%, temp, p)
}
# %/ : target languages, separated by "/"
if (p ~ /%\//) {
temp = getDisplay(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "/" getDisplay(Option["tl"][i])
gsub(/%\//, temp, p)
}
# %? : target languages (English names), separated by "/"
if (p ~ /%\?/) {
temp = getName(Option["tl"][1])
for (i = 2; i <= length(Option["tl"]); i++)
temp = temp "/" getName(Option["tl"][i])
gsub(/%\?/, temp, p)
}
# %s : source languages, separated by "+"
temp = getDisplay(Option["sls"][1])
for (i = 2; i <= length(Option["sls"]); i++)
temp = temp "+" getDisplay(Option["sls"][i])
printf(prettify("prompt", p), temp) > STDERR
}
# REPL.
function repl(line, command, group, name, i, value, words) {
split(line, words, " ")
command = words[1]
if (command ~ /^:(q|quit)$/) {
exit
} else if (command ~ /^:set$/) {
name = words[2]
value = words[3]
Option[name] = value
} else if (command ~ /^:show$/) {
name = words[2]
print prettify("welcome-submessage", toString(Option[name], 1, 0, 1))
} else if (command ~ /^:engine$/) {
value = words[2]
Option["engine"] = value
initHttpService()
} else {
match(command, /^[{(\[]?((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)[})\]]?$/, group)
if (RSTART) {
if (group[1]) {
split(group[1], Option["sls"], "+")
Option["sl"] = Option["sls"][1]
}
if (group[7]) split(group[7], Option["tl"], "+")
line = words[2]
for (i = 3; i <= length(words); i++)
line = line " " words[i]
}
if (line) {
translates(line)
# Interactive verbose mode: newline after each translation
if (Option["verbose"]) printf RS
}
}
prompt()
}
translate-shell-0.9.6.11/include/Script.awk 0000664 0000000 0000000 00000004532 13516335241 0020452 0 ustar 00root root 0000000 0000000 ####################################################################
# Script.awk #
####################################################################
# Load options from the initialization script.
function loadOptions(script, i, j, tokens, name, value) {
tokenize(tokens, script)
for (i in tokens) {
if (tokens[i] ~ /^:/) {
name = substr(tokens[i], 2)
value = tokens[i + 1]
if (value ~ /^[+-]?((0|[1-9][0-9]*)|[.][0-9]*|(0|[1-9][0-9]*)[.][0-9]*)([Ee][+-]?[0-9]+)?$/) {
# Decimal number
delete Option[name]
Option[name] = value
} else if (value == "false" || value == "true") {
# Boolean
delete Option[name]
Option[name] = yn(value)
} else if (value ~ /^".*"$/) {
# String
delete Option[name]
Option[name] = literal(value)
} else if (value == "[") {
# List of strings
delete Option[name]
for (j = 1; tokens[i + j + 1] && tokens[i + j + 1] != "]"; j++) {
if (tokens[i + j + 1] ~ /^".*"$/)
Option[name][j] = literal(tokens[i + j + 1])
else {
e("[ERROR] Malformed configuration.")
return
}
}
} else {
e("[ERROR] Malformed configuration.")
return
}
}
}
}
# Check for upgrade.
function upgrade( i, newVersion, registry, tokens) {
RegistryIndex = "https://raw.githubusercontent.com/soimort/translate-shell/registry/index.trans"
registry = curl(RegistryIndex)
if (!registry) {
e("[ERROR] Failed to check for upgrade.")
ExitCode = 1
return
}
tokenize(tokens, registry)
for (i in tokens)
if (tokens[i] == ":translate-shell")
newVersion = literal(tokens[i + 1])
if (newerVersion(newVersion, Version)) {
w("Current version: \t" Version)
w("New version available: \t" newVersion)
w("Download from: \t" "https://www.soimort.org/translate-shell/trans")
} else {
w("Current version: \t" Version)
w("Already up-to-date.")
}
}
translate-shell-0.9.6.11/include/Theme.awk 0000664 0000000 0000000 00000014231 13516335241 0020245 0 ustar 00root root 0000000 0000000 ####################################################################
# Theme.awk #
####################################################################
# Prettify a string using corresponding SGR option.
function prettify(name, string, i, temp) {
temp = string
if ("sgr-" name in Option)
if (isarray(Option["sgr-" name]))
for (i in Option["sgr-" name])
temp = ansi(Option["sgr-" name][i], temp)
else
temp = ansi(Option["sgr-" name], temp)
return temp
}
# Return a string representing a random color.
function randomColor( i) {
i = int(5 * rand())
switch (i) {
case 0: return "green"
case 1: return "yellow"
case 2: return "blue"
case 3: return "magenta"
case 4: return "cyan"
default: return "default"
}
}
# Set theme to: random.
function setRandomTheme( i, n, temp) {
srand(systime())
for (i = 0; i < 3; i++) {
do temp = randomColor(); while (belongsTo(temp, n))
n[i] = temp
}
Option["sgr-prompt-message"] = Option["sgr-languages"] = n[0]
Option["sgr-original-dictionary-detailed-word-class"][1] = n[0]
Option["sgr-original-dictionary-detailed-word-class"][2] = "bold"
Option["sgr-original-dictionary-synonyms"] = n[0]
Option["sgr-original-dictionary-synonyms-word-class"][1] = n[0]
Option["sgr-original-dictionary-synonyms-word-class"][2] = "bold"
Option["sgr-original-dictionary-examples"] = n[0]
Option["sgr-original-dictionary-see-also"] = n[0]
Option["sgr-dictionary-word-class"][1] = n[0]
Option["sgr-dictionary-word-class"][2] = "bold"
Option["sgr-original"][1] = Option["sgr-original-phonetics"][1] = n[1]
Option["sgr-original"][2] = Option["sgr-original-phonetics"][2] = "bold"
Option["sgr-prompt-message-original"][1] = n[1]
Option["sgr-prompt-message-original"][2] = "bold"
Option["sgr-languages-sl"] = n[1]
Option["sgr-original-dictionary-detailed-explanation"][1] = n[1]
Option["sgr-original-dictionary-detailed-explanation"][2] = "bold"
Option["sgr-original-dictionary-detailed-example"] = n[1]
Option["sgr-original-dictionary-detailed-synonyms"] = n[1]
Option["sgr-original-dictionary-detailed-synonyms-item"][1] = n[1]
Option["sgr-original-dictionary-detailed-synonyms-item"][2] = "bold"
Option["sgr-original-dictionary-synonyms-synonyms"] = n[1]
Option["sgr-original-dictionary-synonyms-synonyms-item"][1] = n[1]
Option["sgr-original-dictionary-synonyms-synonyms-item"][2] = "bold"
Option["sgr-original-dictionary-examples-example"] = n[1]
Option["sgr-original-dictionary-examples-original"][1] = n[1]
Option["sgr-original-dictionary-examples-original"][2] = "bold"
Option["sgr-original-dictionary-examples-original"][3] = "underline"
Option["sgr-original-dictionary-see-also-phrases"] = n[1]
Option["sgr-original-dictionary-see-also-phrases-item"][1] = n[1]
Option["sgr-original-dictionary-see-also-phrases-item"][2] = "bold"
Option["sgr-dictionary-explanation"] = n[1]
Option["sgr-dictionary-explanation-item"][1] = n[1]
Option["sgr-dictionary-explanation-item"][2] = "bold"
Option["sgr-alternatives-original"][1] = n[1]
Option["sgr-alternatives-original"][2] = "bold"
Option["sgr-translation"][1] = Option["sgr-translation-phonetics"][1] = n[2]
Option["sgr-translation"][2] = Option["sgr-translation-phonetics"][2] = "bold"
Option["sgr-languages-tl"] = n[2]
Option["sgr-dictionary-word"][1] = n[2]
Option["sgr-dictionary-word"][2] = "bold"
Option["sgr-alternatives-translations"] = n[2]
Option["sgr-alternatives-translations-item"][1] = n[2]
Option["sgr-alternatives-translations-item"][2] = "bold"
Option["sgr-brief-translation"][1] = Option["sgr-brief-translation-phonetics"][1] = n[2]
Option["sgr-brief-translation"][2] = Option["sgr-brief-translation-phonetics"][2] = "bold"
Option["fmt-welcome-message"] = Name
Option["sgr-welcome-message"][1] = n[0]
Option["sgr-welcome-message"][2] = "bold"
Option["fmt-welcome-submessage"] = "(:q to quit)"
Option["sgr-welcome-submessage"] = n[0]
Option["fmt-prompt"] = "%s> "
Option["sgr-prompt"][1] = n[1]
Option["sgr-prompt"][2] = "bold"
}
# Set theme to: default.
function setDefaultTheme() {
Option["sgr-translation"] = Option["sgr-translation-phonetics"] = "bold"
Option["sgr-prompt-message-original"] = "underline"
Option["sgr-languages-sl"] = "underline"
Option["sgr-languages-tl"] = "bold"
Option["sgr-original-dictionary-detailed-explanation"] = "bold"
Option["sgr-original-dictionary-detailed-synonyms-item"] = "bold"
Option["sgr-original-dictionary-synonyms-synonyms-item"] = "bold"
Option["sgr-original-dictionary-examples-original"][1] = "bold"
Option["sgr-original-dictionary-examples-original"][2] = "underline"
Option["sgr-original-dictionary-see-also-phrases-item"] = "bold"
Option["sgr-dictionary-word"] = "bold"
Option["sgr-alternatives-original"] = "underline"
Option["sgr-alternatives-translations-item"] = "bold"
Option["fmt-welcome-message"] = Name
Option["sgr-welcome-message"] = "bold"
Option["fmt-welcome-submessage"] = "(:q to quit)"
Option["fmt-prompt"] = "%s> "
Option["sgr-prompt"] = "bold"
}
# Set theme using corresponding option.
function setTheme( file, line, script) {
if (Option["theme"] && Option["theme"] != "default" \
&& Option["theme"] != "none" && Option["theme"] != "random") {
file = Option["theme"]
if (!fileExists(file)) {
file = ENVIRON["HOME"] "/.translate-shell/" Option["theme"]
if (!fileExists(file)) {
file = ENVIRON["HOME"] "/.config/translate-shell/" Option["theme"]
if (!fileExists(file)) return
}
}
}
if (file && fileExists(file)) {
# Read from theme file
script = NULLSTR
while (getline line < file)
script = script "\n" line
loadOptions(script)
} else if (Option["theme"] == "none")
;# skip
else if (Option["theme"] == "random")
setRandomTheme()
else
setDefaultTheme()
}
translate-shell-0.9.6.11/include/Translate.awk 0000664 0000000 0000000 00000034173 13516335241 0021147 0 ustar 00root root 0000000 0000000 ####################################################################
# Translate.awk #
####################################################################
function provides(engineName) {
Translator[tolower(engineName)] = TRUE
}
function engineMethod(methodName, engine, translator) {
if (!Translator[Option["engine"]]) {
# case-insensitive match engine name
engine = tolower(Option["engine"])
if (!Translator[engine]) # fuzzy match engine name
for (translator in Translator)
if (Translator[translator] && # there IS such a translator
translator ~ "^"engine) {
engine = translator
break
}
if (!Translator[engine]) {
e("[ERROR] Translator not found: " Option["engine"] "\n" \
" Run '-list-engines / -S' to see a list of available engines.")
exit 1
}
Option["engine"] = engine
}
return Option["engine"] methodName
}
# Detect external audio player (mplayer, mpv, mpg123).
function initAudioPlayer() {
AudioPlayer = !system("mpv" SUPOUT SUPERR) ?
"mpv --no-config" :
(!system("mplayer" SUPOUT SUPERR) ?
"mplayer" :
(!system("mpg123 --version" SUPOUT SUPERR) ?
"mpg123" :
""))
}
# Detect external speech synthesizer (say, espeak).
function initSpeechSynthesizer() {
SpeechSynthesizer = !system("say ''" SUPOUT SUPERR) ?
"say" :
(!system("espeak ''" SUPOUT SUPERR) ?
"espeak" :
"")
}
# Detect external terminal pager (less, more, most).
function initPager() {
Pager = !system("less -V" SUPOUT SUPERR) ?
"less" :
(!system("more -V" SUPOUT SUPERR) ?
"more" :
(!system("most" SUPOUT SUPERR) ?
"most" :
""))
}
# Initialize `HttpService`.
function initHttpService( inet) {
_Init()
inet = "inet"
if (Option["ip-version"])
inet = inet Option["ip-version"]
if (Option["proxy"]) {
match(Option["proxy"], /^(http:\/*)?(([^:]+):([^@]+)@)?([^\/]*):([^\/:]*)/, HttpProxySpec)
HttpAuthUser = HttpProxySpec[3]
HttpAuthPass = HttpProxySpec[4]
HttpAuthCredentials = base64(unquote(HttpAuthUser) ":" HttpAuthPass)
HttpService = "/" inet "/tcp/0/" HttpProxySpec[5] "/" HttpProxySpec[6]
HttpPathPrefix = HttpProtocol HttpHost
} else {
HttpService = "/" inet "/tcp/0/" HttpHost "/" HttpPort
HttpPathPrefix = ""
}
# How long to wait in milliseconds for IPv6 before trying IPv4
PROCINFO[HttpService, "READ_TIMEOUT"] = 2000
}
# Pre-process string (URL-encode before send).
function preprocess(text) {
return quote(text)
}
# Pre-process string (using hexdump to URL-encode everything).
function preprocessByDump(text, arr, len, temp) {
len = dumpX(text, arr)
temp = ""
for (i = 1; i <= len; i++)
temp = temp "%" arr[i]
return temp
}
# [OBSOLETE] Is this function still relevant?
# Post-process string (remove any redundant whitespace).
function postprocess(text) {
text = gensub(/ ([.,;:?!"])/, "\\1", "g", text)
text = gensub(/(["]) /, "\\1", "g", text)
return text
}
# Send an HTTP GET request and get response from an online translator.
function getResponse(text, sl, tl, hl,
####
content, header, isBody, url, group, status, location) {
url = _RequestUrl(text, sl, tl, hl)
header = "GET " url " HTTP/1.1\r\n" \
"Host: " HttpHost "\r\n" \
"Connection: close\r\n"
if (Option["user-agent"])
header = header "User-Agent: " Option["user-agent"] "\r\n"
if (Cookie)
header = header "Cookie: " Cookie "\r\n"
if (HttpAuthUser && HttpAuthPass)
# TODO: digest auth
header = header "Proxy-Authorization: Basic " HttpAuthCredentials "\r\n"
content = NULLSTR; isBody = 0
while (1) {
print header |& HttpService
while ((HttpService |& getline) > 0) {
if (isBody)
content = content ? content "\n" $0 : $0
else if (length($0) <= 1)
isBody = 1
else { # interesting fields in header
match($0, /^HTTP[^ ]* ([^ ]*)/, group)
if (RSTART) status = group[1]
match($0, /^Location: (.*)/, group)
if (RSTART) location = squeeze(group[1]) # squeeze the URL!
}
l(sprintf("%4s bytes > %s", length($0), $0))
}
close(HttpService)
if (ERRNO == "Connection timed out") {
w("[WARNING] " ERRNO ". Retrying IPv4 connection.")
Option["ip-version"] = 4
initHttpService()
PROCINFO[HttpService, "READ_TIMEOUT"] = 0
ERRNO = ""
} else
break
}
if ((status == "301" || status == "302") && location)
content = curl(location)
return assert(content, "[ERROR] Null response.")
}
# Send an HTTP POST request and return response from an online translator.
function postResponse(text, sl, tl, hl, type,
####
content, contentLength, contentType, group,
header, isBody, reqBody, url, status, location) {
url = _PostRequestUrl(text, sl, tl, hl, type)
contentType = _PostRequestContentType(text, sl, tl, hl, type)
reqBody = _PostRequestBody(text, sl, tl, hl, type)
if (DumpContentengths[reqBody])
contentLength = DumpContentengths[reqBody]
else
contentLength = DumpContentengths[reqBody] = dump(reqBody, group)
header = "POST " url " HTTP/1.1\r\n" \
"Host: " HttpHost "\r\n" \
"Connection: close\r\n" \
"Content-Length: " contentLength "\r\n" \
"Content-Type: " contentType "\r\n" # must!
if (Option["user-agent"])
header = header "User-Agent: " Option["user-agent"] "\r\n"
if (Cookie)
header = header "Cookie: " Cookie "\r\n"
if (HttpAuthUser && HttpAuthPass)
# TODO: digest auth
header = header "Proxy-Authorization: Basic " HttpAuthCredentials "\r\n"
content = NULLSTR; isBody = 0
while (1) {
print (header "\r\n" reqBody) |& HttpService
while ((HttpService |& getline) > 0) {
if (isBody)
content = content ? content "\n" $0 : $0
else if (length($0) <= 1)
isBody = 1
else { # interesting fields in header
match($0, /^HTTP[^ ]* ([^ ]*)/, group)
if (RSTART) status = group[1]
match($0, /^Location: (.*)/, group)
if (RSTART) location = squeeze(group[1]) # squeeze the URL!
}
l(sprintf("%4s bytes > %s", length($0), $0))
}
close(HttpService)
if (ERRNO == "Connection timed out") {
w("[WARNING] " ERRNO ". Retrying IPv4 connection.")
Option["ip-version"] = 4
initHttpService()
PROCINFO[HttpService, "READ_TIMEOUT"] = 0
ERRNO = ""
} else
break
}
if (status == "404") {
e("[ERROR] 404 Not Found")
exit 1
}
if ((status == "301" || status == "302") && location) {
url = "https" substr(url, 5) # switch to HTTPS; don't use location!
content = curlPost(url, reqBody)
}
return content
}
# Print a string (to output file or terminal pager).
function p(string) {
if (Option["view"]) {
print string | Option["pager"]
close(Option["pager"])
} else
print string > Option["output"]
}
# Play using a Text-to-Speech engine.
function play(text, tl, url, status) {
url = _TTSUrl(text, tl)
# Don't use getline from pipe here - the same pipe will be run only once for each AWK script!
status = system(Option["player"] " " parameterize(url) SUPOUT SUPERR)
if (status)
w("Voice output isn't available for " getName(tl))
return status
}
# Download audio from a Text-to-Speech engine.
function download_audio(text, tl, url, output) {
url = _TTSUrl(text, tl)
if (Option["download-audio-as"])
output = Option["download-audio-as"]
else
output = text " [" Option["engine"] "] (" Option["narrator"] ").ts"
if (url ~ /^\//)
system("mv -- " parameterize(url) " " parameterize(output))
else
curl(url, output)
}
# Get the translation of a string.
function getTranslation(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl) {
return _Translate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl)
}
# Translate a file.
function fileTranslation(uri, group, temp1, temp2) {
temp1 = Option["input"]
temp2 = Option["verbose"]
match(uri, /^file:\/\/(.*)/, group)
Option["input"] = group[1]
Option["verbose"] = 0
translateMain()
Option["input"] = temp1
Option["verbose"] = temp2
}
# Start a browser session and translate a web page.
function webTranslation(uri, sl, tl, hl, temp) {
temp = _WebTranslateUrl(uri, sl, tl, hl)
if (temp) {
p(temp)
if (Option["browser"] != NONE)
system(Option["browser"] " " parameterize(temp) SUPOUT SUPERR)
}
}
# Translate the source text (into all target languages).
function translate(text, inline,
####
i, j, playlist, il, saveSortedIn) {
if (!getCode(Option["hl"])) {
# Check if home language is supported
w("[WARNING] Unknown language code: " Option["hl"] ", fallback to English: en")
Option["hl"] = "en" # fallback to English
} else if (isRTL(Option["hl"])) {
# Check if home language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(Option["hl"]) " is a right-to-left language, but FriBidi is not found.")
}
if (!getCode(Option["sl"])) {
# Check if source language is supported
w("[WARNING] Unknown source language code: " Option["sl"])
} else if (isRTL(Option["sl"])) {
# Check if source language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(Option["sl"]) " is a right-to-left language, but FriBidi is not found.")
}
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in Option["tl"]) {
# Non-interactive verbose mode: separator between targets
if (!Option["interactive"])
if (Option["verbose"] && i > 1)
p(prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])))
if (inline &&
startsWithAny(text, UriSchemes) == "file://") {
# translate URL only from command-line parameters (inline)
fileTranslation(text)
} else if (inline &&
startsWithAny(text, UriSchemes) == "http://" ||
startsWithAny(text, UriSchemes) == "https://") {
# translate URL only from command-line parameters (inline)
webTranslation(text, Option["sl"], Option["tl"][i], Option["hl"])
} else {
if (!Option["no-translate"])
p(getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"] || Option["download-audio"], playlist, il))
else
il[0] = Option["sl"] == "auto" ? "en" : Option["sl"]
if (Option["play"] == 1) {
if (Option["player"])
for (j in playlist)
play(playlist[j]["text"], playlist[j]["tl"])
else if (SpeechSynthesizer)
for (j in playlist)
print playlist[j]["text"] | SpeechSynthesizer
} else if (Option["play"] == 2) {
if (Option["player"])
play(text, il[0])
else if (SpeechSynthesizer)
print text | SpeechSynthesizer
}
if (Option["download-audio"] == 1) {
# Download the translation unless used with -sp or -no-trans
if (Option["play"] != 2 && !Option["no-translate"])
download_audio(playlist[length(playlist) - 1]["text"], \
playlist[length(playlist) - 1]["tl"])
else
download_audio(text, il[0])
}
}
}
PROCINFO["sorted_in"] = saveSortedIn
}
# Translate the source text (from all source languages).
function translates(text, inline,
####
i) {
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in Option["sls"]) {
# Non-interactive verbose mode: separator between sources
if (!Option["interactive"])
if (Option["verbose"] && i > 1)
p(prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])))
Option["sl"] = Option["sls"][i]
translate(text, inline)
}
PROCINFO["sorted_in"] = saveSortedIn
}
# Read from input and translate each line.
function translateMain( i, line) {
if (Option["interactive"])
prompt()
if (Option["input"] == STDIN || fileExists(Option["input"])) {
i = 0
while (getline line < Option["input"])
if (line) {
# Non-interactive verbose mode: separator between sources
if (!Option["interactive"])
if (Option["verbose"] && i++ > 0)
p(prettify("source-seperator",
replicate(Option["chr-source-seperator"],
Option["width"])))
if (Option["interactive"])
repl(line)
else
translates(line)
} else {
# Non-interactive brief mode: preserve line breaks
if (!Option["interactive"])
if (!Option["verbose"])
p(line)
}
} else
e("[ERROR] File not found: " Option["input"])
}
translate-shell-0.9.6.11/include/TranslatorInterface.awk 0000664 0000000 0000000 00000003760 13516335241 0023162 0 ustar 00root root 0000000 0000000 ####################################################################
# TranslatorInterface.awk #
####################################################################
# Abstract method foobarInit(): ()
function _Init( vm) {
vm = engineMethod("Init")
return @vm()
}
# Abstract method foobarRequestUrl(text, sl, tl, hl: string): string
function _RequestUrl(text, sl, tl, hl, vm) {
vm = engineMethod("RequestUrl")
return @vm(text, sl, tl, hl)
}
# Abstract method foobarPostRequestUrl(text, sl, tl, hl, type: string): string
function _PostRequestUrl(text, sl, tl, hl, type, vm) {
vm = engineMethod("PostRequestUrl")
return @vm(text, sl, tl, hl, type)
}
# Abstract method foobarPostRequestContentType(text, sl, tl, hl, type: string): string
function _PostRequestContentType(text, sl, tl, hl, type, vm) {
vm = engineMethod("PostRequestContentType")
return @vm(text, sl, tl, hl, type)
}
# Abstract method foobarPostRequestBody(text, sl, tl, hl, type: string): string
function _PostRequestBody(text, sl, tl, hl, type, vm) {
vm = engineMethod("PostRequestBody")
return @vm(text, sl, tl, hl, type)
}
# Abstract method foobarTTSUrl(text, tl: string): string
function _TTSUrl(text, tl, vm) {
vm = engineMethod("TTSUrl")
return @vm(text, tl)
}
# Abstract method foobarWebTranslateUrl(uri, sl, tl, hl: string): string
function _WebTranslateUrl(uri, sl, tl, hl, vm) {
vm = engineMethod("WebTranslateUrl")
return @vm(uri, sl, tl, hl)
}
# Abstract method foobarTranslate(text, sl, tl, hl: string,
# isVerbose, toSpeech: boolean,
# returnPlaylist, returnIl: array): string
function _Translate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
vm) {
vm = engineMethod("Translate")
return @vm(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl)
}
translate-shell-0.9.6.11/include/Translators/ 0000775 0000000 0000000 00000000000 13516335241 0021012 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/include/Translators/*.awk 0000664 0000000 0000000 00000000364 13516335241 0021652 0 ustar 00root root 0000000 0000000 @include "include/Translators/GoogleTranslate.awk"
@include "include/Translators/BingTranslator.awk"
@include "include/Translators/YandexTranslate.awk"
@include "include/Translators/Apertium.awk"
@include "include/Translators/SpellChecker.awk"
translate-shell-0.9.6.11/include/Translators/Apertium.awk 0000664 0000000 0000000 00000010047 13516335241 0023306 0 ustar 00root root 0000000 0000000 ####################################################################
# Apertium.awk #
####################################################################
#
# Last Updated: 14 Mar 2016
BEGIN { provides("apertium") }
function apertiumInit() {
HttpProtocol = "http://"
HttpHost = "www.apertium.org"
HttpPort = 80
}
function apertiumRequestUrl(text, sl, tl, hl) {
return HttpPathPrefix "/apy/translate?" \
"langpair=" preprocess(sl) "|" preprocess(tl) \
"&q=" preprocess(text)
}
function apertiumTTSUrl(text, tl, narrator) {
# Not implemented
}
function apertiumWebTranslateUrl(uri, sl, tl, hl) {
# Not implemented
}
# Get the translation of a string.
function apertiumTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
r,
content, tokens, ast,
_sl, _tl, _hl, il,
translation,
wShowOriginal, wShowTranslation, wShowLanguages,
group, temp) {
if (!getCode(tl)) {
# Check if target language is supported
w("[WARNING] Unknown target language code: " tl)
} else if (isRTL(tl)) {
# Check if target language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
}
_sl = getCode(sl); if (!_sl) _sl = sl
_tl = getCode(tl); if (!_tl) _tl = tl
_hl = getCode(hl); if (!_hl) _hl = hl
# Quick hack: Apertium doesn't have an "auto" language code
_sl = "auto" == _sl ? "en" : _sl
content = getResponse(text, _sl, _tl, _hl)
if (Option["dump"])
return content
tokenize(tokens, content)
parseJson(ast, tokens)
l(content, "content", 1, 1)
l(tokens, "tokens", 1, 0, 1)
l(ast, "ast")
if (!isarray(ast) || !anything(ast)) {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
ExitCode = 1
return
}
translation = uprintf(unquote(unparameterize(ast[0 SUBSEP "responseData" SUBSEP "translatedText"])))
returnIl[0] = il = _sl
if (Option["verbose"] < -1)
return il
else if (Option["verbose"] < 0)
return getList(il)
# Generate output
if (!isVerbose) {
# Brief mode
r = translation
} else {
# Verbose mode
wShowOriginal = Option["show-original"]
wShowTranslation = Option["show-translation"]
wShowLanguages = Option["show-languages"]
if (wShowOriginal) {
# Display: original text
if (r) r = r RS RS
r = r m("-- display original text")
r = r prettify("original", s(text, il))
}
if (wShowTranslation) {
# Display: major translation
if (r) r = r RS RS
r = r m("-- display major translation")
r = r prettify("translation", s(translation, tl))
}
if (wShowLanguages) {
# Display: source language -> target language
if (r) r = r RS RS
r = r m("-- display source language -> target language")
temp = Option["fmt-languages"]
if (!temp) temp = "[ %s -> %t ]"
split(temp, group, /(%s|%S|%t|%T)/)
r = r prettify("languages", group[1])
if (temp ~ /%s/)
r = r prettify("languages-sl", getDisplay(il))
if (temp ~ /%S/)
r = r prettify("languages-sl", getName(il))
r = r prettify("languages", group[2])
if (temp ~ /%t/)
r = r prettify("languages-tl", getDisplay(tl))
if (temp ~ /%T/)
r = r prettify("languages-tl", getName(tl))
r = r prettify("languages", group[3])
}
}
if (toSpeech) {
returnPlaylist[0]["text"] = translation
returnPlaylist[0]["tl"] = _tl
}
return r
}
translate-shell-0.9.6.11/include/Translators/BingTranslator.awk 0000664 0000000 0000000 00000035544 13516335241 0024462 0 ustar 00root root 0000000 0000000 ####################################################################
# BingTranslator.awk #
####################################################################
#
# Last Updated: 25 Jul 2019
BEGIN { provides("bing") }
function bingInit() {
HttpProtocol = "http://"
HttpHost = "www.bing.com"
HttpPort = 80
}
# [OBSOLETE?] Retrieve the Cookie and set IG.
function bingSetIG( content, cookie, group, header, isBody,
url, status, location) {
url = HttpPathPrefix "/translator"
header = "GET " url " HTTP/1.1\r\n" \
"Host: " HttpHost "\r\n" \
"Connection: close\r\n"
if (Option["user-agent"])
header = header "User-Agent: " Option["user-agent"] "\r\n"
cookie = NULLSTR
print header |& HttpService
while ((HttpService |& getline) > 0) {
match($0, /Set-Cookie: ([^;]*);/, group)
if (group[1]) {
cookie = cookie (cookie ? "; " : NULLSTR) group[1]
}
if (isBody)
content = content ? content "\n" $0 : $0
else if (length($0) <= 1)
isBody = 1
else { # interesting fields in header
match($0, /^HTTP[^ ]* ([^ ]*)/, group)
if (RSTART) status = group[1]
match($0, /^Location: (.*)/, group)
if (RSTART) location = squeeze(group[1]) # squeeze the URL!
}
l(sprintf("%4s bytes > %s", length($0), length($0) < 1024 ? $0 : "..."))
}
close(HttpService)
if ((status == "301" || status == "302") && location)
content = curl(location)
# FIXME: cookie
Cookie = cookie
match(content, /IG:"([^"]+)"/, group)
if (group[1]) {
IG = group[1]
} else {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
exit 1
}
}
# FIXME!
function bingTTSUrl(text, tl,
####
country, gender, i, group,
header, content, isBody) {
gender = "female"
country = NULLSTR
split(Option["narrator"], group, ",")
for (i in group) {
if (group[i] ~ /^(f(emale)?|w(oman)?)$/)
gender = "female"
else if (group[i] ~ /^m(ale|an)?$/)
gender = "male"
else
country = group[i]
}
# Automatic ISO country code
if (country) tl = tl "-" country
else if (tl == "ar") tl = tl "-EG" # sometimes doesn't work. Why?
else if (tl == "da") tl = tl "-DK"
else if (tl == "de") tl = tl "-DE"
else if (tl == "en") tl = tl "-US"
else if (tl == "es") tl = tl "-ES"
else if (tl == "fi") tl = tl "-FI"
else if (tl == "fr") tl = tl "-FR"
else if (tl == "it") tl = tl "-IT"
else if (tl == "ja") tl = tl "-JP"
else if (tl == "ko") tl = tl "-KR"
else if (tl == "nl") tl = tl "-NL"
else if (tl == "nb") tl = tl "-NO" # Norwegian Bokmål
else if (tl == "pl") tl = tl "-PL"
else if (tl == "pt") tl = tl "-PT"
else if (tl == "ru") tl = tl "-RU"
else if (tl == "sv") tl = tl "-SE"
else if (tl == "yue") ;
else if (tl == "zh") tl = tl "-CN"
header = "GET " "/tspeak?" \
"&language=" tl "&text=" preprocess(text) \
"&options=" gender "&format=audio%2Fmp3" " HTTP/1.1\r\n" \
"Host: " HttpHost "\r\n" \
"Connection: close\r\n"
if (Option["user-agent"])
header = header "User-Agent: " Option["user-agent"] "\r\n"
if (Cookie)
header = header "Cookie: " Cookie "\r\n"
content = NULLSTR; isBody = 0
print header |& HttpService
while ((HttpService |& getline) > 0) {
if (isBody)
content = content ? content "\n" $0 : $0
else if (length($0) <= 1)
isBody = 1
#l(sprintf("%4s bytes > %s", length($0), $0))
}
close(HttpService)
if (!TempFile)
TempFile = getOutput("mktemp")
printf("%s", content) > TempFile
close(TempFile)
return TempFile
}
function bingWebTranslateUrl(uri, sl, tl, hl, _sl, _tl) {
# Hot-patches for language codes
_sl = sl; _tl = tl
if (_sl == "bs") _sl = "bs-Latn" # 'bs' is not recognized as valid code
if (_sl == "zh") _sl = "zh-CHS" # still old format
if (_sl == "zh-CN") _sl = "zh-CHS"
if (_sl == "zh-TW") _sl = "zh-CHT"
if (_tl == "bs") _tl = "bs-Latn"
if (_tl == "zh") _tl = "zh-CHS"
if (_tl == "zh-CN") _tl = "zh-CHS"
if (_tl == "zh-TW") _tl = "zh-CHT"
return "https://www.translatetheweb.com/?" "from=" _sl "&to=" _tl "&a=" uri
}
# [OBSOLETE?] Old dictionary API (via HTTP GET).
function bingRequestUrl(text, sl, tl, hl) {
return HttpPathPrefix "/translator/api/Dictionary/Lookup?" \
"from=" sl "&to=" tl "&text=" preprocess(text)
}
# Main Bing Translator API (via HTTP POST).
function bingPostRequestUrl(text, sl, tl, hl, type) {
if (type == "lookup")
return HttpPathPrefix "/tlookupv3"
#else if (type == "transliterate")
# return HttpPathPrefix "/ttransliteratev3"
else # type == "translate"
return HttpPathPrefix "/ttranslatev3"
}
function bingPostRequestContentType(text, sl, tl, hl, type) {
return "application/x-www-form-urlencoded"
}
function bingPostRequestBody(text, sl, tl, hl, type) {
if (type == "lookup")
return "&text=" quote(text) "&from=" sl "&to=" tl
#else if (type == "transliterate")
# return "&text=" quote(text) "&language=" sl "&toScript=" "latn"
else # type == "translate"
return "&text=" quote(text) "&fromLang=" sl "&to=" tl
}
# Get the translation of a string.
function bingTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
r,
content, tokens, ast, dicContent, dicTokens, dicAst,
_sl, _tl, _hl, il, isPhonetic,
translation, phonetics, oPhonetics,
wordClasses, words, wordBackTranslations,
wShowOriginal, wShowOriginalPhonetics,
wShowTranslation, wShowTranslationPhonetics,
wShowLanguages, wShowDictionary,
i, j, k, group, temp, saveSortedIn) {
isPhonetic = match(tl, /^@/)
tl = substr(tl, 1 + isPhonetic)
if (!getCode(tl)) {
# Check if target language is supported
w("[WARNING] Unknown target language code: " tl)
} else if (isRTL(tl)) {
# Check if target language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
}
_sl = getCode(sl); if (!_sl) _sl = sl
_tl = getCode(tl); if (!_tl) _tl = tl
_hl = getCode(hl); if (!_hl) _hl = hl
#bingSetIG() # set IG (no longer needed)
# Hot-patches for Bing's own translator language codes
# See:
if (_sl == "auto") _sl = "auto-detect"
if (_sl == "bs") _sl = "bs-Latn" # 'bs' is not recognized as valid code
if (_sl == "zh-CN") _sl = "zh-Hans"
if (_sl == "zh-TW") _sl = "zh-Hant"
if (_tl == "bs") _tl = "bs-Latn"
if (_tl == "zh-CN") _tl = "zh-Hans"
if (_tl == "zh-TW") _tl = "zh-Hant"
# Translation
content = postResponse(text, _sl, _tl, _hl, "translate")
if (content == "") {
# Empty content. Assume "301 Moved Permanently" and use cn.bing.com
HttpHost = "cn.bing.com"
# Just dirty hack
if (Option["proxy"]) {
HttpPathPrefix = HttpProtocol HttpHost
} else {
HttpService = "/" "inet" "/tcp/0/" HttpHost "/" HttpPort # FIXME: inet version
}
# Try again
content = postResponse(text, _sl, _tl, _hl, "translate")
}
if (Option["dump"])
return content
tokenize(tokens, content)
parseJson(ast, tokens)
l(content, "content", 1, 1)
l(tokens, "tokens", 1, 0, 1)
l(ast, "ast")
if (!isarray(ast) || !anything(ast)) {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
ExitCode = 1
return
}
translation = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "text"])
returnIl[0] = il = _sl == "auto-detect" ?
unparameterize(ast[0 SUBSEP 0 SUBSEP "detectedLanguage" SUBSEP "language"]) : _sl
if (Option["verbose"] < -1)
return il
if (Option["verbose"] < 0)
return getList(il)
# Transliteration
wShowTranslationPhonetics = Option["show-translation-phonetics"]
if (wShowTranslationPhonetics) {
split(_tl, group, "-")
#content = postResponse(translation, group[1], group[1], _hl, "transliterate")
#phonetics = unparameterize(content)
phonetics = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "transliteration" \
SUBSEP "text"])
if (phonetics == translation) phonetics = ""
}
# Generate output
if (!isVerbose) {
# Brief mode
r = isPhonetic && phonetics ?
prettify("brief-translation-phonetics", join(phonetics, " ")) :
prettify("brief-translation", s(translation, tl))
} else {
# Verbose mode
wShowOriginal = Option["show-original"]
wShowTranslation = Option["show-translation"]
wShowLanguages = Option["show-languages"]
wShowDictionary = Option["show-dictionary"]
# Transliteration (original)
wShowOriginalPhonetics = Option["show-original-phonetics"]
if (wShowOriginalPhonetics) {
split(_sl, group, "-")
#content = postResponse(text, group[1], group[1], _hl, "transliterate")
#oPhonetics = unparameterize(content)
delete ast # purge old AST
content = postResponse(text, il, il, _hl, "translate")
tokenize(tokens, content)
parseJson(ast, tokens)
oPhonetics = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 \
SUBSEP "transliteration" SUBSEP "text"])
if (oPhonetics == text) oPhonetics = ""
}
if (!oPhonetics) wShowOriginalPhonetics = 0
if (!phonetics) wShowTranslationPhonetics = 0
if (wShowOriginal) {
# Display: original text & phonetics
if (r) r = r RS RS
r = r m("-- display original text")
r = r prettify("original", s(text, _sl))
if (wShowOriginalPhonetics)
r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), _sl))
}
if (wShowTranslation) {
# Display: major translation & phonetics
if (r) r = r RS RS
r = r m("-- display major translation")
r = r prettify("translation", s(translation, tl))
if (wShowTranslationPhonetics)
r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
}
if (wShowLanguages) {
# Display: source language -> target language
if (r) r = r RS RS
r = r m("-- display source language -> target language")
temp = Option["fmt-languages"]
if (!temp) temp = "[ %s -> %t ]"
split(temp, group, /(%s|%S|%t|%T)/)
r = r prettify("languages", group[1])
if (temp ~ /%s/)
r = r prettify("languages-sl", getDisplay(il))
if (temp ~ /%S/)
r = r prettify("languages-sl", getName(il))
r = r prettify("languages", group[2])
if (temp ~ /%t/)
r = r prettify("languages-tl", getDisplay(tl))
if (temp ~ /%T/)
r = r prettify("languages-tl", getName(tl))
r = r prettify("languages", group[3])
}
if (wShowDictionary) {
# Dictionary API
dicContent = postResponse(text, il, _tl, _hl, "lookup")
if (dicContent != "") {
tokenize(dicTokens, dicContent)
parseJson(dicAst, dicTokens)
l(dicContent, "dicContent", 1, 1)
l(dicTokens, "dicTokens", 1, 0, 1)
l(dicAst, "dicAst")
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "compareByIndexFields"
for (i in dicAst) {
if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP \
"posTag$", group))
wordClasses[group[1]] = tolower(literal(dicAst[i]))
}
for (i in dicAst) {
if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP \
"displayTarget$", group))
words[wordClasses[group[1]]][group[1]] = literal(dicAst[i])
if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP \
"backTranslations" SUBSEP "([[:digit:]]+)" SUBSEP "displayText$", group))
wordBackTranslations[wordClasses[group[1]]][group[1]][group[2]] = literal(dicAst[i])
}
PROCINFO["sorted_in"] = saveSortedIn
# Display: dictionary entries
if (r) r = r RS
r = r m("-- display dictionary entries")
for (i = 0; i < length(words); i++) {
r = (i > 0 ? r RS : r) RS prettify("dictionary-word-class", s(wordClasses[i], hl))
for (j in words[wordClasses[i]]) {
r = r RS prettify("dictionary-word", ins(1, words[wordClasses[i]][j], tl))
if (isRTL(il))
explanation = join(wordBackTranslations[wordClasses[i]][j], ", ")
else {
explanation = prettify("dictionary-explanation-item",
wordBackTranslations[wordClasses[i]][j][0])
for (k = 1; k < length(wordBackTranslations[wordClasses[i]][j]); k++)
explanation = explanation prettify("dictionary-explanation", ", ") \
prettify("dictionary-explanation-item",
wordBackTranslations[wordClasses[i]][j][k])
}
if (isRTL(il))
r = r RS prettify("dictionary-explanation-item", ins(2, explanation, il))
else
r = r RS ins(2, explanation)
}
}
}
}
}
if (toSpeech) {
returnPlaylist[0]["text"] = translation
returnPlaylist[0]["tl"] = _tl
}
return r
}
translate-shell-0.9.6.11/include/Translators/GoogleTranslate.awk 0000664 0000000 0000000 00000052642 13516335241 0024621 0 ustar 00root root 0000000 0000000 ####################################################################
# GoogleTranslate.awk #
####################################################################
#
# Last Updated: 25 Jul 2019
BEGIN { provides("google") }
# FIXME!
# See:
function genRL(a, x,
####
b, c, d, i, y) {
tokenize(y, x)
parseList(b, y)
i = SUBSEP 0
for (c = 0; c < length(b[i]) - 2; c += 3) {
d = b[i][c + 2]
d = d >= 97 ? d - 87 :
d - 48 # convert to number
d = b[i][c + 1] == 43 ? rshift(a, d) : lshift(a, d)
a = b[i][c] == 43 ? and(a + d, 4294967295) : xor(a, d)
}
return a
}
function genTK(text,
####
a, d, dLen, e, tkk, ub, vb) {
if (TK[text]) return TK[text]
tkk = systime() / 3600
ub = "[43,45,51,94,43,98,43,45,102]"
vb = "[43,45,97,94,43,54]"
# FIXME: build a dump cache!
dLen = dump(text, d) # convert to byte array
a = tkk
for (e = 1; e <= dLen; e++)
a = genRL(a + d[e], vb)
a = genRL(a, ub)
0 > a && (a = and(a, 2147483647) + 2147483648)
a %= 1e6
TK[text] = a "." xor(a, tkk)
l(text, "text")
l(tkk, "tkk")
l(TK[text], "tk")
return TK[text]
}
function googleInit() {
HttpProtocol = "http://"
HttpHost = "translate.googleapis.com"
HttpPort = 80
}
function googleRequestUrl(text, sl, tl, hl, qc) {
qc = Option["no-autocorrect"] ? "qc" : "qca";
return HttpPathPrefix "/translate_a/single?client=gtx" \
"&ie=UTF-8&oe=UTF-8" \
"&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=gt" \
"&dt=" qc "&sl=" sl "&tl=" tl "&hl=" hl \
"&q=" preprocessByDump(text)
}
function googleTTSUrl(text, tl) {
return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx" \
"&tl=" tl "&q=" preprocessByDump(text)
}
function googleWebTranslateUrl(uri, sl, tl, hl) {
return "https://translate.google.com/translate?" \
"hl=" hl "&sl=" sl "&tl=" tl "&u=" uri
}
# Get the translation of a string.
function googleTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
r,
content, tokens, ast,
_sl, _tl, _hl, il, ils, isPhonetic,
article, example, explanation, ref, word,
translation, translations, phonetics,
wordClasses, words, segments, altTranslations,
original, oPhonetics, oWordClasses, oWords,
oRefs, oSynonymClasses, oSynonyms,
oExamples, oSeeAlso,
wShowOriginal, wShowOriginalPhonetics,
wShowTranslation, wShowTranslationPhonetics,
wShowPromptMessage, wShowLanguages,
wShowOriginalDictionary, wShowDictionary,
wShowAlternatives,
genderedTrans, hasWordClasses, hasAltTranslations,
i, j, k, group, temp, saveSortedIn) {
isPhonetic = match(tl, /^@/)
tl = substr(tl, 1 + isPhonetic)
if (!getCode(tl)) {
# Check if target language is supported
w("[WARNING] Unknown target language code: " tl)
} else if (isRTL(tl)) {
# Check if target language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
}
# Convert codes or aliases to standard codes used by Google Translate
# If the code or alias cannot be found, use as it is
_sl = getCode(sl); if (!_sl) _sl = sl
_tl = getCode(tl); if (!_tl) _tl = tl
_hl = getCode(hl); if (!_hl) _hl = hl
content = getResponse(text, _sl, _tl, _hl)
if (Option["dump"])
return content
tokenize(tokens, content)
parseJsonArray(ast, tokens)
l(content, "content", 1, 1)
l(tokens, "tokens", 1, 0, 1)
l(ast, "ast")
if (!isarray(ast) || !anything(ast)) {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
ExitCode = 1
return
}
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "compareByIndexFields"
for (i in ast) {
if (ast[i] == "null") continue
if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "0$")
append(translations, literal(ast[i]))
if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "1$")
append(original, literal(ast[i]))
if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "2$")
append(phonetics, literal(ast[i]))
if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "3$")
append(oPhonetics, literal(ast[i]))
# 1 - word classes and explanations
if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
wordClasses[group[1]] = literal(ast[i])
if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "([[:digit:]]+)$", group))
words[group[1]][group[2]][group[3]] = literal(ast[i])
if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)$", group))
words[group[1]][group[2]]["1"][group[3]] = literal(ast[i])
# 5 - alternative translations
if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group)) {
segments[group[1]] = literal(ast[i])
altTranslations[group[1]][0] = ""
}
if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
altTranslations[group[1]][group[2]] = literal(ast[i])
# 7 - autocorrection
if (i ~ "^0" SUBSEP "7" SUBSEP "5$") {
if (ast[i] == "true")
w("Showing translation for: (use -no-auto to disable autocorrect)")
else
w("Did you mean: " \
ansi("bold", unparameterize(ast["0" SUBSEP "7" SUBSEP "1"])))
}
# 8 - identified source languages
if (i ~ "^0" SUBSEP "8" SUBSEP "0" SUBSEP "[[:digit:]]+$" ||
i ~ "^0" SUBSEP "2$")
append(ils, literal(ast[i]))
# 11 - (original) word classes and synonyms
if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
oSynonymClasses[group[1]] = literal(ast[i])
if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
if (ast[i]) {
oRefs[literal(ast[i])][1] = group[1]
oRefs[literal(ast[i])][2] = group[2]
}
if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
oSynonyms[group[1]][group[2]][group[3]] = literal(ast[i])
# 12 - (original) word classes and explanations
if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
oWordClasses[group[1]] = literal(ast[i])
if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
oWords[group[1]][group[2]][0] = literal(ast[i])
if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
oWords[group[1]][group[2]][1] = literal(ast[i])
if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2$", group))
oWords[group[1]][group[2]][2] = literal(ast[i])
# 13 - (original) examples
if (match(i, "^0" SUBSEP "13" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
oExamples[group[1]] = literal(ast[i])
# 14 - (original) see also
if (match(i, "^0" SUBSEP "14" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
oSeeAlso[group[1]] = literal(ast[i])
# 18 - gender-specific translations
if (match(i, "^0" SUBSEP "18" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
genderedTrans[group[1]] = literal(ast[i])
}
PROCINFO["sorted_in"] = saveSortedIn
translation = join(translations)
returnIl[0] = il = !anything(ils) || belongsTo(sl, ils) ? sl : ils[0]
if (Option["verbose"] < -1)
return il
else if (Option["verbose"] < 0)
return getList(il)
# Generate output
if (!isVerbose) {
# Brief mode
r = isPhonetic && anything(phonetics) ?
prettify("brief-translation-phonetics", join(phonetics, " ")) :
prettify("brief-translation", s(translation, tl))
if (toSpeech) {
returnPlaylist[0]["text"] = translation
returnPlaylist[0]["tl"] = _tl
}
} else {
# Verbose mode
wShowOriginal = Option["show-original"]
wShowOriginalPhonetics = Option["show-original-phonetics"]
wShowTranslation = Option["show-translation"]
wShowTranslationPhonetics = Option["show-translation-phonetics"]
wShowPromptMessage = Option["show-prompt-message"]
wShowLanguages = Option["show-languages"]
wShowOriginalDictionary = Option["show-original-dictionary"]
wShowDictionary = Option["show-dictionary"]
wShowAlternatives = Option["show-alternatives"]
if (!anything(oPhonetics)) wShowOriginalPhonetics = 0
if (!anything(phonetics)) wShowTranslationPhonetics = 0
if (getCode(il) == getCode(tl) && \
(isarray(oWordClasses) || isarray(oSynonymClasses) || \
isarray(oExamples) || isarray(oSeeAlso))) {
wShowOriginalDictionary = 1
wShowTranslation = 0
}
hasWordClasses = exists(wordClasses)
hasAltTranslations = exists(altTranslations[0])
if (!hasWordClasses && !hasAltTranslations)
wShowPromptMessage = wShowLanguages = 0
if (!hasWordClasses) wShowDictionary = 0
if (!hasAltTranslations) wShowAlternatives = 0
if (wShowOriginal) {
# Display: original text & phonetics
if (r) r = r RS RS
r = r m("-- display original text & phonetics")
r = r prettify("original", s(join(original, " "), il))
if (wShowOriginalPhonetics)
r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), il))
}
if (wShowTranslation) {
# Display: major translation & phonetics
if (r) r = r RS RS
r = r m("-- display major translation & phonetics")
if (!exists(genderedTrans))
r = r prettify("translation", s(translation, tl))
else {
r = r prettify("prompt-message", s("(♂) ", hl))
r = r prettify("translation", s(genderedTrans[0], tl)) RS
r = r prettify("prompt-message", s("(♀) ", hl))
r = r prettify("translation", s(genderedTrans[1], tl))
}
if (wShowTranslationPhonetics)
r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
}
if (wShowPromptMessage || wShowLanguages)
if (r) r = r RS
if (wShowPromptMessage) {
if (hasWordClasses) {
# Display: prompt message (Definitions of ...)
if (r) r = r RS
r = r m("-- display prompt message (Definitions of ...)")
if (isRTL(hl)) # home language is R-to-L
r = r prettify("prompt-message", s(showDefinitionsOf(hl, join(original, " "))))
else { # home language is L-to-R
split(showDefinitionsOf(hl, "\0%s\0"), group, "\0")
for (i = 1; i <= length(group); i++) {
if (group[i] == "%s")
r = r prettify("prompt-message-original", show(join(original, " "), il))
else
r = r prettify("prompt-message", group[i])
}
}
} else if (hasAltTranslations) {
# Display: prompt message (Translations of ...)
if (r) r = r RS
r = r m("-- display prompt message (Translations of ...)")
if (isRTL(hl)) # home language is R-to-L
r = r prettify("prompt-message", s(showTranslationsOf(hl, join(original, " "))))
else { # home language is L-to-R
split(showTranslationsOf(hl, "\0%s\0"), group, "\0")
for (i = 1; i <= length(group); i++) {
if (group[i] == "%s")
r = r prettify("prompt-message-original", show(join(original, " "), il))
else
r = r prettify("prompt-message", group[i])
}
}
}
}
if (wShowLanguages) {
# Display: source language -> target language
if (r) r = r RS
r = r m("-- display source language -> target language")
temp = Option["fmt-languages"]
if (!temp) temp = "[ %s -> %t ]"
split(temp, group, /(%s|%S|%t|%T)/)
r = r prettify("languages", group[1])
if (temp ~ /%s/)
r = r prettify("languages-sl", getDisplay(il))
if (temp ~ /%S/)
r = r prettify("languages-sl", getName(il))
r = r prettify("languages", group[2])
if (temp ~ /%t/)
r = r prettify("languages-tl", getDisplay(tl))
if (temp ~ /%T/)
r = r prettify("languages-tl", getName(tl))
r = r prettify("languages", group[3])
}
if (wShowOriginalDictionary) {
# Display: original dictionary
if (exists(oWordClasses)) {
# Detailed explanations
if (r) r = r RS
r = r m("-- display original dictionary (detailed explanations)")
for (i = 0; i < length(oWordClasses); i++) {
r = (i > 0 ? r RS : r) RS prettify("original-dictionary-detailed-word-class", s(oWordClasses[i], hl))
for (j = 0; j < length(oWords[i]); j++) {
explanation = oWords[i][j][0]
ref = oWords[i][j][1]
example = oWords[i][j][2]
r = (j > 0 ? r RS : r) RS prettify("original-dictionary-detailed-explanation", ins(1, explanation, il))
if (example)
r = r RS prettify("original-dictionary-detailed-example", ins(2, "- \"" example "\"", il))
if (ref && isarray(oRefs[ref])) {
temp = prettify("original-dictionary-detailed-synonyms", ins(1, show(showSynonyms(hl), hl) ": "))
temp = temp prettify("original-dictionary-detailed-synonyms-item", show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][0], il))
for (k = 1; k < length(oSynonyms[oRefs[ref][1]][oRefs[ref][2]]); k++)
temp = temp prettify("original-dictionary-detailed-synonyms", ", ") \
prettify("original-dictionary-detailed-synonyms-item", show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][k], il))
r = r RS temp
}
}
}
}
if (exists(oSynonymClasses)) {
# Synonyms
r = r RS RS
r = r m("-- display original dictionary (synonyms)")
r = r prettify("original-dictionary-synonyms", s(showSynonyms(hl), hl))
for (i = 0; i < length(oSynonymClasses); i++) {
r = (i > 0 ? r RS : r) RS prettify("original-dictionary-synonyms-word-class", ins(1, oSynonymClasses[i], hl))
for (j = 0; j < length(oSynonyms[i]); j++) {
temp = prettify("original-dictionary-synonyms-synonyms", ins(2, "- "))
temp = temp prettify("original-dictionary-synonyms-synonyms-item", show(oSynonyms[i][j][0], il))
for (k = 1; k < length(oSynonyms[i][j]); k++)
temp = temp prettify("original-dictionary-synonyms-synonyms", ", ") \
prettify("original-dictionary-synonyms-synonyms-item", show(oSynonyms[i][j][k], il))
r = r RS temp
}
}
}
if (exists(oExamples)) {
# Examples
r = r RS RS
r = r m("-- display original dictionary (examples)")
r = r prettify("original-dictionary-examples", s(showExamples(hl), hl))
for (i = 0; i < length(oExamples); i++) {
example = oExamples[i]
temp = prettify("original-dictionary-examples-example", ins(1, "- "))
split(example, group, /(|<\/b>)/)
if (group[3] ~ / [[:punct:].]/)
group[3] = substr(group[3], 2)
if (isRTL(il)) # target language is R-to-L
temp = temp show(group[1] group[2] group[3], il)
else # target language is L-to-R
temp = temp prettify("original-dictionary-examples-example", group[1]) \
prettify("original-dictionary-examples-original", group[2]) \
prettify("original-dictionary-examples-example", group[3])
r = (i > 0 ? r RS : r) RS temp
}
}
if (exists(oSeeAlso)) {
# See also
r = r RS RS
r = r m("-- display original dictionary (see also)")
r = r prettify("original-dictionary-see-also", s(showSeeAlso(hl), hl))
temp = ins(1, prettify("original-dictionary-see-also-phrases-item", show(oSeeAlso[0], il)))
for (k = 1; k < length(oSeeAlso); k++)
temp = temp prettify("original-dictionary-see-also-phrases", ", ") \
prettify("original-dictionary-see-also-phrases-item", show(oSeeAlso[k], il))
r = r RS temp
}
}
if (wShowDictionary) {
# Display: dictionary entries
if (r) r = r RS
r = r m("-- display dictionary entries")
for (i = 0; i < length(wordClasses); i++) {
r = (i > 0 ? r RS : r) RS prettify("dictionary-word-class", s(wordClasses[i], hl))
for (j = 0; j < length(words[i]); j++) {
word = words[i][j][0]
article = words[i][j][4]
if (isRTL(il))
explanation = join(words[i][j][1], ", ")
else {
explanation = prettify("dictionary-explanation-item", words[i][j][1][0])
for (k = 1; k < length(words[i][j][1]); k++)
explanation = explanation prettify("dictionary-explanation", ", ") \
prettify("dictionary-explanation-item", words[i][j][1][k])
}
r = r RS prettify("dictionary-word", ins(1, (article ? "(" article ") " : "") word, tl))
if (isRTL(il))
r = r RS prettify("dictionary-explanation-item", ins(2, explanation, il))
else
r = r RS ins(2, explanation)
}
}
}
if (wShowAlternatives) {
# Display: alternative translations
if (r) r = r RS RS
r = r m("-- display alternative translations")
for (i = 0; i < length(altTranslations); i++) {
r = (i > 0 ? r RS : r) prettify("alternatives-original", show(segments[i], il))
if (isRTL(tl)) {
temp = join(altTranslations[i], ", ")
r = r RS prettify("alternatives-translations-item", ins(1, temp, tl))
} else {
temp = prettify("alternatives-translations-item", altTranslations[i][0])
for (j = 1; j < length(altTranslations[i]); j++)
temp = temp prettify("alternatives-translations", ", ") \
prettify("alternatives-translations-item", altTranslations[i][j])
r = r RS ins(1, temp)
}
}
}
if (toSpeech) {
if (index(showTranslationsOf(hl, "%s"), "%s") > 2) {
returnPlaylist[0]["text"] = showTranslationsOf(hl)
returnPlaylist[0]["tl"] = _hl
returnPlaylist[1]["text"] = join(original)
returnPlaylist[1]["tl"] = il
} else {
returnPlaylist[0]["text"] = join(original)
returnPlaylist[0]["tl"] = il
returnPlaylist[1]["text"] = showTranslationsOf(hl)
returnPlaylist[1]["tl"] = _hl
}
returnPlaylist[2]["text"] = translation
returnPlaylist[2]["tl"] = _tl
}
}
return r
}
translate-shell-0.9.6.11/include/Translators/SpellChecker.awk 0000664 0000000 0000000 00000006043 13516335241 0024065 0 ustar 00root root 0000000 0000000 ####################################################################
# SpellChecker.awk #
####################################################################
BEGIN {
provides("spell")
provides("aspell")
provides("hunspell")
}
# Detect external (ispell -a compatible) spell checker.
function spellInit() {
Ispell = detectProgram("aspell", "--version") ? "aspell" :
(detectProgram("hunspell", "--version") ? "hunspell" : "")
if (!Ispell) {
e("[ERROR] Spell checker (aspell or hunspell) not found.")
exit 1
}
}
function aspellInit() {
if (!(Ispell = detectProgram("aspell", "--version") ? "aspell" : "")) {
e("[ERROR] Spell checker (aspell) not found.")
exit 1
}
}
function hunspellInit() {
if (!(Ispell = detectProgram("hunspell", "--version") ? "hunspell" : "")) {
e("[ERROR] Spell checker (hunspell) not found.")
exit 1
}
}
# Check a string.
function spellTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
args, i, j, r, line, group, word, sug) {
args = " -a" (sl != "auto" ? " -d " sl : "")
if (system("echo" PIPE Ispell args SUPOUT SUPERR)) {
e("[ERROR] No dictionary for language: " sl)
exit 1
}
i = 1
r = ""
while ((("echo " parameterize(text) PIPE Ispell args SUPERR) |& getline line) > 0) {
match(line,
/^& (.*) [[:digit:]]+ [[:digit:]]+: ([^,]+)(, ([^,]+))?(, ([^,]+))?/,
group)
if (RSTART) {
ExitCode = 1 # found a spelling error
word = group[1]
sug = "[" group[2]
if (group[4]) sug = sug "|" group[4]
if (group[6]) sug = sug "|" group[6]
sug = sug "]"
j = i + index(substr(text, i), word) - 1
r = r substr(text, i, j - i)
r = r ansi("bold", ansi("red", word)) ansi("yellow", sug)
i = j + length(word)
}
}
r = r substr(text, i)
return r
}
function aspellTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl) {
return spellTranslate(text, sl, tl, hl)
}
function hunspellTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl) {
return spellTranslate(text, sl, tl, hl)
}
function spellTTSUrl(text, tl, narrator) {
e("[ERROR] Spell checker does not support TTS.")
ExitCode = 1
return
}
function aspellTTSUrl(text, tl, narrator) {
return spellTTSUrl(text, tl)
}
function hunspellTTSUrl(text, tl, narrator) {
return spellTTSUrl(text, tl)
}
function spellWebTranslateUrl(uri, sl, tl, hl) {
e("[ERROR] Spell checker does not support web translation.")
ExitCode = 1
return
}
function aspellWebTranslateUrl(uri, sl, tl, hl) {
return spellWebTranslateUrl(uri, sl, tl, hl)
}
function hunspellWebTranslateUrl(uri, sl, tl, hl) {
return spellWebTranslateUrl(uri, sl, tl, hl)
}
translate-shell-0.9.6.11/include/Translators/YandexTranslate.awk 0000664 0000000 0000000 00000026410 13516335241 0024627 0 ustar 00root root 0000000 0000000 ####################################################################
# YandexTranslate.awk #
####################################################################
#
# Last Updated: 11 Aug 2018
BEGIN { provides("yandex") }
function genSID( content, group, temp) {
content = curl("http://translate.yandex.com")
match(content, /SID:[[:space:]]*'([^']+)'/, group)
if (group[1]) {
split(group[1], temp, ".")
SID = reverse(temp[1]) "." reverse(temp[2]) "." reverse(temp[3])
} else {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
exit 1
}
}
function yandexInit() {
genSID() # generate a one-time key
YandexWebTranslate = "z5h64q92x9.net" # host for web translation
HttpProtocol = "http://"
HttpHost = "translate.yandex.net"
HttpPort = 80
}
function yandexRequestUrl(text, sl, tl, hl, group) {
# Quick hack: Yandex doesn't support digraphia code (yet)
split(sl, group, "-"); sl = group[1]
split(tl, group, "-"); tl = group[1]
return HttpPathPrefix "/api/v1/tr.json/translate?" \
"id=" SID "-0-0&srv=tr-text" \
"&text=" preprocess(text) "&lang=" (sl == "auto" ? tl : sl "-" tl)
}
function yandexPostRequestBody(text, sl, tl, hl, type) {
# type == "translit"
return "text=" quote(text) "&lang=" sl
}
function yandexGetDictionaryResponse(text, sl, tl, hl, content, header, isBody, url) {
# Quick hack: Yandex doesn't support digraphia code (yet)
split(sl, group, "-"); sl = group[1]
split(tl, group, "-"); tl = group[1]
url = "http://dictionary.yandex.net/dicservice.json/lookupMultiple?" \
"&text=" preprocess(text) "&dict=" sl "-" tl
content = curl(url) # but why?!
return assert(content, "[ERROR] Null response.")
}
function yandexTTSUrl(text, tl,
####
speaker, emotion, i, group) {
speaker = NULLSTR
emotion = NULLSTR
split(Option["narrator"], group, ",")
for (i in group) {
if (group[i] ~ /^(g(ood)?|n(eutral)?|e(vil)?)$/)
emotion = group[i]
else if (group[i] ~ /^(f(emale)?|w(oman)?)$/)
speaker = "alyss"
else if (group[i] ~ /^m(ale|an)?$/)
speaker = "zahar"
else
speaker = group[i]
}
switch (tl) { # List of available TTS language codes
case "ar": tl = "ar_AE"; break
case "cs": tl = "cs_CZ"; break
case "da": tl = "da_DK"; break
case "de": tl = "de_DE"; break
case "el": tl = "el_GR"; break
case "en": tl = "en_GB"; break
case "es": tl = "es_ES"; break
case "fi": tl = "fi_FI"; break
case "fr": tl = "fr_FR"; break
case "it": tl = "it_IT"; break
case "nl": tl = "nl_NL"; break
case "no": tl = "no_NO"; break
case "pl": tl = "pl_PL"; break
case "pt": tl = "pt_PT"; break
case "ru": tl = "ru_RU"; break
case "sv": tl = "sv_SE"; break
case "tr": tl = "tr_TR"; break
default: tl = NULLSTR
}
return HttpProtocol "tts.voicetech.yandex.net" "/tts?" \
"text=" preprocess(text) (tl ? "&lang=" tl : tl) \
(speaker ? "&speaker=" speaker : speaker) \
(emotion ? "&emotion=" emotion : emotion) \
"&format=mp3" "&quality=hi"
}
function yandexWebTranslateUrl(uri, sl, tl, hl) {
gsub(/:\/\//, "/", uri)
return HttpProtocol YandexWebTranslate "/proxy_u/" \
(sl == "auto" ? tl : sl "-" tl)"/" uri
}
# Get the translation of a string.
function yandexTranslate(text, sl, tl, hl,
isVerbose, toSpeech, returnPlaylist, returnIl,
####
r,
content, tokens, ast,
_sl, _tl, _hl, il, isPhonetic,
translation,
wShowOriginal, wShowTranslation, wShowLanguages,
wShowDictionary, dicContent, dicTokens, dicAst,
i, syn, mean,
group, temp) {
isPhonetic = match(tl, /^@/)
tl = substr(tl, 1 + isPhonetic)
if (!getCode(tl)) {
# Check if target language is supported
w("[WARNING] Unknown target language code: " tl)
} else if (isRTL(tl)) {
# Check if target language is R-to-L
if (!FriBidi)
w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
}
_sl = getCode(sl); if (!_sl) _sl = sl
_tl = getCode(tl); if (!_tl) _tl = tl
_hl = getCode(hl); if (!_hl) _hl = hl
content = getResponse(text, _sl, _tl, _hl)
if (Option["dump"])
return content
tokenize(tokens, content)
parseJson(ast, tokens)
l(content, "content", 1, 1)
l(tokens, "tokens", 1, 0, 1)
l(ast, "ast")
if (!isarray(ast) || !anything(ast)) {
e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
ExitCode = 1
return
}
if (ast[0 SUBSEP "code"] != "200") {
e("[ERROR] " unparameterize(ast[0 SUBSEP "message"]))
ExitCode = 1
return
}
translation = unparameterize(ast[0 SUBSEP "text" SUBSEP 0])
# Transliteration
wShowTranslationPhonetics = Option["show-translation-phonetics"]
if (wShowTranslationPhonetics && _tl != "emj") {
split(_tl, group, "-")
data = yandexPostRequestBody(translation, group[1], group[1], _hl, "translit")
content = curlPost("https://translate.yandex.net/translit/translit", data)
phonetics = (content ~ /not supported$/) ? "" : unparameterize(content)
}
split(unparameterize(ast[0 SUBSEP "lang"]), group, "-")
returnIl[0] = il = group[1]
if (Option["verbose"] < -1)
return il
else if (Option["verbose"] < 0)
return getList(il)
# Generate output
if (!isVerbose) {
# Brief mode
r = isPhonetic && phonetics ?
prettify("brief-translation-phonetics", join(phonetics, " ")) :
prettify("brief-translation", s(translation, tl))
} else {
# Verbose mode
wShowOriginal = Option["show-original"]
wShowTranslation = Option["show-translation"]
wShowLanguages = Option["show-languages"]
wShowDictionary = Option["show-dictionary"]
# Transliteration (original)
wShowOriginalPhonetics = Option["show-original-phonetics"]
if (wShowTranslationPhonetics && il != "emj") {
split(il, group, "-")
data = yandexPostRequestBody(text, group[1], group[1], _hl, "translit")
content = curlPost("https://translate.yandex.net/translit/translit", data)
oPhonetics = (content ~ /not supported$/) ? "" : unparameterize(content)
}
if (!oPhonetics) wShowOriginalPhonetics = 0
if (!phonetics) wShowTranslationPhonetics = 0
if (wShowOriginal) {
# Display: original text & phonetics
if (r) r = r RS RS
r = r m("-- display original text & phonetics")
r = r prettify("original", s(text, il))
if (wShowOriginalPhonetics)
r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), il))
}
if (wShowTranslation) {
# Display: major translation & phonetics
if (r) r = r RS RS
r = r m("-- display major translation")
r = r prettify("translation", s(translation, tl))
if (wShowTranslationPhonetics)
r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
}
if (wShowLanguages) {
# Display: source language -> target language
if (r) r = r RS RS
r = r m("-- display source language -> target language")
temp = Option["fmt-languages"]
if (!temp) temp = "[ %s -> %t ]"
split(temp, group, /(%s|%S|%t|%T)/)
r = r prettify("languages", group[1])
if (temp ~ /%s/)
r = r prettify("languages-sl", getDisplay(il))
if (temp ~ /%S/)
r = r prettify("languages-sl", getName(il))
r = r prettify("languages", group[2])
if (temp ~ /%t/)
r = r prettify("languages-tl", getDisplay(tl))
if (temp ~ /%T/)
r = r prettify("languages-tl", getName(tl))
r = r prettify("languages", group[3])
}
if (wShowDictionary && false) { # FIXME!
# Dictionary API
dicContent = yandexGetDictionaryResponse(text, il, _tl, _hl)
tokenize(dicTokens, dicContent)
parseJson(dicAst, dicTokens)
if (anything(dicAst)) {
# Display: dictionary entries
if (r) r = r RS
r = r m("-- display dictionary entries")
saveSortedIn = PROCINFO["sorted_in"]
PROCINFO["sorted_in"] = "@ind_num_asc"
for (i in dicAst) {
if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP \
"pos$") {
r = r RS prettify("dictionary-word-class", s((literal(dicAst[i])), hl))
syn = mean = ""
}
# TODO: ex, gen, ...
if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP \
"tr" SUBSEP "[[:digit:]]+" SUBSEP \
"mean" SUBSEP "[[:digit:]]+" SUBSEP "text") {
if (mean) {
mean = mean prettify("dictionary-explanation", ", ") \
prettify("dictionary-explanation-item", s((literal(dicAst[i])), sl))
} else {
mean = prettify("dictionary-explanation-item", s((literal(dicAst[i])), sl))
}
}
if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP \
"tr" SUBSEP "[[:digit:]]+" SUBSEP \
"syn" SUBSEP "[[:digit:]]+" SUBSEP "text") {
if (syn) {
syn = syn prettify("dictionary-explanation", ", ") \
prettify("dictionary-word", s((literal(dicAst[i])), il))
} else {
syn = prettify("dictionary-word", s((literal(dicAst[i])), il))
}
}
if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP \
"tr" SUBSEP "[[:digit:]]+" SUBSEP "text$") {
text = prettify("dictionary-word", s((literal(dicAst[i])), il))
if (syn) {
r = r RS ins(1, text prettify("dictionary-explanation", ", ") syn)
} else {
r = r RS ins(1, text)
}
r = r RS ins(2, mean)
syn = mean = ""
}
}
PROCINFO["sorted_in"] = saveSortedIn
}
}
}
if (toSpeech) {
returnPlaylist[0]["text"] = translation
returnPlaylist[0]["tl"] = _tl
}
return r
}
translate-shell-0.9.6.11/include/Utils.awk 0000664 0000000 0000000 00000017132 13516335241 0020306 0 ustar 00root root 0000000 0000000 ####################################################################
# Utils.awk #
####################################################################
# Detect gawk version.
function initGawk( group) {
Gawk = "gawk"
GawkVersion = PROCINFO["version"]
split(PROCINFO["version"], group, ".")
if (group[1] < 4) {
e("[ERROR] Oops! Your gawk (version " GawkVersion ") " \
"appears to be too old.\n" \
" You need at least gawk 4.0.0 to run this program.")
exit 1
}
}
# Detect whether the terminal emulator implements its own BiDi support.
# NOTE: not working inside an SSH session!
function initBiDiTerm() {
if (ENVIRON["MLTERM"])
BiDiTerm = "mlterm"
else if (ENVIRON["KONSOLE_VERSION"])
BiDiTerm = "konsole"
}
# Detect external bidirectional algorithm utility (fribidi);
# Fallback to Unix `rev` if not found.
function initBiDi() {
FriBidi = detectProgram("fribidi", "--version", 1)
BiDiNoPad = FriBidi ? "fribidi --nopad" : "rev" SUPERR
BiDi = FriBidi ? "fribidi --width %s" :
"rev" SUPERR "| sed \"s/'/\\\\\\'/\" | xargs -0 printf '%%%ss'"
}
# Detect external readline wrapper (rlwrap).
function initRlwrap() {
Rlwrap = detectProgram("rlwrap", "--version")
}
# Detect emacs.
function initEmacs() {
Emacs = detectProgram("emacs", "--version")
}
# Detect curl.
function initCurl() {
Curl = detectProgram("curl", "--version")
}
# Log any value if debugging is enabled.
function l(value, name, inline, heredoc, valOnly, numSub, sortedIn) {
if (Option["debug"]) {
if (name)
da(value, name, inline, heredoc, valOnly, numSub, sortedIn)
else
d(value)
}
}
# Return a log message if debugging is enabled.
function m(string) {
if (Option["debug"])
return ansi("cyan", string) RS
}
# Return 1 if the first version is newer than the second; otherwise return 0.
function newerVersion(ver1, ver2, i, group1, group2) {
split(ver1, group1, ".")
split(ver2, group2, ".")
for (i = 1; i <= 4; i++) {
if (group1[i] + 0 > group2[i] + 0)
return 1
else if (group1[i] + 0 < group2[i] + 0)
return 0
}
return 0
}
# Fork a rlwrap process as the wrapper. Return non-zero if failed,
function rlwrapMe( i, command) {
initRlwrap()
if (!Rlwrap) {
l(">> not found: rlwrap")
return 1
}
if (ENVIRON["TRANS_ENTRY"]) {
command = Rlwrap " " ENVIRON["TRANS_ENTRY"] " " \
parameterize("-no-rlwrap") # never fork rlwrap again!
} else if (fileExists(ENVIRON["TRANS_DIR"] "/" EntryScript)) {
command = Rlwrap " sh " \
parameterize(ENVIRON["TRANS_DIR"] "/" EntryScript) \
" - " parameterize("-no-rlwrap") # never fork rlwrap again!
} else {
l(">> not found: $TRANS_ENTRY or EntryPoint")
return 1
}
for (i = 1; i < length(ARGV); i++)
if (ARGV[i])
command = command " " parameterize(ARGV[i])
l(">> forking: " command)
if (!system(command)) {
l(">> process exited with code 0")
exit ExitCode
} else {
l(">> process exited with non-zero return code")
return 1
}
}
# Fork an emacs process as the front-end. Return non-zero if failed,
function emacsMe( i, params, el, command) {
initEmacs()
if (!Emacs) {
l(">> not found: emacs")
return 1
}
params = ""
for (i = 1; i < length(ARGV); i++)
if (ARGV[i])
params = params " " parameterize(ARGV[i], "\"")
if (ENVIRON["TRANS_ENTRY"]) {
el = "(progn (setq explicit-shell-file-name \"" ENVIRON["TRANS_ENTRY"] "\") " \
"(setq explicit-" Command "-args '(\"-I\" \"-no-rlwrap\"" params ")) " \
"(command-execute 'shell) (rename-buffer \"" Name "\"))"
} else if (fileExists(ENVIRON["TRANS_DIR"] "/" EntryScript)) {
el = "(progn (setq explicit-shell-file-name \"" "sh" "\") " \
"(setq explicit-" "sh" "-args '(\"" ENVIRON["TRANS_DIR"] "/" EntryScript "\" \"-I\" \"-no-rlwrap\"" params ")) " \
"(command-execute 'shell) (rename-buffer \"" Name "\"))"
} else {
l(">> not found: $TRANS_ENTRY or EntryPoint")
return 1
}
command = Emacs " --eval " parameterize(el)
l(">> forking: " command)
if (!system(command)) {
l(">> process exited with code 0")
exit ExitCode
} else {
l(">> process exited with non-zero return code")
return 1
}
}
# Fetch the content of a URL. Return a null string if failed.
function curl(url, output, command, content, line) {
initCurl()
if (!Curl) {
l(">> not found: curl")
w("[WARNING] curl is not found.")
return NULLSTR
}
command = Curl " --location --silent"
if (Option["proxy"])
command = command " --proxy " parameterize(Option["proxy"])
if (Option["user-agent"])
command = command " --user-agent " parameterize(Option["user-agent"])
command = command " " parameterize(url)
if (output) {
command = command " --output " parameterize(output)
system(command)
return NULLSTR
}
content = NULLSTR
while ((command |& getline line) > 0)
content = (content ? content "\n" : NULLSTR) line
close(command)
return content
}
# Fetch the content of a URL. Return a null string if failed.
function curlPost(url, data, output, command, content, line) {
initCurl()
if (!Curl) {
l(">> not found: curl")
w("[WARNING] curl is not found.")
return NULLSTR
}
command = Curl " --location --silent"
if (Option["proxy"])
command = command " --proxy " parameterize(Option["proxy"])
if (Option["user-agent"])
command = command " --user-agent " parameterize(Option["user-agent"])
command = command " --request POST --data " parameterize(data)
command = command " " parameterize(url)
if (output) {
command = command " --output " parameterize(output)
system(command)
return NULLSTR
}
content = NULLSTR
while ((command |& getline line) > 0)
content = (content ? content "\n" : NULLSTR) line
close(command)
return content
}
# Dump a Unicode string into a byte array. Return the length of the array.
function dump(text, group, command, temp) {
# hexdump tricks:
# (1) use -v (--no-squeezing)
# (2) use "%u" (unsigned integers)
command = "hexdump" " -v -e'1/1 \"%03u\" \" \"'"
command = "echo " parameterize(text) PIPE command
command | getline temp
split(temp, group, " ")
close(command)
return length(group) - 1
}
# Dump a Unicode string into a byte array (hexadecimal). Return the length of the array.
function dumpX(text, group, command, temp) {
command = "hexdump" " -v -e'1/1 \"%02X\" \" \"'"
command = "echo " parameterize(text) PIPE command
command | getline temp
split(temp, group, " ")
close(command)
return length(group) - 1
}
# Base64 encode a string.
function base64(text, command, temp) {
command = "echo -n " parameterize(text) PIPE "base64"
command = "bash -c " parameterize(command, "\"")
command | getline temp
close(command)
return temp
}
# Print a Unicode-escaped string. (requires GNU Bash)
function uprintf(text, command, temp) {
command = "echo -en " parameterize(text)
command = "bash -c " parameterize(command, "\"")
command | getline temp
close(command)
return temp
}
translate-shell-0.9.6.11/man/ 0000775 0000000 0000000 00000000000 13516335241 0015626 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/man/trans.1 0000664 0000000 0000000 00000030013 13516335241 0017034 0 ustar 00root root 0000000 0000000 .\" Automatically generated by Pandoc 2.5
.\"
.TH "TRANS" "1" "2019\-07\-25" "0.9.6.11" ""
.hy
.SH NAME
.PP
trans \- Command\-line translator using Google Translate, Bing
Translator, Yandex.Translate, etc.
.SH SYNOPSIS
.PP
\f[B]trans\f[R] [\f[I]OPTIONS\f[R]]
[\f[I]SOURCE\f[R]]:[\f[I]TARGETS\f[R]] [\f[I]TEXT\f[R]]...
.SH DESCRIPTION
.PP
This tool translates text into any language from the command\-line,
using a translation engine such as Google Translate, Bing Translator and
Yandex.Translate.
.PP
Each argument which is not a valid option is treated as \f[I]TEXT\f[R]
to be translated.
.PP
If neither \f[I]TEXT\f[R] nor the input file is specified by
command\-line arguments, the program will read and translate from
standard input.
.SH OPTIONS
.SS Information options
.TP
.B \f[B]\-V\f[R], \f[B]\-version\f[R]
Print version and exit.
.TP
.B \f[B]\-H\f[R], \f[B]\-help\f[R]
Print help message and exit.
\f[B]\-M\f[R], \f[B]\-man\f[R]
Show man page and exit.
.TP
.B \f[B]\-T\f[R], \f[B]\-reference\f[R]
Print reference table of all supported languages and codes, and exit.
Names of languages are displayed in their endonyms (language name in the
language itself).
.TP
.B \f[B]\-R\f[R], \f[B]\-reference\-english\f[R]
Print reference table of all supported languages and codes, and exit.
Names of languages are displayed in English.
.TP
.B \f[B]\-L\f[R] \f[I]CODES\f[R], \f[B]\-list\f[R] \f[I]CODES\f[R]
Print details of languages and exit.
When specifying two or more language codes, concatenate them by plus
sign \[dq]+\[dq].
.TP
.B \f[B]\-S\f[R], \f[B]\-list\-engines\f[R]
List available translation engines and exit.
.TP
.B \f[B]\-U\f[R], \f[B]\-upgrade\f[R]
Check for upgrade of this program.
.SS Translator options
.TP
.B \f[B]\-e\f[R] \f[I]ENGINE\f[R], \f[B]\-engine\f[R] \f[I]ENGINE\f[R]
Specify the translation engine to use.
(default: google)
.SS Display options
.TP
.B \f[B]\-verbose\f[R]
Verbose mode.
.RS
.PP
Show the original text and its most relevant translation, then its
phonetic notation (if any), then its alternative translations (if any)
or its definition in the dictionary (if it is a word).
.PP
This option is unnecessary in most cases since verbose mode is enabled
by default.
.RE
.TP
.B \f[B]\-b\f[R], \f[B]\-brief\f[R]
Brief mode.
.RS
.PP
Show the most relevant translation or its phonetic notation only.
.RE
.TP
.B \f[B]\-d\f[R], \f[B]\-dictionary\f[R]
Dictionary mode.
.RS
.PP
Show the definition of the original word in the dictionary.
.RE
.TP
.B \f[B]\-identify\f[R]
Language identification.
.RS
.PP
Show the identified language of the original text.
.RE
.TP
.B \f[B]\-show\-original\f[R] \f[I]Y/n\f[R]
Show original text or not.
(default: yes)
.TP
.B \f[B]\-show\-original\-phonetics\f[R] \f[I]Y/n\f[R]
Show phonetic notation of original text or not.
(default: yes)
.TP
.B \f[B]\-show\-translation\f[R] \f[I]Y/n\f[R]
Show translation or not.
(default: yes)
.TP
.B \f[B]\-show\-translation\-phonetics\f[R] \f[I]Y/n\f[R]
Show phonetic notation of translation or not.
(default: yes)
.TP
.B \f[B]\-show\-prompt\-message\f[R] \f[I]Y/n\f[R]
Show prompt message or not.
(default: yes)
.TP
.B \f[B]\-show\-languages\f[R] \f[I]Y/n\f[R]
Show source and target languages or not.
(default: yes)
.TP
.B \f[B]\-show\-original\-dictionary\f[R] \f[I]y/N\f[R]
Show dictionary entry of original text or not.
(default: no)
.RS
.PP
This option is enabled in dictionary mode.
.RE
.TP
.B \f[B]\-show\-dictionary\f[R] \f[I]Y/n\f[R]
Show dictionary entry of translation or not.
(default: yes)
.TP
.B \f[B]\-show\-alternatives\f[R] \f[I]Y/n\f[R]
Show alternative translations or not.
(default: yes)
.TP
.B \f[B]\-w\f[R] \f[I]NUM\f[R], \f[B]\-width\f[R] \f[I]NUM\f[R]
Specify the screen width for padding.
.RS
.PP
This option overrides the setting of environment variable
$\f[B]COLUMNS\f[R].
.RE
.TP
.B \f[B]\-indent\f[R] \f[I]NUM\f[R]
Specify the size of indent (number of spaces).
(default: 4)
.TP
.B \f[B]\-theme\f[R] \f[I]FILENAME\f[R]
Specify the theme to use.
(default: default)
.TP
.B \f[B]\-no\-theme\f[R]
Do not use any other theme than default.
.TP
.B \f[B]\-no\-ansi\f[R]
Do not use ANSI escape codes.
.TP
.B \f[B]\-no\-autocorrect\f[R]
Do not autocorrect.
(if defaulted by the translation engine)
.TP
.B \f[B]\-no\-bidi\f[R]
Do not convert bidirectional texts.
.TP
.B \f[B]\-bidi\f[R]
Always convert bidirectional texts.
.TP
.B \f[B]\-no\-warn\f[R]
Do not write warning messages to stderr.
.TP
.B \f[B]\-dump\f[R]
Print raw API response instead.
.SS Audio options
.TP
.B \f[B]\-p\f[R], \f[B]\-play\f[R]
Listen to the translation.
.RS
.PP
You must have at least one of the supported audio players
(\f[B]mplayer\f[R], \f[B]mpv\f[R] or \f[B]mpg123\f[R]) installed to
stream from Google Text\-to\-Speech engine.
Otherwise, a local speech synthesizer may be used instead (\f[B]say\f[R]
on macOS, \f[B]espeak\f[R] on Linux or other platforms).
.RE
.TP
.B \f[B]\-speak\f[R]
Listen to the original text.
.TP
.B \f[B]\-n\f[R] \f[I]VOICE\f[R], \f[B]\-narrator\f[R] \f[I]VOICE\f[R]
Specify the narrator, and listen to the translation.
.RS
.PP
Common values for this option are \f[B]male\f[R] and \f[B]female\f[R].
.RE
.TP
.B \f[B]\-player\f[R] \f[I]PROGRAM\f[R]
Specify the audio player to use, and listen to the translation.
.RS
.PP
Option \f[B]\-play\f[R] will try to use \f[B]mplayer\f[R], \f[B]mpv\f[R]
or \f[B]mpg123\f[R] by default, since these players are known to work
for streaming URLs.
Not all command\-line audio players can work this way.
Use this option only when you have your own preference.
.PP
This option overrides the setting of environment variable
$\f[B]PLAYER\f[R].
.RE
.TP
.B \f[B]\-no\-play\f[R]
Do not listen to the translation.
.TP
.B \f[B]\-no\-translate\f[R]
Do not translate anything when using \-speak.
.TP
.B \f[B]\-download\-audio\f[R]
Download the audio to the current directory.
.TP
.B \f[B]\-download\-audio\-as\f[R] \f[I]FILENAME\f[R]
Download the audio to the specified file.
.SS Terminal paging and browsing options
.TP
.B \f[B]\-v\f[R], \f[B]\-view\f[R]
View the translation in a terminal pager (\f[B]less\f[R], \f[B]more\f[R]
or \f[B]most\f[R]).
.TP
.B \f[B]\-pager\f[R] \f[I]PROGRAM\f[R]
Specify the terminal pager to use, and view the translation.
.RS
.PP
This option overrides the setting of environment variable
$\f[B]PAGER\f[R].
.RE
.TP
.B \f[B]\-no\-view\f[R], \f[B]\-no\-pager\f[R]
Do not view the translation in a terminal pager.
.TP
.B \f[B]\-browser\f[R] \f[I]PROGRAM\f[R]
Specify the web browser to use.
.RS
.PP
This option overrides the setting of environment variable
$\f[B]BROWSER\f[R].
.RE
.TP
.B \f[B]\-no\-browser\f[R]
Do not open the web browser.
.SS Networking options
.TP
.B \f[B]\-x\f[R] \f[I]HOST:PORT\f[R], \f[B]\-proxy\f[R] \f[I]HOST:PORT\f[R]
Use HTTP proxy on given port.
.RS
.PP
This option overrides the setting of environment variables
$\f[B]HTTP_PROXY\f[R] and $\f[B]http_proxy\f[R].
.RE
.TP
.B \f[B]\-u\f[R] \f[I]STRING\f[R], \f[B]\-user\-agent\f[R] \f[I]STRING\f[R]
Specify the User\-Agent to identify as.
.RS
.PP
This option overrides the setting of environment variables
$\f[B]USER_AGENT\f[R].
.RE
.TP
.B \f[B]\-4\f[R], \f[B]\-ipv4\f[R], \f[B]\-inet4\-only\f[R]
Connect only to IPv4 addresses.
.TP
.B \f[B]\-6\f[R], \f[B]\-ipv6\f[R], \f[B]\-inet6\-only\f[R]
Connect only to IPv6 addresses.
.SS Interactive shell options
.TP
.B \f[B]\-I\f[R], \f[B]\-interactive\f[R], \f[B]\-shell\f[R]
Start an interactive shell, invoking \f[B]rlwrap\f[R] whenever possible
(unless \f[B]\-no\-rlwrap\f[R] is specified).
.TP
.B \f[B]\-E\f[R], \f[B]\-emacs\f[R]
Start the GNU Emacs front\-end for an interactive shell.
.RS
.PP
This option does not need to, and cannot be used along with
\f[B]\-I\f[R] or \f[B]\-no\-rlwrap\f[R].
.RE
.TP
.B \f[B]\-no\-rlwrap\f[R]
Do not invoke \f[B]rlwrap\f[R] when starting an interactive shell.
.RS
.PP
This option is useful when your terminal type is not supported by
\f[B]rlwrap\f[R] (e.g.
\f[B]emacs\f[R]).
.RE
.SS I/O options
.TP
.B \f[B]\-i\f[R] \f[I]FILENAME\f[R], \f[B]\-input\f[R] \f[I]FILENAME\f[R]
Specify the input file.
.RS
.PP
Source text to be translated will be read from the input file, instead
of standard input.
.RE
.TP
.B \f[B]\-o\f[R] \f[I]FILENAME\f[R], \f[B]\-output\f[R] \f[I]FILENAME\f[R]
Specify the output file.
.RS
.PP
Translations will be written to the output file, instead of standard
output.
.RE
.SS Language preference options
.TP
.B \f[B]\-l\f[R] \f[I]CODE\f[R], \f[B]\-hl\f[R] \f[I]CODE\f[R], \f[B]\-lang\f[R] \f[I]CODE\f[R]
Specify your home language (the language you would like to see for
displaying prompt messages in the translation).
.RS
.PP
This option affects only the display in verbose mode (anything other
than source language and target language will be displayed in your home
language).
This option has no effect in brief mode.
.PP
This option is optional.
When its setting is omitted, English will be used.
.PP
This option overrides the setting of environment variables
$\f[B]LC_ALL\f[R], $\f[B]LANG\f[R], and $\f[B]HOME_LANG\f[R].
.RE
.TP
.B \f[B]\-s\f[R] \f[I]CODES\f[R], \f[B]\-sl\f[R] \f[I]CODES\f[R], \f[B]\-source\f[R] \f[I]CODES\f[R], \f[B]\-from\f[R] \f[I]CODES\f[R]
Specify the source language(s) (the language(s) of original text).
When specifying two or more language codes, concatenate them by plus
sign \[dq]+\[dq].
.RS
.PP
This option is optional.
When its setting is omitted, the language of original text will be
identified automatically (with a possibility of misidentification).
.PP
This option overrides the setting of environment variable
$\f[B]SOURCE_LANG\f[R].
.RE
.TP
.B \f[B]\-t\f[R] \f[I]CODES\f[R], \f[B]\-tl\f[R] \f[I]CODES\f[R], \f[B]\-target\f[R] \f[I]CODES\f[R], \f[B]\-to\f[R] \f[I]CODES\f[R]
Specify the target language(s) (the language(s) of translated text).
When specifying two or more language codes, concatenate them by plus
sign \[dq]+\[dq].
.RS
.PP
This option is optional.
When its setting is omitted, everything will be translated into English.
.PP
This option overrides the setting of environment variables
$\f[B]LC_ALL\f[R], $\f[B]LANG\f[R], and $\f[B]TARGET_LANG\f[R].
.RE
.TP
.B [\f[I]SOURCE\f[R]]:[\f[I]TARGETS\f[R]]
A simpler, alternative way to specify the source language and target
language(s) is to use a shortcut formatted string:
.RS
.IP \[bu] 2
\f[I]SOURCE\-CODE\f[R]:\f[I]TARGET\-CODE\f[R]
.IP \[bu] 2
\f[I]SOURCE\-CODE\f[R]:\f[I]TARGET\-CODE1\f[R]+\f[I]TARGET\-CODE2\f[R]+...
.IP \[bu] 2
\f[I]SOURCE\-CODE\f[R]=\f[I]TARGET\-CODE\f[R]
.IP \[bu] 2
\f[I]SOURCE\-CODE\f[R]=\f[I]TARGET\-CODE1\f[R]+\f[I]TARGET\-CODE2\f[R]+...
.PP
Delimiter \[dq]:\[dq] and \[dq]=\[dq] can be used interchangeably.
.PP
Either \f[I]SOURCE\f[R] or \f[I]TARGETS\f[R] may be omitted, but the
delimiter character must be kept.
.RE
.SS Text preprocessing options
.TP
.B \f[B]\-j\f[R], \f[B]\-join\-sentence\f[R]
Treat all arguments as one single sentence.
.SS Other options
.TP
.B \f[B]\-no\-init\f[R]
Do not load any initialization script.
.TP
.B \f[B]\-\-\f[R]
End\-of\-options.
.RS
.PP
All arguments after this option are treated as \f[I]TEXT\f[R] to be
translated.
.RE
.SH EXIT STATUS
.TP
.B \f[B]0\f[R]
Successful translation.
.TP
.B \f[B]1\f[R]
Error.
.SH ENVIRONMENT
.TP
.B \f[B]PAGER\f[R]
Equivalent to option setting \f[B]\-pager\f[R].
.TP
.B \f[B]BROWSER\f[R]
Equivalent to option setting \f[B]\-browser\f[R].
.TP
.B \f[B]PLAYER\f[R]
Equivalent to option setting \f[B]\-player\f[R].
.TP
.B \f[B]HTTP_PROXY\f[R]
Equivalent to option setting \f[B]\-proxy\f[R].
.TP
.B \f[B]USER_AGENT\f[R]
Equivalent to option setting \f[B]\-user\-agent\f[R].
.TP
.B \f[B]HOME_LANG\f[R]
Equivalent to option setting \f[B]\-lang\f[R].
.TP
.B \f[B]SOURCE_LANG\f[R]
Equivalent to option setting \f[B]\-source\f[R].
.TP
.B \f[B]TARGET_LANG\f[R]
Equivalent to option setting \f[B]\-target\f[R].
.SH FILES
.TP
.B \f[I]/etc/translate\-shell\f[R]
Initialization script.
(system\-wide)
.TP
.B \f[I]$HOME/.translate\-shell/init.trans\f[R]
Initialization script.
(user\-specific)
.TP
.B \f[I]$XDG_CONFIG_HOME/translate\-shell/init.trans\f[R]
Initialization script.
(user\-specific)
.TP
.B \f[I]./.trans\f[R]
Initialization script.
(current directory)
.SH FURTHER DOCUMENTATION
.PP
.SH REPORTING BUGS
.PP
.SH AUTHORS
Mort Yao .
translate-shell-0.9.6.11/man/trans.1.md 0000664 0000000 0000000 00000023770 13516335241 0017447 0 ustar 00root root 0000000 0000000 % TRANS(1) 0.9.6.11
% Mort Yao
% 2019-07-25
# NAME
trans - Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
# SYNOPSIS
**trans** [*OPTIONS*] [*SOURCE*]:[*TARGETS*] [*TEXT*]...
# DESCRIPTION
This tool translates text into any language from the command-line, using a translation engine such as Google Translate, Bing Translator and Yandex.Translate.
Each argument which is not a valid option is treated as *TEXT* to be translated.
If neither *TEXT* nor the input file is specified by command-line arguments, the program will read and translate from standard input.
# OPTIONS
## Information options
**-V**, **-version**
: Print version and exit.
**-H**, **-help**
: Print help message and exit.
**-M**, **-man**
: Show man page and exit.
**-T**, **-reference**
: Print reference table of all supported languages and codes, and exit. Names of languages are displayed in their endonyms (language name in the language itself).
**-R**, **-reference-english**
: Print reference table of all supported languages and codes, and exit. Names of languages are displayed in English.
**-L** *CODES*, **-list** *CODES*
: Print details of languages and exit. When specifying two or more language codes, concatenate them by plus sign "+".
**-S**, **-list-engines**
: List available translation engines and exit.
**-U**, **-upgrade**
: Check for upgrade of this program.
## Translator options
**-e** *ENGINE*, **-engine** *ENGINE*
: Specify the translation engine to use. (default: google)
## Display options
**-verbose**
: Verbose mode.
Show the original text and its most relevant translation, then its phonetic notation (if any), then its alternative translations (if any) or its definition in the dictionary (if it is a word).
This option is unnecessary in most cases since verbose mode is enabled by default.
**-b**, **-brief**
: Brief mode.
Show the most relevant translation or its phonetic notation only.
**-d**, **-dictionary**
: Dictionary mode.
Show the definition of the original word in the dictionary.
**-identify**
: Language identification.
Show the identified language of the original text.
**-show-original** *Y/n*
: Show original text or not. (default: yes)
**-show-original-phonetics** *Y/n*
: Show phonetic notation of original text or not. (default: yes)
**-show-translation** *Y/n*
: Show translation or not. (default: yes)
**-show-translation-phonetics** *Y/n*
: Show phonetic notation of translation or not. (default: yes)
**-show-prompt-message** *Y/n*
: Show prompt message or not. (default: yes)
**-show-languages** *Y/n*
: Show source and target languages or not. (default: yes)
**-show-original-dictionary** *y/N*
: Show dictionary entry of original text or not. (default: no)
This option is enabled in dictionary mode.
**-show-dictionary** *Y/n*
: Show dictionary entry of translation or not. (default: yes)
**-show-alternatives** *Y/n*
: Show alternative translations or not. (default: yes)
**-w** *NUM*, **-width** *NUM*
: Specify the screen width for padding.
This option overrides the setting of environment variable $**COLUMNS**.
**-indent** *NUM*
: Specify the size of indent (number of spaces). (default: 4)
**-theme** *FILENAME*
: Specify the theme to use. (default: default)
**-no-theme**
: Do not use any other theme than default.
**-no-ansi**
: Do not use ANSI escape codes.
**-no-autocorrect**
: Do not autocorrect. (if defaulted by the translation engine)
**-no-bidi**
: Do not convert bidirectional texts.
**-bidi**
: Always convert bidirectional texts.
**-no-warn**
: Do not write warning messages to stderr.
**-dump**
: Print raw API response instead.
## Audio options
**-p**, **-play**
: Listen to the translation.
You must have at least one of the supported audio players (**mplayer**, **mpv** or **mpg123**) installed to stream from Google Text-to-Speech engine. Otherwise, a local speech synthesizer may be used instead (**say** on macOS, **espeak** on Linux or other platforms).
**-speak**
: Listen to the original text.
**-n** *VOICE*, **-narrator** *VOICE*
: Specify the narrator, and listen to the translation.
Common values for this option are **male** and **female**.
**-player** *PROGRAM*
: Specify the audio player to use, and listen to the translation.
Option **-play** will try to use **mplayer**, **mpv** or **mpg123** by default, since these players are known to work for streaming URLs. Not all command-line audio players can work this way. Use this option only when you have your own preference.
This option overrides the setting of environment variable $**PLAYER**.
**-no-play**
: Do not listen to the translation.
**-no-translate**
: Do not translate anything when using -speak.
**-download-audio**
: Download the audio to the current directory.
**-download-audio-as** *FILENAME*
: Download the audio to the specified file.
## Terminal paging and browsing options
**-v**, **-view**
: View the translation in a terminal pager (**less**, **more** or **most**).
**-pager** *PROGRAM*
: Specify the terminal pager to use, and view the translation.
This option overrides the setting of environment variable $**PAGER**.
**-no-view**, **-no-pager**
: Do not view the translation in a terminal pager.
**-browser** *PROGRAM*
: Specify the web browser to use.
This option overrides the setting of environment variable $**BROWSER**.
**-no-browser**
: Do not open the web browser.
## Networking options
**-x** *HOST:PORT*, **-proxy** *HOST:PORT*
: Use HTTP proxy on given port.
This option overrides the setting of environment variables $**HTTP_PROXY** and $**http_proxy**.
**-u** *STRING*, **-user-agent** *STRING*
: Specify the User-Agent to identify as.
This option overrides the setting of environment variables $**USER_AGENT**.
**-4**, **-ipv4**, **-inet4-only**
: Connect only to IPv4 addresses.
**-6**, **-ipv6**, **-inet6-only**
: Connect only to IPv6 addresses.
## Interactive shell options
**-I**, **-interactive**, **-shell**
: Start an interactive shell, invoking **rlwrap** whenever possible (unless **-no-rlwrap** is specified).
**-E**, **-emacs**
: Start the GNU Emacs front-end for an interactive shell.
This option does not need to, and cannot be used along with **-I** or **-no-rlwrap**.
**-no-rlwrap**
: Do not invoke **rlwrap** when starting an interactive shell.
This option is useful when your terminal type is not supported by **rlwrap** (e.g. **emacs**).
## I/O options
**-i** *FILENAME*, **-input** *FILENAME*
: Specify the input file.
Source text to be translated will be read from the input file, instead of standard input.
**-o** *FILENAME*, **-output** *FILENAME*
: Specify the output file.
Translations will be written to the output file, instead of standard output.
## Language preference options
**-l** *CODE*, **-hl** *CODE*, **-lang** *CODE*
: Specify your home language (the language you would like to see for displaying prompt messages in the translation).
This option affects only the display in verbose mode (anything other than source language and target language will be displayed in your home language). This option has no effect in brief mode.
This option is optional. When its setting is omitted, English will be used.
This option overrides the setting of environment variables $**LC_ALL**, $**LANG**, and $**HOME_LANG**.
**-s** *CODES*, **-sl** *CODES*, **-source** *CODES*, **-from** *CODES*
: Specify the source language(s) (the language(s) of original text). When specifying two or more language codes, concatenate them by plus sign "+".
This option is optional. When its setting is omitted, the language of original text will be identified automatically (with a possibility of misidentification).
This option overrides the setting of environment variable $**SOURCE_LANG**.
**-t** *CODES*, **-tl** *CODES*, **-target** *CODES*, **-to** *CODES*
: Specify the target language(s) (the language(s) of translated text). When specifying two or more language codes, concatenate them by plus sign "+".
This option is optional. When its setting is omitted, everything will be translated into English.
This option overrides the setting of environment variables $**LC_ALL**, $**LANG**, and $**TARGET_LANG**.
[*SOURCE*]:[*TARGETS*]
: A simpler, alternative way to specify the source language and target language(s) is to use a shortcut formatted string:
* *SOURCE-CODE*:*TARGET-CODE*
* *SOURCE-CODE*:*TARGET-CODE1*+*TARGET-CODE2*+...
* *SOURCE-CODE*=*TARGET-CODE*
* *SOURCE-CODE*=*TARGET-CODE1*+*TARGET-CODE2*+...
Delimiter ":" and "=" can be used interchangeably.
Either *SOURCE* or *TARGETS* may be omitted, but the delimiter character must be kept.
## Text preprocessing options
**-j**, **-join-sentence**
: Treat all arguments as one single sentence.
## Other options
**-no-init**
: Do not load any initialization script.
**--**
: End-of-options.
All arguments after this option are treated as *TEXT* to be translated.
# EXIT STATUS
**0**
: Successful translation.
**1**
: Error.
# ENVIRONMENT
**PAGER**
: Equivalent to option setting **-pager**.
**BROWSER**
: Equivalent to option setting **-browser**.
**PLAYER**
: Equivalent to option setting **-player**.
**HTTP_PROXY**
: Equivalent to option setting **-proxy**.
**USER_AGENT**
: Equivalent to option setting **-user-agent**.
**HOME_LANG**
: Equivalent to option setting **-lang**.
**SOURCE_LANG**
: Equivalent to option setting **-source**.
**TARGET_LANG**
: Equivalent to option setting **-target**.
# FILES
*/etc/translate-shell*
: Initialization script. (system-wide)
*$HOME/.translate-shell/init.trans*
: Initialization script. (user-specific)
*$XDG_CONFIG_HOME/translate-shell/init.trans*
: Initialization script. (user-specific)
*./.trans*
: Initialization script. (current directory)
# FURTHER DOCUMENTATION
# REPORTING BUGS
translate-shell-0.9.6.11/man/trans.1.template.md 0000664 0000000 0000000 00000023774 13516335241 0021265 0 ustar 00root root 0000000 0000000 % TRANS(1) $Version$
% Mort Yao
% $ReleaseDate$
# NAME
trans - Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
# SYNOPSIS
**trans** [*OPTIONS*] [*SOURCE*]:[*TARGETS*] [*TEXT*]...
# DESCRIPTION
This tool translates text into any language from the command-line, using a translation engine such as Google Translate, Bing Translator and Yandex.Translate.
Each argument which is not a valid option is treated as *TEXT* to be translated.
If neither *TEXT* nor the input file is specified by command-line arguments, the program will read and translate from standard input.
# OPTIONS
## Information options
**-V**, **-version**
: Print version and exit.
**-H**, **-help**
: Print help message and exit.
**-M**, **-man**
: Show man page and exit.
**-T**, **-reference**
: Print reference table of all supported languages and codes, and exit. Names of languages are displayed in their endonyms (language name in the language itself).
**-R**, **-reference-english**
: Print reference table of all supported languages and codes, and exit. Names of languages are displayed in English.
**-L** *CODES*, **-list** *CODES*
: Print details of languages and exit. When specifying two or more language codes, concatenate them by plus sign "+".
**-S**, **-list-engines**
: List available translation engines and exit.
**-U**, **-upgrade**
: Check for upgrade of this program.
## Translator options
**-e** *ENGINE*, **-engine** *ENGINE*
: Specify the translation engine to use. (default: google)
## Display options
**-verbose**
: Verbose mode.
Show the original text and its most relevant translation, then its phonetic notation (if any), then its alternative translations (if any) or its definition in the dictionary (if it is a word).
This option is unnecessary in most cases since verbose mode is enabled by default.
**-b**, **-brief**
: Brief mode.
Show the most relevant translation or its phonetic notation only.
**-d**, **-dictionary**
: Dictionary mode.
Show the definition of the original word in the dictionary.
**-identify**
: Language identification.
Show the identified language of the original text.
**-show-original** *Y/n*
: Show original text or not. (default: yes)
**-show-original-phonetics** *Y/n*
: Show phonetic notation of original text or not. (default: yes)
**-show-translation** *Y/n*
: Show translation or not. (default: yes)
**-show-translation-phonetics** *Y/n*
: Show phonetic notation of translation or not. (default: yes)
**-show-prompt-message** *Y/n*
: Show prompt message or not. (default: yes)
**-show-languages** *Y/n*
: Show source and target languages or not. (default: yes)
**-show-original-dictionary** *y/N*
: Show dictionary entry of original text or not. (default: no)
This option is enabled in dictionary mode.
**-show-dictionary** *Y/n*
: Show dictionary entry of translation or not. (default: yes)
**-show-alternatives** *Y/n*
: Show alternative translations or not. (default: yes)
**-w** *NUM*, **-width** *NUM*
: Specify the screen width for padding.
This option overrides the setting of environment variable $**COLUMNS**.
**-indent** *NUM*
: Specify the size of indent (number of spaces). (default: 4)
**-theme** *FILENAME*
: Specify the theme to use. (default: default)
**-no-theme**
: Do not use any other theme than default.
**-no-ansi**
: Do not use ANSI escape codes.
**-no-autocorrect**
: Do not autocorrect. (if defaulted by the translation engine)
**-no-bidi**
: Do not convert bidirectional texts.
**-bidi**
: Always convert bidirectional texts.
**-no-warn**
: Do not write warning messages to stderr.
**-dump**
: Print raw API response instead.
## Audio options
**-p**, **-play**
: Listen to the translation.
You must have at least one of the supported audio players (**mplayer**, **mpv** or **mpg123**) installed to stream from Google Text-to-Speech engine. Otherwise, a local speech synthesizer may be used instead (**say** on macOS, **espeak** on Linux or other platforms).
**-speak**
: Listen to the original text.
**-n** *VOICE*, **-narrator** *VOICE*
: Specify the narrator, and listen to the translation.
Common values for this option are **male** and **female**.
**-player** *PROGRAM*
: Specify the audio player to use, and listen to the translation.
Option **-play** will try to use **mplayer**, **mpv** or **mpg123** by default, since these players are known to work for streaming URLs. Not all command-line audio players can work this way. Use this option only when you have your own preference.
This option overrides the setting of environment variable $**PLAYER**.
**-no-play**
: Do not listen to the translation.
**-no-translate**
: Do not translate anything when using -speak.
**-download-audio**
: Download the audio to the current directory.
**-download-audio-as** *FILENAME*
: Download the audio to the specified file.
## Terminal paging and browsing options
**-v**, **-view**
: View the translation in a terminal pager (**less**, **more** or **most**).
**-pager** *PROGRAM*
: Specify the terminal pager to use, and view the translation.
This option overrides the setting of environment variable $**PAGER**.
**-no-view**, **-no-pager**
: Do not view the translation in a terminal pager.
**-browser** *PROGRAM*
: Specify the web browser to use.
This option overrides the setting of environment variable $**BROWSER**.
**-no-browser**
: Do not open the web browser.
## Networking options
**-x** *HOST:PORT*, **-proxy** *HOST:PORT*
: Use HTTP proxy on given port.
This option overrides the setting of environment variables $**HTTP_PROXY** and $**http_proxy**.
**-u** *STRING*, **-user-agent** *STRING*
: Specify the User-Agent to identify as.
This option overrides the setting of environment variables $**USER_AGENT**.
**-4**, **-ipv4**, **-inet4-only**
: Connect only to IPv4 addresses.
**-6**, **-ipv6**, **-inet6-only**
: Connect only to IPv6 addresses.
## Interactive shell options
**-I**, **-interactive**, **-shell**
: Start an interactive shell, invoking **rlwrap** whenever possible (unless **-no-rlwrap** is specified).
**-E**, **-emacs**
: Start the GNU Emacs front-end for an interactive shell.
This option does not need to, and cannot be used along with **-I** or **-no-rlwrap**.
**-no-rlwrap**
: Do not invoke **rlwrap** when starting an interactive shell.
This option is useful when your terminal type is not supported by **rlwrap** (e.g. **emacs**).
## I/O options
**-i** *FILENAME*, **-input** *FILENAME*
: Specify the input file.
Source text to be translated will be read from the input file, instead of standard input.
**-o** *FILENAME*, **-output** *FILENAME*
: Specify the output file.
Translations will be written to the output file, instead of standard output.
## Language preference options
**-l** *CODE*, **-hl** *CODE*, **-lang** *CODE*
: Specify your home language (the language you would like to see for displaying prompt messages in the translation).
This option affects only the display in verbose mode (anything other than source language and target language will be displayed in your home language). This option has no effect in brief mode.
This option is optional. When its setting is omitted, English will be used.
This option overrides the setting of environment variables $**LC_ALL**, $**LANG**, and $**HOME_LANG**.
**-s** *CODES*, **-sl** *CODES*, **-source** *CODES*, **-from** *CODES*
: Specify the source language(s) (the language(s) of original text). When specifying two or more language codes, concatenate them by plus sign "+".
This option is optional. When its setting is omitted, the language of original text will be identified automatically (with a possibility of misidentification).
This option overrides the setting of environment variable $**SOURCE_LANG**.
**-t** *CODES*, **-tl** *CODES*, **-target** *CODES*, **-to** *CODES*
: Specify the target language(s) (the language(s) of translated text). When specifying two or more language codes, concatenate them by plus sign "+".
This option is optional. When its setting is omitted, everything will be translated into English.
This option overrides the setting of environment variables $**LC_ALL**, $**LANG**, and $**TARGET_LANG**.
[*SOURCE*]:[*TARGETS*]
: A simpler, alternative way to specify the source language and target language(s) is to use a shortcut formatted string:
* *SOURCE-CODE*:*TARGET-CODE*
* *SOURCE-CODE*:*TARGET-CODE1*+*TARGET-CODE2*+...
* *SOURCE-CODE*=*TARGET-CODE*
* *SOURCE-CODE*=*TARGET-CODE1*+*TARGET-CODE2*+...
Delimiter ":" and "=" can be used interchangeably.
Either *SOURCE* or *TARGETS* may be omitted, but the delimiter character must be kept.
## Text preprocessing options
**-j**, **-join-sentence**
: Treat all arguments as one single sentence.
## Other options
**-no-init**
: Do not load any initialization script.
**--**
: End-of-options.
All arguments after this option are treated as *TEXT* to be translated.
# EXIT STATUS
**0**
: Successful translation.
**1**
: Error.
# ENVIRONMENT
**PAGER**
: Equivalent to option setting **-pager**.
**BROWSER**
: Equivalent to option setting **-browser**.
**PLAYER**
: Equivalent to option setting **-player**.
**HTTP_PROXY**
: Equivalent to option setting **-proxy**.
**USER_AGENT**
: Equivalent to option setting **-user-agent**.
**HOME_LANG**
: Equivalent to option setting **-lang**.
**SOURCE_LANG**
: Equivalent to option setting **-source**.
**TARGET_LANG**
: Equivalent to option setting **-target**.
# FILES
*/etc/translate-shell*
: Initialization script. (system-wide)
*$HOME/.translate-shell/init.trans*
: Initialization script. (user-specific)
*$XDG_CONFIG_HOME/translate-shell/init.trans*
: Initialization script. (user-specific)
*./.trans*
: Initialization script. (current directory)
# FURTHER DOCUMENTATION
# REPORTING BUGS
translate-shell-0.9.6.11/metainfo.awk 0000664 0000000 0000000 00000000460 13516335241 0017361 0 ustar 00root root 0000000 0000000 BEGIN {
Name = "Translate Shell"
Description = "Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc."
Version = "0.9.6.11"
ReleaseDate = "2019-07-25"
Command = "trans"
EntryPoint = "translate.awk"
EntryScript = "translate"
}
translate-shell-0.9.6.11/test.awk 0000664 0000000 0000000 00000004364 13516335241 0016545 0 ustar 00root root 0000000 0000000 #!/usr/bin/gawk -f
@include "include/Commons"
function pass(name, message, ansiCode, string) {
if (!name) name = TEST
if (!ansiCode) ansiCode = "green"
G_COUNTER++; COUNTER++; G_SUCCESS++
string = sprintf("(%2s/%-2s) TESTING %s", COUNTER, TOTAL, name)
if (message) string = string "\n " message
print(ansi(ansiCode, ansi("bold", "[PASS] " string)))
}
function fail(name, message, ansiCode, string) {
if (!name) name = TEST
if (!ansiCode) ansiCode = "red"
G_COUNTER++; COUNTER++
string = sprintf("(%2s/%-2s) TESTING %s", COUNTER, TOTAL, name)
if (message) string = string "\n " message
print(ansi(ansiCode, ansi("bold", "[FAIL] " string)))
}
function assertTrue(x, name, message, ansiCode) {
if (x)
pass(name, "", ansiCode)
else {
if (!message) message = "assertTrue: FALSE"
fail(name, message, ansiCode)
}
}
function assertFalse(x, name, message, ansiCode) {
if (!message) message = "assertFalse: TRUE"
assertTrue(!x, name, message, ansiCode)
}
function assertEqual(x, y, name, message, ansiCode, i) {
if (!message)
message = "assertEqual: " ansi("underline", toString(x, 1)) \
" IS NOT EQUAL TO " ansi("underline", toString(y, 1))
assertTrue(identical(x, y), name, message, ansiCode)
}
function assertNotEqual(x, y, name, message, ansiCode, i) {
if (!message)
message = "assertNotEqual: " ansi("underline", toString(x, 1)) \
" IS EQUAL TO " ansi("underline", toString(y, 1))
assertFalse(identical(x, y), name, message, ansiCode)
}
function T(test, total) {
TEST = test
TOTAL = total
COUNTER = 0
}
function START_TEST(name) {
print(ansi("negative", ansi("bold", "====== TESTING FOR " \
ansi("underline", name) " STARTED")))
G_COUNTER = G_SUCCESS = 0
}
function END_TEST() {
TOTAL = G_COUNTER; COUNTER = G_SUCCESS - 1
G_FAILURE = G_COUNTER - G_SUCCESS
if (G_FAILURE) {
assertEqual(G_COUNTER, G_SUCCESS, "COMPLETED", \
G_SUCCESS " PASSED, " G_FAILURE " FAILED", "yellow")
exit 1
} else
assertEqual(G_COUNTER, G_SUCCESS, "COMPLETED. PERFECT!")
}
@include "test/Test"
translate-shell-0.9.6.11/test/ 0000775 0000000 0000000 00000000000 13516335241 0016032 5 ustar 00root root 0000000 0000000 translate-shell-0.9.6.11/test/Test.awk 0000664 0000000 0000000 00000000157 13516335241 0017460 0 ustar 00root root 0000000 0000000 @include "test/TestCommons"
@include "test/TestUtils"
@include "test/TestParser"
@include "test/TestLanguages"
translate-shell-0.9.6.11/test/TestCommons.awk 0000664 0000000 0000000 00000016367 13516335241 0021026 0 ustar 00root root 0000000 0000000 BEGIN {
START_TEST("Commons.awk")
# Arrays
T("anything()", 3)
{
delete something
assertFalse(anything(nothing))
something[0] = 0; assertFalse(anything(something)) # edge case
something[0] = 1; assertTrue(anything(something))
}
T("exists()", 4)
{
delete something
assertFalse(exists(something))
something[0] = 0; assertFalse(exists(something)) # edge case
something[0] = 1; assertTrue(exists(something))
assertTrue(exists(something[0]))
}
T("belongsTo()", 3)
{
delete array; array[0] = "foo"; array[1] = "bar"
assertTrue(belongsTo("foo", array))
assertTrue(belongsTo("bar", array))
assertFalse(belongsTo("world", array))
}
T("identical()", 4)
{
delete x; x[0] = 42
delete y; y[0][0] = 42
assertFalse(identical(x, y))
assertTrue(identical(x, y[0]))
assertFalse(identical(x[0], y[0]))
assertTrue(identical(x[0], y[0][0]))
}
T("append()", 1)
{
delete array; array[0] = "foo"
delete expected; expected[0] = "foo"; expected[1] = "bar"
append(array, "bar")
assertEqual(array, expected)
}
# Strings
T("isnum()", 4)
{
assertTrue(isnum(0))
assertTrue(isnum(42.0))
assertFalse(isnum(""))
assertFalse(isnum("hello world"))
}
T("startsWithAny()", 3)
{
delete substrings; substrings[0] = "A"; substrings[1] = "a"
assertTrue(startsWithAny("absolute", substrings))
assertTrue(startsWithAny("ABSOLUTE", substrings))
assertFalse(startsWithAny("ZOO", substrings))
}
T("matchesAny()", 4)
{
delete patterns; patterns[0] = "[[:space:]]"; patterns[1] = "[0Oo]"
assertTrue(matchesAny(" ", patterns))
assertTrue(matchesAny("obsolete", patterns))
assertTrue(matchesAny("0.0", patterns))
assertFalse(matchesAny("1.0", patterns))
}
T("replicate()", 4)
{
assertEqual(replicate("", 0), "")
assertEqual(replicate("", 2), "")
assertEqual(replicate("foo bar", 1), "foo bar")
assertEqual(replicate("foo bar", 3), "foo barfoo barfoo bar")
}
T("reverse()", 4)
{
assertEqual(reverse(""), "")
assertEqual(reverse("god"), "dog")
assertEqual(reverse("0123456789"), "9876543210")
assertEqual(reverse("さしすせそ"), "そせすしさ")
}
T("join()", 4)
{
assertEqual(join("", "-"), "")
delete array; array[0]
assertEqual(join(array, "-"), "")
delete array; array[0] = "foo"; array[1] = "bar"
assertEqual(join(array, " "), "foo bar")
assertEqual(join(array, ","), "foo,bar")
}
T("explode()", 1)
{
delete array
delete expected; expected[1] = "f"; expected[2] = "o"; expected[3] = "o"
explode("foo", array)
assertEqual(array, expected)
}
T("escapeChar()", 8)
{
assertEqual(escapeChar("b"), "\b")
assertEqual(escapeChar("f"), "\f")
assertEqual(escapeChar("n"), "\n")
assertEqual(escapeChar("r"), "\r")
assertEqual(escapeChar("t"), "\t")
assertEqual(escapeChar("v"), "\v")
assertEqual(escapeChar("_"), "_")
assertNotEqual(escapeChar("_"), "\\_")
}
T("literal()", 6)
{
assertEqual(literal(""), "")
assertEqual(literal("foo"), "foo")
assertEqual(literal("\"foo\""), "foo")
assertEqual(literal("\"\\\"foo\\\"\""), "\"foo\"")
assertEqual(literal("\"foo\\nbar\""), "foo\nbar")
assertEqual(literal("\"foo\\u0026bar\""), "foo&bar")
}
T("escape()", 4)
{
assertEqual(escape(""), "")
assertEqual(escape("foo"), "foo")
assertEqual(escape("\""), "\\\"")
assertEqual(escape("\"foo\""), "\\\"foo\\\"")
}
T("unescape()", 4)
{
assertEqual(unescape(""), "")
assertEqual(unescape("foo"), "foo")
assertEqual(unescape("\\\""), "\"")
assertEqual(unescape("\\\"foo\\\""), "\"foo\"")
}
T("parameterize()", 10)
{
assertEqual(parameterize(""), "''")
assertEqual(parameterize("foo"), "'foo'")
assertEqual(parameterize("foo bar"), "'foo bar'")
assertEqual(parameterize("foo 'bar"), "'foo '\\''bar'")
assertEqual(parameterize("foo \"bar\""), "'foo \"bar\"'")
assertEqual(parameterize("", "\""), "\"\"")
assertEqual(parameterize("foo", "\""), "\"foo\"")
assertEqual(parameterize("foo bar", "\""), "\"foo bar\"")
assertEqual(parameterize("foo 'bar", "\""), "\"foo 'bar\"")
assertEqual(parameterize("foo \"bar\"", "\""), "\"foo \\\"bar\\\"\"")
}
T("unparameterize()", 10)
{
assertEqual(unparameterize("''"), "")
assertEqual(unparameterize("'foo'"), "foo")
assertEqual(unparameterize("'foo bar'"), "foo bar")
assertEqual(unparameterize("'foo '\\''bar'"), "foo 'bar")
assertEqual(unparameterize("'foo \"bar\"'"), "foo \"bar\"")
assertEqual(unparameterize("\"\""), "")
assertEqual(unparameterize("\"foo\""), "foo")
assertEqual(unparameterize("\"foo bar\""), "foo bar")
assertEqual(unparameterize("\"foo 'bar\""), "foo 'bar")
assertEqual(unparameterize("\"foo \\\"bar\\\"\""), "foo \"bar\"")
}
T("toString()", 4)
{
assertEqual(toString(""), "")
assertEqual(toString(42), "42")
assertEqual(toString("foo"), "foo")
assertEqual(toString("\"foo bar\""), "\"foo bar\"")
}
T("squeeze()", 4)
{
assertEqual(squeeze(""), "")
assertEqual(squeeze(" "), "")
assertEqual(squeeze(" "), "")
assertEqual(squeeze(" foo = bar #comments"), "foo = bar")
}
T("yn()", 12)
{
assertFalse(yn(0))
assertFalse(yn("0"))
assertFalse(yn("false"))
assertFalse(yn("no"))
assertFalse(yn("off"))
assertFalse(yn("OFF"))
assertTrue(yn(1))
assertTrue(yn("1"))
assertTrue(yn("true"))
assertTrue(yn("yes"))
assertTrue(yn("on"))
assertTrue(yn("ON"))
}
# URLs
T("quote()", 4)
{
assertEqual(quote(""), "")
assertEqual(quote("foo"), "foo")
assertEqual(quote("foo bar"), "foo%20bar")
assertEqual(quote("\"hello, world!\""), "%22hello%2C%20world%21%22")
}
# un-URLs
T("unquote()", 6)
{
assertEqual(unquote(""), "")
assertEqual(unquote("foo"), "foo")
assertEqual(unquote("foo%20bar"), "foo bar")
assertEqual(unquote("%22hello%2C%20world%21%22"), "\"hello, world!\"")
assertEqual(unquote("foo%%%%bar"), "foo%%%%bar")
assertEqual(unquote("foo%%%%b"), "foo%%%%b")
}
# System
T("fileExists()", 4)
{
assertFalse(fileExists("README"))
assertFalse(fileExists("README .md"))
assertTrue(fileExists("README.md"))
assertFalse(fileExists("."))
}
T("dirExists()", 4)
{
assertFalse(dirExists("README"))
assertFalse(dirExists("README.md"))
assertTrue(dirExists("."))
assertFalse(dirExists(" ."))
}
T("detectProgram()", 2)
{
assertTrue(detectProgram("ls"))
assertTrue(detectProgram("gawk", "--version"))
}
END_TEST()
}
translate-shell-0.9.6.11/test/TestLanguages.awk 0000664 0000000 0000000 00000000703 13516335241 0021304 0 ustar 00root root 0000000 0000000 @include "include/Languages"
BEGIN {
START_TEST("Languages.awk")
T("getCode()", 5)
{
initLocale()
initLocaleAlias()
initLocaleDisplay()
assertEqual(getCode("chinese"), "zh-CN")
assertEqual(getCode("简体中文"), "zh-CN")
assertEqual(getCode("正體中文"), "zh-TW")
assertEqual(getCode("Japanese"), "ja")
assertEqual(getCode("日本語"), "ja")
}
END_TEST()
}
translate-shell-0.9.6.11/test/TestParser.awk 0000664 0000000 0000000 00000010256 13516335241 0020636 0 ustar 00root root 0000000 0000000 @include "include/Parser"
BEGIN {
START_TEST("Parser.awk")
T("tokenize()", 8)
{
delete tokens
tokenize(tokens, "0")
delete expected
expected[0] = "0"
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "3.14")
delete expected
expected[0] = "3.14"
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "Atom")
delete expected
expected[0] = "Atom"
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "\"foo bar\"")
delete expected
expected[0] = "\"foo bar\""
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "\"\\\"\"")
delete expected
expected[0] = "\"\\\"\""
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "(QUOTE A)")
delete expected
expected[0] = "("
expected[1] = "QUOTE"
expected[2] = "A"
expected[3] = ")"
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "1 + 2 * 3")
delete expected
expected[0] = "1"
expected[1] = "+"
expected[2] = "2"
expected[3] = "*"
expected[4] = "3"
assertEqual(tokens, expected)
delete tokens
tokenize(tokens, "[42, \"hello, world\", [Foo, bar]]")
delete expected
expected[0] = "["
expected[1] = "42"
expected[2] = ","
expected[3] = "\"hello, world\""
expected[4] = ","
expected[5] = "["
expected[6] = "Foo"
expected[7] = ","
expected[8] = "bar"
expected[9] = "]"
expected[10] = "]"
assertEqual(tokens, expected)
}
T("parseJson()", 10)
{
delete tokens; delete ast; delete expected
tokenize(tokens, "0")
parseJson(ast, tokens)
expected[0] = "0"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "null")
parseJson(ast, tokens)
expected[0] = "null"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "[42]")
parseJson(ast, tokens)
expected[0 SUBSEP 0] = "42"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "[42, \"answer\", null]")
parseJson(ast, tokens)
expected[0 SUBSEP 0] = "42"
expected[0 SUBSEP 1] = "\"answer\""
expected[0 SUBSEP 2] = "null"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "{\"answer\": [42], \"Answer\": null}")
parseJson(ast, tokens)
expected[0 SUBSEP "answer" SUBSEP 0] = 42
expected[0 SUBSEP "Answer"] = "null"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "{\"answer\": {\"everything\": 42}}")
parseJson(ast, tokens)
expected[0 SUBSEP "answer" SUBSEP "everything"] = "42"
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "{\"answer\": {\"everything\": [42]}}")
parseJson(ast, tokens)
expected[0 SUBSEP "answer" SUBSEP "everything" SUBSEP 0] = "42"
assertEqual(ast, expected)
# empty object - what is the "correct" parsing result?
delete tokens; delete ast; delete expected
tokenize(tokens, "{}")
parseJson(ast, tokens)
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "{\"answer\": {}}")
parseJson(ast, tokens)
assertEqual(ast, expected)
delete tokens; delete ast; delete expected
tokenize(tokens, "{\"answer\": {}, \"Answer\": null}")
parseJson(ast, tokens)
expected[0 SUBSEP "Answer"] = "null"
assertEqual(ast, expected)
}
T("parseList()", 1)
{
delete tokens; delete ast; delete expected
tokenize(tokens, "0")
parseList(ast, tokens)
expected[NULLSTR][0] = "0"
assertEqual(ast, expected)
}
END_TEST()
}
translate-shell-0.9.6.11/test/TestUtils.awk 0000664 0000000 0000000 00000003577 13516335241 0020512 0 ustar 00root root 0000000 0000000 @include "include/Utils"
BEGIN {
START_TEST("Utils.awk")
T("GawkVersion", 1)
{
initGawk()
assertTrue(GawkVersion ~ "^(4|5).")
}
T("Rlwrap", 1)
{
initRlwrap()
assertEqual(Rlwrap, "rlwrap")
}
T("Emacs", 1)
{
initEmacs()
assertEqual(Emacs, "emacs")
}
T("newerVersion()", 5)
{
assertTrue(newerVersion("0.9", "0.8"))
assertTrue(newerVersion("0.9.0.1", "0.9.0"))
assertTrue(newerVersion("1.0", "0.9.9999"))
assertTrue(newerVersion("1.9.9999", "1.9.10"))
assertTrue(newerVersion("2", "1.9.9999"))
}
if (yn(ENVIRON["NETWORK_ACCESS"])) { # if network access enabled
T("curl()", 1)
{
delete tokens; delete ast
tokenize(tokens, curl("https://httpbin.org/get"))
parseJson(ast, tokens)
assertEqual(unparameterize(ast[0 SUBSEP "url"]),
"https://httpbin.org/get")
}
T("curlPost()", 1)
{
delete tokens; delete ast
tokenize(tokens, curlPost("https://httpbin.org/post", "fizz=buzz"))
parseJson(ast, tokens)
assertEqual(unparameterize(ast[0 SUBSEP "url"]),
"https://httpbin.org/post")
}
}
T("dump()", 3)
{
delete group
assertEqual(dump("a", group), 1)
delete group
assertEqual(dump("Århus", group), 6)
delete group
assertEqual(dump("안녕하세요 세계", group), 22)
}
T("dumpX()", 2)
{
delete group
assertEqual(dumpX("a", group), 1)
delete group
assertEqual(dumpX("你好", group), 6)
}
T("base64()", 1)
{
assertEqual(base64("ninja"), "bmluamE=")
}
T("uprintf", 1)
{
assertEqual(uprintf("Ma\\u00f1ana"), "Mañana")
}
END_TEST()
}
translate-shell-0.9.6.11/translate 0000775 0000000 0000000 00000001460 13516335241 0016777 0 ustar 00root root 0000000 0000000 #!/bin/sh
export TRANS_DIR=`dirname $0`
gawk \
-i "${TRANS_DIR}/metainfo.awk" \
-i "${TRANS_DIR}/include/Commons.awk" \
-i "${TRANS_DIR}/include/Utils.awk" \
-i "${TRANS_DIR}/include/Languages.awk" \
-i "${TRANS_DIR}/include/Help.awk" \
-i "${TRANS_DIR}/include/Parser.awk" \
-i "${TRANS_DIR}/include/Theme.awk" \
-i "${TRANS_DIR}/include/Translate.awk" \
-i "${TRANS_DIR}/include/TranslatorInterface.awk" \
-i "${TRANS_DIR}/include/Translators/GoogleTranslate.awk" \
-i "${TRANS_DIR}/include/Translators/BingTranslator.awk" \
-i "${TRANS_DIR}/include/Translators/YandexTranslate.awk" \
-i "${TRANS_DIR}/include/Translators/Apertium.awk" \
-i "${TRANS_DIR}/include/Translators/SpellChecker.awk" \
-i "${TRANS_DIR}/include/Script.awk" \
-i "${TRANS_DIR}/include/REPL.awk" \
-f "${TRANS_DIR}/include/Main.awk" -- "$@"
translate-shell-0.9.6.11/translate-shell.plugin.zsh 0000664 0000000 0000000 00000000071 13516335241 0022176 0 ustar 00root root 0000000 0000000 #!/usr/bin/env zsh
alias trans="$(dirname $0)/translate"
translate-shell-0.9.6.11/translate.awk 0000775 0000000 0000000 00000000650 13516335241 0017560 0 ustar 00root root 0000000 0000000 #!/usr/bin/gawk -f
@include "metainfo.awk"
@include "include/Commons.awk"
@include "include/Utils.awk"
@include "include/Languages.awk"
@include "include/Help.awk"
@include "include/Parser.awk"
@include "include/Theme.awk"
@include "include/Translate.awk"
@include "include/TranslatorInterface.awk"
@include "include/Translators/*"
@include "include/Script.awk"
@include "include/REPL.awk"
@include "include/Main.awk"