pax_global_header00006660000000000000000000000064126347744750014535gustar00rootroot0000000000000052 comment=2eb9a0a468c8863e697ffafed6e59291cb7ee74c translate-shell-0.9.2.1/000077500000000000000000000000001263477447500150065ustar00rootroot00000000000000translate-shell-0.9.2.1/.gitignore000066400000000000000000000000651263477447500167770ustar00rootroot00000000000000/_* /build /gh-pages /registry /wiki *.emacs* *.html translate-shell-0.9.2.1/.travis.yml000066400000000000000000000003211263477447500171130ustar00rootroot00000000000000os: - linux before_install: | sudo add-apt-repository ppa:schot/gawk -y sudo apt-get update -q sudo apt-get install gawk sudo apt-get install rlwrap sudo apt-get install emacs script: make check translate-shell-0.9.2.1/CONTRIBUTING.md000066400000000000000000000016311263477447500172400ustar00rootroot00000000000000## 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.2.1/DISCLAIMER000066400000000000000000000020221263477447500163410ustar00rootroot00000000000000This is free and unencumbered software released into the public domain. This software is provided for the purpose of reasonable personal use of the Google Translate service, i.e., for those who prefer command line to web interface. For other purposes, please refer to the official Google Translate API . By using this software, you ("the user") are aware that: 1. Google Translate is a proprietary service provided and owned by Google Inc. 2. Translate Shell is NOT a Google product. Neither this software nor its author is affiliated with Google Inc. 3. 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. translate-shell-0.9.2.1/LICENSE000066400000000000000000000022731263477447500160170ustar00rootroot00000000000000This 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.2.1/Makefile000066400000000000000000000016661263477447500164570ustar00rootroot00000000000000NAME = "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 'hello world'`" = 'hello world' ] install: @install -D $(BUILDDIR)/$(COMMAND) $(PREFIX)/bin/$(COMMAND) &&\ mkdir -p $(PREFIX)/share/man/man1 &&\ cp $(MANDIR)/$(COMMAND).1 $(PREFIX)/share/man/man1/$(COMMAND).1 &&\ echo "[OK] $(NAME) installed." uninstall: @rm $(PREFIX)/bin/$(COMMAND) $(PREFIX)/share/man/man1/$(COMMAND).1 &&\ echo "[OK] $(NAME) uninstalled." translate-shell-0.9.2.1/README.md000066400000000000000000000741401263477447500162730ustar00rootroot00000000000000# Translate Shell [![Icon](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/icon.png)](http://www.soimort.org/translate-shell) [![Build Status](https://travis-ci.org/soimort/translate-shell.png)](https://travis-ci.org/soimort/translate-shell) [![Version](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/badge-release.png)](https://github.com/soimort/translate-shell/releases) [![Download](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/badge-download.png)](http://www.soimort.org/translate-shell/trans) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/soimort/translate-shell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) **[Translate Shell](http://www.soimort.org/translate-shell)** (formerly _Google Translate CLI_) is a command-line translator powered by **[Google Translate](https://translate.google.com/)**. It gives you easy access to Google Translate 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 * OS X * FreeBSD * Windows (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 OS X, 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. ### Optional Dependencies * **[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/)**, **[mplayer2](http://www.mplayer2.org/)**, **[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 * **[curl](http://curl.haxx.se/)** with **OpenSSL** support * required for secured URL fetching (checking for upgrade, etc.) ### 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 **Please make sure to read [the disclaimer](#disclaimer) before using.** ## 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](http://www.soimort.org/translate-shell/trans.sig). ### Option #2. From Git $ 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 ### Option #3. From A Package Manager On OS X with Homebrew: $ brew install http://www.soimort.org/translate-shell/translate-shell.rb On Linux, you may ignore its dependencies (e.g. gawk) if you already have them in your system: $ brew install --ignore-dependencies http://www.soimort.org/translate-shell/translate-shell.rb See **[wiki: Distros](https://github.com/soimort/translate-shell/wiki/Distros)** on how to install from a specific package manager on your distro. ## Introduction 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 #### 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" ### 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)](http://www.soimort.org/translate-shell/trans.1.html)** or use `trans -M` in a terminal. ``` Usage: trans [OPTIONS] [SOURCE]:[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. -U, -upgrade Check for upgrade of this program. 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. Audio options: -p, -play Listen to the translation. -speak Listen to the original text. -player PROGRAM Specify the audio player to use, and listen to the translation. -no-play Do not listen to the translation. 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 Do not view the translation in a terminal pager. -browser PROGRAM Specify the web browser to use. 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. 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 CODE, -sl CODE, -source CODE Specify the source language. -t CODES, -tl CODE, -target CODES Specify the target language(s), joined by '+'. 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`** | **[Hawaiian](http://en.wikipedia.org/wiki/Hawaiian_language)**
**ʻŌlelo Hawaiʻi** | **`haw`** | **[Portuguese](http://en.wikipedia.org/wiki/Portuguese_language)**
**Português** | **`pt`** | | **[Albanian](http://en.wikipedia.org/wiki/Albanian_language)**
**Shqip** | **`sq`** | **[Hebrew](http://en.wikipedia.org/wiki/Hebrew_language)**
**עִבְרִית** | **`he`** | **[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`** | **[Romanian](http://en.wikipedia.org/wiki/Romanian_language)**
**Română** | **`ro`** | | **[Arabic](http://en.wikipedia.org/wiki/Arabic_language)**
**العربية** | **`ar`** | **[Hmong](http://en.wikipedia.org/wiki/Hmong_language)**
**Hmoob** | **`hmn`** | **[Romansh](http://en.wikipedia.org/wiki/Romansh_language)**
**Rumantsch** | **`rm`** | | **[Armenian](http://en.wikipedia.org/wiki/Armenian_language)**
**Հայերեն** | **`hy`** | **[Hungarian](http://en.wikipedia.org/wiki/Hungarian_language)**
**Magyar** | **`hu`** | **[Russian](http://en.wikipedia.org/wiki/Russian_language)**
**Русский** | **`ru`** | | **[Assamese](http://en.wikipedia.org/wiki/Assamese_language)**
**অসমীয়া** | **`as`** | **[Icelandic](http://en.wikipedia.org/wiki/Icelandic_language)**
**Íslenska** | **`is`** | **[Samoan](http://en.wikipedia.org/wiki/Samoan_language)**
**Gagana Sāmoa** | **`sm`** | | **[Azerbaijani](http://en.wikipedia.org/wiki/Azerbaijani_language)**
**Azərbaycanca** | **`az`** | **[Igbo](http://en.wikipedia.org/wiki/Igbo_language)**
**Igbo** | **`ig`** | **[Scottish Gaelic](http://en.wikipedia.org/wiki/Scottish_Gaelic)**
**Gàidhlig** | **`gd`** | | **[Bashkir](http://en.wikipedia.org/wiki/Bashkir_language)**
**башҡорт теле** | **`ba`** | **[Indonesian](http://en.wikipedia.org/wiki/Indonesian_language)**
**Bahasa Indonesia** | **`id`** | **[Serbian](http://en.wikipedia.org/wiki/Serbian_language)**
**српски** | **`sr`** | | **[Basque](http://en.wikipedia.org/wiki/Basque_language)**
**Euskara** | **`eu`** | **[Interlingue](http://en.wikipedia.org/wiki/Interlingue_language)**
**Interlingue** | **`ie`** | **[Sesotho](http://en.wikipedia.org/wiki/Sesotho_language)**
**Sesotho** | **`st`** | | **[Belarusian](http://en.wikipedia.org/wiki/Belarusian_language)**
**беларуская** | **`be`** | **[Irish](http://en.wikipedia.org/wiki/Irish_language)**
**Gaeilge** | **`ga`** | **[Shona](http://en.wikipedia.org/wiki/Shona_language)**
**chiShona** | **`sn`** | | **[Bengali](http://en.wikipedia.org/wiki/Bengali_language)**
**বাংলা** | **`bn`** | **[Italian](http://en.wikipedia.org/wiki/Italian_language)**
**Italiano** | **`it`** | **[Sindhi](http://en.wikipedia.org/wiki/Sindhi_language)**
**سنڌي** | **`sd`** | | **[Bosnian](http://en.wikipedia.org/wiki/Bosnian_language)**
**Bosanski** | **`bs`** | **[Japanese](http://en.wikipedia.org/wiki/Japanese_language)**
**日本語** | **`ja`** | **[Sinhala](http://en.wikipedia.org/wiki/Sinhala_language)**
**සිංහල** | **`si`** | | **[Breton](http://en.wikipedia.org/wiki/Breton_language)**
**Brezhoneg** | **`br`** | **[Javanese](http://en.wikipedia.org/wiki/Javanese_language)**
**Basa Jawa** | **`jv`** | **[Slovak](http://en.wikipedia.org/wiki/Slovak_language)**
**Slovenčina** | **`sk`** | | **[Bulgarian](http://en.wikipedia.org/wiki/Bulgarian_language)**
**български** | **`bg`** | **[Kannada](http://en.wikipedia.org/wiki/Kannada_language)**
**ಕನ್ನಡ** | **`kn`** | **[Slovenian](http://en.wikipedia.org/wiki/Slovenian_language)**
**Slovenščina** | **`sl`** | | **[Catalan](http://en.wikipedia.org/wiki/Catalan_language)**
**Català** | **`ca`** | **[Kazakh](http://en.wikipedia.org/wiki/Kazakh_language)**
**Қазақ тілі** | **`kk`** | **[Somali](http://en.wikipedia.org/wiki/Somali_language)**
**Soomaali** | **`so`** | | **[Cebuano](http://en.wikipedia.org/wiki/Cebuano_language)**
**Cebuano** | **`ceb`** | **[Khmer](http://en.wikipedia.org/wiki/Khmer_language)**
**ភាសាខ្មែរ** | **`km`** | **[Spanish](http://en.wikipedia.org/wiki/Spanish_language)**
**Español** | **`es`** | | **[Cherokee](http://en.wikipedia.org/wiki/Cherokee_language)**
**ᏣᎳᎩ** | **`chr`** | **[Kinyarwanda](http://en.wikipedia.org/wiki/Kinyarwanda_language)**
**Ikinyarwanda** | **`rw`** | **[Sundanese](http://en.wikipedia.org/wiki/Sundanese_language)**
**Basa Sunda** | **`su`** | | **[Chichewa](http://en.wikipedia.org/wiki/Chichewa_language)**
**Nyanja** | **`ny`** | **[Korean](http://en.wikipedia.org/wiki/Korean_language)**
**한국어** | **`ko`** | **[Swahili](http://en.wikipedia.org/wiki/Swahili_language)**
**Kiswahili** | **`sw`** | | **[Chinese Simplified](http://en.wikipedia.org/wiki/Chinese_Simplified)**
**简体中文** | **`zh-CN`** | **[Kurdish](http://en.wikipedia.org/wiki/Kurdish_language)**
**Kurdî** | **`ku`** | **[Swedish](http://en.wikipedia.org/wiki/Swedish_language)**
**Svenska** | **`sv`** | | **[Chinese Traditional](http://en.wikipedia.org/wiki/Chinese_Traditional)**
**正體中文** | **`zh-TW`** | **[Kyrgyz](http://en.wikipedia.org/wiki/Kyrgyz_language)**
**Кыргызча** | **`ky`** | **[Tajik](http://en.wikipedia.org/wiki/Tajik_language)**
**Тоҷикӣ** | **`tg`** | | **[Corsican](http://en.wikipedia.org/wiki/Corsican_language)**
**Corsu** | **`co`** | **[Lao](http://en.wikipedia.org/wiki/Lao_language)**
**ລາວ** | **`lo`** | **[Tamil](http://en.wikipedia.org/wiki/Tamil_language)**
**தமிழ்** | **`ta`** | | **[Croatian](http://en.wikipedia.org/wiki/Croatian_language)**
**Hrvatski** | **`hr`** | **[Latin](http://en.wikipedia.org/wiki/Latin_language)**
**Latina** | **`la`** | **[Tatar](http://en.wikipedia.org/wiki/Tatar_language)**
**татарча** | **`tt`** | | **[Czech](http://en.wikipedia.org/wiki/Czech_language)**
**Čeština** | **`cs`** | **[Latvian](http://en.wikipedia.org/wiki/Latvian_language)**
**Latviešu** | **`lv`** | **[Telugu](http://en.wikipedia.org/wiki/Telugu_language)**
**తెలుగు** | **`te`** | | **[Danish](http://en.wikipedia.org/wiki/Danish_language)**
**Dansk** | **`da`** | **[Lithuanian](http://en.wikipedia.org/wiki/Lithuanian_language)**
**Lietuvių** | **`lt`** | **[Thai](http://en.wikipedia.org/wiki/Thai_language)**
**ไทย** | **`th`** | | **[Dutch](http://en.wikipedia.org/wiki/Dutch_language)**
**Nederlands** | **`nl`** | **[Luxembourgish](http://en.wikipedia.org/wiki/Luxembourgish_language)**
**Lëtzebuergesch** | **`lb`** | **[Tibetan](http://en.wikipedia.org/wiki/Tibetan_language)**
**བོད་ཡིག** | **`bo`** | | **[Dzongkha](http://en.wikipedia.org/wiki/Dzongkha_language)**
**རྫོང་ཁ** | **`dz`** | **[Macedonian](http://en.wikipedia.org/wiki/Macedonian_language)**
**Македонски** | **`mk`** | **[Tigrinya](http://en.wikipedia.org/wiki/Tigrinya_language)**
**ትግርኛ** | **`ti`** | | **[English](http://en.wikipedia.org/wiki/English_language)**
**English** | **`en`** | **[Malagasy](http://en.wikipedia.org/wiki/Malagasy_language)**
**Malagasy** | **`mg`** | **[Turkish](http://en.wikipedia.org/wiki/Turkish_language)**
**Türkçe** | **`tr`** | | **[Esperanto](http://en.wikipedia.org/wiki/Esperanto_language)**
**Esperanto** | **`eo`** | **[Malay](http://en.wikipedia.org/wiki/Malay_language)**
**Bahasa Melayu** | **`ms`** | **[Turkmen](http://en.wikipedia.org/wiki/Turkmen_language)**
**Türkmen** | **`tk`** | | **[Estonian](http://en.wikipedia.org/wiki/Estonian_language)**
**Eesti** | **`et`** | **[Malayalam](http://en.wikipedia.org/wiki/Malayalam_language)**
**മലയാളം** | **`ml`** | **[Ukrainian](http://en.wikipedia.org/wiki/Ukrainian_language)**
**Українська** | **`uk`** | | **[Faroese](http://en.wikipedia.org/wiki/Faroese_language)**
**Føroyskt** | **`fo`** | **[Maltese](http://en.wikipedia.org/wiki/Maltese_language)**
**Malti** | **`mt`** | **[Urdu](http://en.wikipedia.org/wiki/Urdu_language)**
**اُردُو** | **`ur`** | | **[Fijian](http://en.wikipedia.org/wiki/Fijian_language)**
**Vosa Vakaviti** | **`fj`** | **[Maori](http://en.wikipedia.org/wiki/Maori_language)**
**Māori** | **`mi`** | **[Uyghur](http://en.wikipedia.org/wiki/Uyghur_language)**
**ئۇيغۇر تىلى** | **`ug`** | | **[Filipino](http://en.wikipedia.org/wiki/Filipino_language)**
**Tagalog** | **`tl`** | **[Marathi](http://en.wikipedia.org/wiki/Marathi_language)**
**मराठी** | **`mr`** | **[Uzbek](http://en.wikipedia.org/wiki/Uzbek_language)**
**Oʻzbek tili** | **`uz`** | | **[Finnish](http://en.wikipedia.org/wiki/Finnish_language)**
**Suomi** | **`fi`** | **[Mongolian](http://en.wikipedia.org/wiki/Mongolian_language)**
**Монгол** | **`mn`** | **[Vietnamese](http://en.wikipedia.org/wiki/Vietnamese_language)**
**Tiếng Việt** | **`vi`** | | **[French](http://en.wikipedia.org/wiki/French_language)**
**Français** | **`fr`** | **[Myanmar](http://en.wikipedia.org/wiki/Myanmar_language)**
**မြန်မာစာ** | **`my`** | **[Volapük](http://en.wikipedia.org/wiki/Volapük_language)**
**Volapük** | **`vo`** | | **[Galician](http://en.wikipedia.org/wiki/Galician_language)**
**Galego** | **`gl`** | **[Nepali](http://en.wikipedia.org/wiki/Nepali_language)**
**नेपाली** | **`ne`** | **[Welsh](http://en.wikipedia.org/wiki/Welsh_language)**
**Cymraeg** | **`cy`** | | **[Georgian](http://en.wikipedia.org/wiki/Georgian_language)**
**ქართული** | **`ka`** | **[Norwegian](http://en.wikipedia.org/wiki/Norwegian_language)**
**Norsk** | **`no`** | **[Western Frisian](http://en.wikipedia.org/wiki/Western_Frisian)**
**Frysk** | **`fy`** | | **[German](http://en.wikipedia.org/wiki/German_language)**
**Deutsch** | **`de`** | **[Occitan](http://en.wikipedia.org/wiki/Occitan_language)**
**Occitan** | **`oc`** | **[Wolof](http://en.wikipedia.org/wiki/Wolof_language)**
**Wollof** | **`wo`** | | **[Greek](http://en.wikipedia.org/wiki/Greek_language)**
**Ελληνικά** | **`el`** | **[Oriya](http://en.wikipedia.org/wiki/Oriya_language)**
**ଓଡ଼ିଆ** | **`or`** | **[Xhosa](http://en.wikipedia.org/wiki/Xhosa_language)**
**isiXhosa** | **`xh`** | | **[Guarani](http://en.wikipedia.org/wiki/Guarani_language)**
**Avañe'ẽ** | **`gn`** | **[Oromo](http://en.wikipedia.org/wiki/Oromo_language)**
**Afaan Oromoo** | **`om`** | **[Yiddish](http://en.wikipedia.org/wiki/Yiddish_language)**
**ייִדיש** | **`yi`** | | **[Gujarati](http://en.wikipedia.org/wiki/Gujarati_language)**
**ગુજરાતી** | **`gu`** | **[Pashto](http://en.wikipedia.org/wiki/Pashto_language)**
**پښتو** | **`ps`** | **[Yoruba](http://en.wikipedia.org/wiki/Yoruba_language)**
**Yorùbá** | **`yo`** | | **[Haitian Creole](http://en.wikipedia.org/wiki/Haitian_Creole)**
**Kreyòl Ayisyen** | **`ht`** | **[Persian](http://en.wikipedia.org/wiki/Persian_language)**
**فارسی** | **`fa`** | **[Zulu](http://en.wikipedia.org/wiki/Zulu_language)**
**isiZulu** | **`zu`** | | **[Hausa](http://en.wikipedia.org/wiki/Hausa_language)**
**Hausa** | **`ha`** | **[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)** * **[Configuration](https://github.com/soimort/translate-shell/wiki/Configuration)** * **[Themes](https://github.com/soimort/translate-shell/wiki/Themes)** 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)** ## How to Report Bugs / Contribute **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.** ## Disclaimer This software is provided for the purpose of **reasonable personal use** of the Google Translate service, i.e., for those who prefer command line to web interface. For other purposes, please refer to the official [Google Translate API](https://developers.google.com/translate/). By using this software, you ("the user") are aware that: 1. **Google Translate** is a proprietary service provided and owned by Google Inc. 2. **Translate Shell** is **NOT** a Google product. Neither this software nor its author is affiliated with Google Inc. 3. 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. ## Copyright Waiver 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.2.1/README.template.md000066400000000000000000000334601263477447500201050ustar00rootroot00000000000000# Translate Shell [![Icon](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/icon.png)](http://www.soimort.org/translate-shell) [![Build Status](https://travis-ci.org/soimort/translate-shell.png)](https://travis-ci.org/soimort/translate-shell) [![Version](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/badge-release.png)](https://github.com/soimort/translate-shell/releases) [![Download](https://raw.githubusercontent.com/soimort/translate-shell/gh-pages/images/badge-download.png)](http://www.soimort.org/translate-shell/trans) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/soimort/translate-shell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) **[Translate Shell](http://www.soimort.org/translate-shell)** (formerly _Google Translate CLI_) is a command-line translator powered by **[Google Translate](https://translate.google.com/)**. It gives you easy access to Google Translate 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 * OS X * FreeBSD * Windows (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 OS X, 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. ### Optional Dependencies * **[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/)**, **[mplayer2](http://www.mplayer2.org/)**, **[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 * **[curl](http://curl.haxx.se/)** with **OpenSSL** support * required for secured URL fetching (checking for upgrade, etc.) ### 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 **Please make sure to read [the disclaimer](#disclaimer) before using.** ## 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](http://www.soimort.org/translate-shell/trans.sig). ### Option #2. From Git $ 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 ### Option #3. From A Package Manager On OS X with Homebrew: $ brew install http://www.soimort.org/translate-shell/translate-shell.rb On Linux, you may ignore its dependencies (e.g. gawk) if you already have them in your system: $ brew install --ignore-dependencies http://www.soimort.org/translate-shell/translate-shell.rb See **[wiki: Distros](https://github.com/soimort/translate-shell/wiki/Distros)** on how to install from a specific package manager on your distro. ## Introduction 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 #### 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" ### 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)](http://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$ ## How to Report Bugs / Contribute **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.** ## Disclaimer This software is provided for the purpose of **reasonable personal use** of the Google Translate service, i.e., for those who prefer command line to web interface. For other purposes, please refer to the official [Google Translate API](https://developers.google.com/translate/). By using this software, you ("the user") are aware that: 1. **Google Translate** is a proprietary service provided and owned by Google Inc. 2. **Translate Shell** is **NOT** a Google product. Neither this software nor its author is affiliated with Google Inc. 3. 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. ## Copyright Waiver 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.2.1/WAIVER000066400000000000000000000015631263477447500157330ustar00rootroot00000000000000# 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.2.1/build.awk000077500000000000000000000266151263477447500166260ustar00rootroot00000000000000#!/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" HomebrewFormula = PagesPath "translate-shell.rb" 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 -t html --toc --toc-depth 1 --template " ManHtmlTemplate " " ManMarkdown " -o " ManHtml) return system("pandoc -s -t man " ManMarkdown " -o " Man) } function readme( code, col, cols, content, group, i, j, language, r, rows, text) { text = readFrom(ReadmeTemplate) content = getOutput("gawk -f translate.awk -- -no-ansi -h") gsub(/\$usage\$/, content, text) initBiDi(); initLocale() rows = int(length(Locale) / 3) + 1 cols[0][0] = cols[1][0] = cols[2][0] = NULLSTR i = 0 saveSortedIn = PROCINFO["sorted_in"] PROCINFO["sorted_in"] = "compName" for (code in Locale) { 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. " \ "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) { split(getISO(code), group, "-") iso = group[1] split(getName(code), group, " ") language = length(group) == 1 ? 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 build(target, type, 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 print "#" > Trans if (fileExists("DISCLAIMER")) while (getline line < "DISCLAIMER") print "# " line > Trans print "#" > Trans print "if ! [[ $LANG =~ '[UTF|utf]-?8$' ]]; then export LANG=en_US.UTF-8; fi" > Trans print "read -r -d '' TRANS_PROGRAM << 'EOF'" > Trans if (fileExists(EntryPoint)) while (getline line < EntryPoint) { match(line, /^[[:space:]]*@include[[:space:]]*"(.*)"$/, group) if (RSTART) { # Include file if (fileExists(group[1] ".awk")) while (getline inline < (group[1] ".awk")) if (inline = squeeze(inline)) print inline > Trans # effective LOC } else { if (line && line !~ /^[[:space:]]*#!/) { # Remove preceding spaces gsub(/^[[:space:]]+/, "", line) print line > 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 return 0 } else if (target == "awk" || target == "gawk") { "uname -s" | getline temp if (fileExists(EntryPoint)) while (getline line < EntryPoint) { match(line, /^[[:space:]]*@include[[:space:]]*"(.*)"$/, group) if (RSTART) { # Include file if (fileExists(group[1] ".awk")) while (getline inline < (group[1] ".awk")) if (inline = squeeze(inline, 1)) print inline > TransAwk } else { if (temp == "Darwin" && line == "#!/usr/bin/gawk -f") # OS X: gawk not in /usr/bin, use a better shebang print "#!/usr/bin/env gawk -f" > TransAwk else print line > 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/translate-shell.rb ...") # Update gh-pages/translate-shell.rb ("sha1sum " PagesPath "translate-shell.tar.gz") | getline temp split(temp, group) sha1 = group[1] text = readFrom(HomebrewFormula ".temp") gsub(/\$sha1\$/, sha1, text) gsub(/\$Version\$/, Version, text) writeTo(text, HomebrewFormula) 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.2.1/google-translate-mode.el000066400000000000000000000041361263477447500215250ustar00rootroot00000000000000;;; 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.2.1/include/000077500000000000000000000000001263477447500164315ustar00rootroot00000000000000translate-shell-0.9.2.1/include/Commons.awk000066400000000000000000000327231263477447500205570ustar00rootroot00000000000000#################################################################### # Commons.awk # #################################################################### # Initialize constants. function initConst() { NULLSTR = "" 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 } ## 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 } # Join an array into one string; # Return the string. function join(array, separator, sortedIn, preserveNull, #### i, j, saveSortedIn, temp) { # Default parameters if (!separator) separator = " " if (!sortedIn) sortedIn = "@ind_num_asc" 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' 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 } # Return the escaped, quoted string. function parameterize(string, quotationMark) { if (!quotationMark) quotationMark = "'" if (quotationMark == "'") { gsub(/'/, "'\\''", string) return "'" string "'" } else { return "\"" escape(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 = "@ind_num_asc" 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 = "@ind_num_asc" 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["\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 } # 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 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, temp) { if (returnOutput) { prog " " arg SUPERR | getline temp return temp } else return (prog " " arg SUPERR | getline) ? prog : 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.2.1/include/GenTK.awk000066400000000000000000000024251263477447500201100ustar00rootroot00000000000000#################################################################### # GenTK.awk # #################################################################### # # Last Updated: 18 Dec 2015 # https://translate.google.com/translate/releases/twsfe_w_20151214_RC03/r/js/desktop_module_main.js 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]" 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] } translate-shell-0.9.2.1/include/Help.awk000066400000000000000000000412131263477447500200260ustar00rootroot00000000000000#################################################################### # Help.awk # #################################################################### # Return version as a string. function getVersion( build, gitHead, platform) { initAudioPlayer() initPager() 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", "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", "terminal type", ENVIRON["TERM"]) \ sprintf("%-22s%s (%s)\n", "user locale", UserLocale, getName(UserLang)) \ sprintf("%-22s%s\n", "home language", Option["hl"]) \ sprintf("%-22s%s\n", "source language", Option["sl"]) \ sprintf("%-22s%s\n", "target language", join(Option["tl"], "+")) \ 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", "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", "SOURCE") "]" \ ":[" 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", "-U") ", " ansi("bold", "-upgrade")) RS \ ins(2, "Check for upgrade of this program.") 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 \ 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", "-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 \ 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")) 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 \ 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 \ 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", "CODE") \ ", " ansi("bold", "-sl ") ansi("underline", "CODE") \ ", " ansi("bold", "-source ") ansi("underline", "CODE")) RS \ ins(2, "Specify the source language.") RS \ ins(1, ansi("bold", "-t ") ansi("underline", "CODES") \ ", " ansi("bold", "-tl ") ansi("underline", "CODE") \ ", " ansi("bold", "-target ") ansi("underline", "CODES")) RS \ ins(2, "Specify the target language(s), joined by '+'.") 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("man/" Command ".1")) system("man 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, r, rows, saveSortedIn, t, tt) { rows = int(length(Locale) / 3) + 1 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) { col = int(i / rows) append(cols[col], code) i++ } PROCINFO["sorted_in"] = saveSortedIn if (displayName == "endonym") { r = "┌" replicate("─", 22) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS for (i = 0; i < rows; i++) { r = r "│ " for (j = 0; j < 3; j++) { if (cols[j][i]) { t = cols[j][i] == "bo" || cols[j][i] == "dz" || cols[j][i] == "he" || cols[j][i] == "hi" || cols[j][i] == "hu" || cols[j][i] == "la" || cols[j][i] == "ml" || cols[j][i] == "mn" || cols[j][i] == "ne" || cols[j][i] == "ny" || cols[j][i] == "pa" || cols[j][i] == "pl" || cols[j][i] == "ro" || cols[j][i] == "sr" || cols[j][i] == "te" || cols[j][i] == "tg" || cols[j][i] == "tr" || cols[j][i] == "ur" || cols[j][i] == "wo" || cols[j][i] == "yi" || cols[j][i] == "yo" || (cols[j][i] != "zh-CN" && cols[j][i] != "zh-TW" && length(getEndonym(cols[j][i])) < 6) ? "\t\t " : cols[j][i] == "id" ? "" : cols[j][i] == "haw" ? " " : "\t " tt = length(cols[j][i]) == 3 ? " │" : (cols[j][i] != "zh-CN" && cols[j][i] != "zh-TW") ? " │" : "" r = r getDisplay(cols[j][i]) t "- " ansi("bold", cols[j][i]) tt " " } else r = r "\t\t │" } r = r RS } r = r "└" replicate("─", 22) "┴" replicate("─", 23) "┴" replicate("─", 23) "┘" } else { r = "┌" replicate("─", 22) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS for (i = 0; i < rows; i++) { r = r "│ " for (j = 0; j < 3; j++) { if (cols[j][i]) { t = cols[j][i] == "he" || cols[j][i] == "kk" || cols[j][i] == "ko" || cols[j][i] == "ky" || cols[j][i] == "ne" || cols[j][i] == "pl" || cols[j][i] == "ps" || cols[j][i] == "sd" || cols[j][i] == "sk" || cols[j][i] == "sm" || cols[j][i] == "so" || cols[j][i] == "te" || cols[j][i] == "ug" || cols[j][i] == "yo" || (cols[j][i] != "zh-CN" && cols[j][i] != "zh-TW" && length(getName(cols[j][i])) < 6) ? "\t\t " : cols[j][i] == "fy" || cols[j][i] == "gd" || cols[j][i] == "ht" ? " " : "\t " tt = length(cols[j][i]) == 3 ? " │" : (cols[j][i] != "zh-CN" && cols[j][i] != "zh-TW") ? " │" : "" name = getName(cols[j][i]) if (cols[j][i] == "zh-CN" || cols[j][i] == "zh-TW") name = substr(name, 1, 12) "." r = r name t "- " ansi("bold", cols[j][i]) tt " " } else r = r "\t\t │" } r = r RS } r = r "└" replicate("─", 22) "┴" 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.2.1/include/Languages.awk000066400000000000000000002555711263477447500210620ustar00rootroot00000000000000#################################################################### # Languages.awk # #################################################################### # Initialize all locales supported on Google Translate. # 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( i) { #? Amharic Locale["am"]["support"] = "unstable" Locale["am"]["name"] = "Amharic" Locale["am"]["endonym"] = "አማርኛ" #Locale["am"]["translations-of"] #Locale["am"]["definitions-of"] #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" #? 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"] = "unstable" 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" #? Corsican Locale["co"]["support"] = "unstable" Locale["co"]["name"] = "Corsican" Locale["co"]["endonym"] = "Corsu" #Locale["co"]["translations-of"] #Locale["co"]["definitions-of"] #Locale["co"]["synonyms"] #Locale["co"]["examples"] #Locale["co"]["see-also"] Locale["co"]["family"] = "Indo-European" Locale["co"]["iso"] = "cos" Locale["co"]["glotto"] = "cors1242" Locale["co"]["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" #? 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" #? Fijian Locale["fj"]["support"] = "unstable" Locale["fj"]["name"] = "Fijian" Locale["fj"]["endonym"] = "Vosa Vakaviti" #Locale["fj"]["translations-of"] #Locale["fj"]["definitions-of"] #Locale["fj"]["synonyms"] #Locale["fj"]["examples"] #Locale["fj"]["see-also"] Locale["fj"]["family"] = "Austronesian" Locale["fj"]["iso"] = "fij" Locale["fj"]["glotto"] = "fiji1243" Locale["fj"]["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" #? 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" #? Kyrgyz Locale["ky"]["support"] = "unstable" Locale["ky"]["name"] = "Kyrgyz" Locale["ky"]["endonym"] = "Кыргызча" #Locale["ky"]["translations-of"] #Locale["ky"]["definitions-of"] #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" #? Kurdish (Central Kurdish, Sorani), Latin alphabet Locale["ku"]["support"] = "unstable" 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" #? Luxembourgish Locale["lb"]["support"] = "unstable" 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" #? 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" #? Pashto Locale["ps"]["support"] = "unstable" Locale["ps"]["name"] = "Pashto" Locale["ps"]["endonym"] = "پښتو" #Locale["ps"]["translations-of"] #Locale["ps"]["definitions-of"] #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 #? 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" #? Sindhi Locale["sd"]["support"] = "unstable" Locale["sd"]["name"] = "Sindhi" Locale["sd"]["endonym"] = "سنڌي" #Locale["sd"]["translations-of"] #Locale["sd"]["definitions-of"] #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 #? Samoan Locale["sm"]["support"] = "unstable" 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" #? Scottish Gaelic Locale["gd"]["support"] = "unstable" Locale["gd"]["name"] = "Scottish Gaelic" Locale["gd"]["endonym"] = "Gàidhlig" #Locale["gd"]["translations-of"] #Locale["gd"]["definitions-of"] #Locale["gd"]["synonyms"] #Locale["gd"]["examples"] #Locale["gd"]["see-also"] Locale["gd"]["family"] = "Indo-European" Locale["gd"]["iso"] = "gla" Locale["gd"]["glotto"] = "scot1245" Locale["gd"]["script"] = "Latn" #? Shona Locale["sn"]["support"] = "unstable" Locale["sn"]["name"] = "Shona" Locale["sn"]["endonym"] = "chiShona" #Locale["sn"]["translations-of"] #Locale["sn"]["definitions-of"] #Locale["sn"]["synonyms"] #Locale["sn"]["examples"] #Locale["sn"]["see-also"] Locale["sn"]["family"] = "Atlantic-Congo" Locale["sn"]["iso"] = "sna" Locale["sn"]["glotto"] = "core1255" Locale["sn"]["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"] = "unstable" 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" #? 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" #? Western Frisian Locale["fy"]["support"] = "unstable" Locale["fy"]["name"] = "Western Frisian" Locale["fy"]["endonym"] = "Frysk" #Locale["fy"]["translations-of"] #Locale["fy"]["definitions-of"] #Locale["fy"]["synonyms"] #Locale["fy"]["examples"] #Locale["fy"]["see-also"] Locale["fy"]["family"] = "Indo-European" Locale["fy"]["iso"] = "fry" Locale["fy"]["glotto"] = "west2354" Locale["fy"]["script"] = "Latn" #? Xhosa Locale["xh"]["support"] = "unstable" Locale["xh"]["name"] = "Xhosa" Locale["xh"]["endonym"] = "isiXhosa" #Locale["xh"]["translations-of"] #Locale["xh"]["definitions-of"] #Locale["xh"]["synonyms"] #Locale["xh"]["examples"] #Locale["xh"]["see-also"] Locale["xh"]["family"] = "Atlantic-Congo" Locale["xh"]["iso"] = "xho" Locale["xh"]["glotto"] = "xhos1239" Locale["xh"]["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" #? Hawaiian Locale["haw"]["support"] = "unstable" 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" #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 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 #4 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" #5 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" #6 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" #7 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" #8 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" #9 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" #10 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" #11 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" #12 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" #13 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" #14a 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 #14b 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 #15 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" #16 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" #17 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" #18 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 #19 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 #20 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" #21 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" #22 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" #23 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" #24 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 #25 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" #26 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" #27 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 #28 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" #29 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" #30 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" #31 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" #32 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 #33 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" #34 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" #35 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" #36 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" #37 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" #38 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" #39 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" #40 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 #41 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 #42 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" #43 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" #44 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" #45 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" #46 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 #47 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" #48 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" #49 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" #50 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" #51 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" #52 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" #53 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" #54 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" #55 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" #56 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" #57 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" #58 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" #59 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" #60 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" #61 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" #62 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 #63 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" #64 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 #65 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" #66 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" #67 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 #68 Serbian, Cyrillic alphabet Locale["sr"]["name"] = "Serbian" Locale["sr"]["endonym"] = "српски" Locale["sr"]["translations-of"] = "Преводи за „%s“" Locale["sr"]["definitions-of"] = "Дефиниције за %s" Locale["sr"]["synonyms"] = "Синоними" Locale["sr"]["examples"] = "Примери" Locale["sr"]["see-also"] = "Погледајте такође" Locale["sr"]["family"] = "Indo-European" Locale["sr"]["iso"] = "srp" Locale["sr"]["glotto"] = "serb1264" Locale["sr"]["script"] = "Cyrl" #69 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" #70 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" #71 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" #72 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" #73 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" #74 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 #75 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" #76 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" #77 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" #78 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" #79 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" #80 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" #81 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" #82 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" #83 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" #84 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 #85 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" #86 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" #87 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" #88 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 #89 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" #90 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" for (i in Locale) { # Initialize strings for displaying endonyms of locales Locale[i]["display"] = show(Locale[i]["endonym"], i) # 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" # Serbo-Croatian: default to Serbian LocaleAlias["zh"] = "zh-CN" # Chinese: default to Chinese Simplified LocaleAlias["zho"] = "zh-CN" LocaleAlias["chinese"] = "zh-CN" # TODO: more aliases } # Get locale key by language code or alias. function getCode(code) { 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)] else 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 "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)) return prettify("languages", sprintf("%-22s%s\n", "Unknown code", ansi("bold", code))) 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" : 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", "Ethnologue", ansi("bold", "http://www.ethnologue.com/language/" 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, temp) { if (!code || isRTL(code)) { if (Cache[text][0]) return Cache[text][0] else { if ((FriBidi || (code && isRTL(code))) && BiDiNoPad) ("echo " parameterize(text) PIPE BiDiNoPad) | getline temp 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, 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) ("echo " parameterize(text) PIPE sprintf(BiDi, width)) | getline temp 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["LANGUAGE"]) { if (!UserLocale) UserLocale = lang utf = utf || tolower(lang) ~ /utf-?8$/ } 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.2.1/include/Main.awk000066400000000000000000000435351263477447500200330ustar00rootroot00000000000000#################################################################### # Main.awk # #################################################################### # Initialization. function init() { initGawk() initBiDi() # (Languages.awk) initLocale() initUserLang() RS = "\n" ExitCode = 0 Option["debug"] = 0 # 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["theme"] = "default" # Audio Option["play"] = 0 Option["player"] = ENVIRON["PLAYER"] # 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; rv:40.0) Gecko/20100101 Firefox/40.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["tl"][1] = ENVIRON["TARGET_LANG"] ? ENVIRON["TARGET_LANG"] : UserLang } # 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["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( group, temp) { # (Translate.awk) initHttpService() # Initialize screen width if not set if (!Option["width"] && detectProgram("tput", "-V")) { "tput cols" | getline temp Option["width"] = temp ? temp - 2 : 64 } # Disable ANSI escape codes if required if (Option["no-ansi"]) delete AnsiCode # 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"]) { "xdg-mime query default text/html" SUPERR | getline Option["browser"] match(Option["browser"], "(.*).desktop$", group) Option["browser"] = group[1] } } # 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 } # -U, -upgrade match(ARGV[pos], /^--?(U|upgrade)$/) if (RSTART) { InfoOnly = "upgrade" continue } # -N, -nothing match(ARGV[pos], /^--?(N|nothing)$/) if (RSTART) { InfoOnly = "nothing" 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"] = -1 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 } ## 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 } # -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 } ## 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 match(ARGV[pos], /^--?no-view$/) 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 } ## 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 } ## 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 CODE, -sl CODE, -source CODE match(ARGV[pos], /^--?s(o(u(r(ce?)?)?)?|l)?(=(.*)?)?$/, group) if (RSTART) { Option["sl"] = group[5] ? (group[6] ? group[6] : Option["sl"]) : ARGV[++pos] continue } # -t CODES, -tl CODE, -target CODES match(ARGV[pos], /^--?t(a(r(g(et?)?)?)?|l)?(=(.*)?)?$/, 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:]])?)?)[})\]]?$/, group) if (RSTART) { if (group[1]) Option["sl"] = group[1] if (group[4]) split(group[4], Option["tl"], "+") 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 "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] 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"]))) translate(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.2.1/include/Parser.awk000066400000000000000000000214621263477447500203760ustar00rootroot00000000000000#################################################################### # 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 } } } # 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.2.1/include/REPL.awk000066400000000000000000000132771263477447500177110ustar00rootroot00000000000000#################################################################### # 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 language # 's' is the format-control character for string # %S : source language (English name) if (p ~ /%S/) gsub(/%S/, getName(Option["sl"]), p) # %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 ~ /% STDERR } # REPL. function repl(line, command, group, i, 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 { match(command, /^[{(\[]?([[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?)[})\]]?$/, group) if (RSTART) { if (group[1]) Option["sl"] = group[1] if (group[4]) split(group[4], Option["tl"], "+") line = words[2] for (i = 3; i <= length(words); i++) line = line " " words[i] } if (line) { translate(line) # Interactive verbose mode: newline after each translation if (Option["verbose"]) printf RS } } prompt() } translate-shell-0.9.2.1/include/Script.awk000066400000000000000000000045311263477447500204040ustar00rootroot00000000000000#################################################################### # 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" "http://www.soimort.org/translate-shell/trans") } else { w("Current version: \t" Version) w("Already up-to-date.") } } translate-shell-0.9.2.1/include/Theme.awk000066400000000000000000000141031263477447500201760ustar00rootroot00000000000000#################################################################### # 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") { 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.2.1/include/Translate.awk000066400000000000000000000625071263477447500211040ustar00rootroot00000000000000#################################################################### # Translate.awk # #################################################################### # Detect external audio player (mplayer, mpv, mpg123). function initAudioPlayer() { AudioPlayer = !system("mplayer" SUPOUT SUPERR) ? "mplayer" : (!system("mpv" SUPOUT SUPERR) ? "mpv" : (!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() { HttpProtocol = "http://" HttpHost = "translate.google.com" HttpPort = 80 if (Option["proxy"]) { match(Option["proxy"], /^(http:\/*)?([^\/]*):([^\/:]*)/, HttpProxySpec) HttpService = "/inet/tcp/0/" HttpProxySpec[2] "/" HttpProxySpec[3] HttpPathPrefix = HttpProtocol HttpHost } else { HttpService = "/inet/tcp/0/" HttpHost "/" HttpPort HttpPathPrefix = "" } } # Pre-process string (URL-encode before send). function preprocess(text) { return quote(text) } # 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 request and get response from Google Translate. function getResponse(text, sl, tl, hl, content, header, url) { url = HttpPathPrefix "/translate_a/single?client=t" \ "&ie=UTF-8&oe=UTF-8" \ "&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at" \ "&sl=" sl "&tl=" tl "&hl=" hl \ "&tk=" genTK(text) "&q=" preprocess(text) header = "GET " url " HTTP/1.1\n" \ "Host: " HttpHost "\n" \ "Connection: close\n" if (Option["user-agent"]) header = header "User-Agent: " Option["user-agent"] "\n" print header |& HttpService while ((HttpService |& getline) > 0) { if ($0 ~ /^\[.*\]/) content = $0 l(sprintf("%4s bytes > %s", length($0), $0)) } close(HttpService) return assert(content, "[ERROR] Null response.") } # Print a string (to output file or terminal pager). function p(string) { if (Option["view"]) print string | Option["pager"] else print string > Option["output"] } # Play using Google Text-to-Speech engine. function play(text, tl, url) { url = HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=t" \ "&tl=" tl "&tk=" genTK(text) "&q=" preprocess(text) # Don't use getline from pipe here - the same pipe will be run only once for each AWK script! system(Option["player"] " " parameterize(url) SUPOUT SUPERR) } # Get the translation of a string. function getTranslation(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, 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) 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"] = "@ind_num_asc" for (i in ast) { if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "0$") append(translations, postprocess(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]] = postprocess(literal(ast[i])) # 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] = postprocess(literal(ast[i])) # 13 - (original) examples if (match(i, "^0" SUBSEP "13" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group)) oExamples[group[1]] = postprocess(literal(ast[i])) # 14 - (original) see also if (match(i, "^0" SUBSEP "14" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group)) oSeeAlso[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"] < 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 (hasWordClasses || !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") r = r prettify("translation", s(translation, 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, /(\u003cb\u003e|\u003c\/b\u003e)/) 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 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) { system(Option["browser"] " " parameterize("https://translate.google.com/translate?" \ "hl=" hl "&sl=" sl "&tl=" tl "&u=" uri) "&") } # 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 { p(getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"], playlist, il)) 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 } } } 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 translate(line) } } else e("[ERROR] File not found: " Option["input"]) } translate-shell-0.9.2.1/include/Utils.awk000066400000000000000000000125361263477447500202440ustar00rootroot00000000000000#################################################################### # 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 external bidirectional algorithm utility (fribidi); # Fallback to Unix `rev` if not found. function initBiDi() { FriBidi = detectProgram("fribidi", "--version", 1) BiDiNoPad = FriBidi ? "fribidi --nopad" : "rev" BiDi = FriBidi ? "fribidi --width %s" : "rev | sed \"s/'/\\\\\\'/\" | xargs printf '%%s '" } # 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 } else if (!(ENVIRON["TRANS_PROGRAM"] || fileExists(EntryPoint))) { l(">> not found: $TRANS_PROGRAM or EntryPoint") return 1 } else { command = Rlwrap " " Gawk " " (ENVIRON["TRANS_PROGRAM"] ? "\"${TRANS_PROGRAM}\"" : "-f " EntryPoint) \ " - " parameterize("-no-rlwrap") # never fork rlwrap again! 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 } else if (!(ENVIRON["TRANS_PROGRAM"] || fileExists(EntryPoint))) { l(">> not found: $TRANS_PROGRAM or EntryPoint") return 1 } else { params = "" for (i = 1; i < length(ARGV); i++) if (ARGV[i]) params = params " " parameterize(ARGV[i], "\"") if (ENVIRON["TRANS_PROGRAM"]) { el = "(progn (setq trans-program (getenv \"TRANS_PROGRAM\")) " \ "(setq explicit-shell-file-name \"" Gawk "\") " \ "(setq explicit-" Gawk "-args (cons trans-program '(\"-\" \"-I\" \"-no-rlwrap\"" params "))) " \ "(command-execute 'shell) (rename-buffer \"" Name "\"))" } else { el = "(progn (setq explicit-shell-file-name \"" Gawk "\") " \ "(setq explicit-" Gawk "-args '(\"-f\" \"" EntryPoint "\" \"--\" \"-I\" \"-no-rlwrap\"" params ")) " \ "(command-execute 'shell) (rename-buffer \"" Name "\"))" } 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, command, content, line) { initCurl() if (!Curl) { l(">> not found: curl") w("[WARNING] curl is not found.") return NULLSTR } else { command = Curl " --location --silent " url content = NULLSTR while ((command |& getline line) > 0) content = (content ? content "\n" : NULLSTR) line return content } } # Dump a Unicode string into a byte array. Return the length of the array. # NOTE: can only be ran once for each text! Build a cache. 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\" \" \"'" ("echo " parameterize(text) PIPE command) | getline temp split(temp, group, " ") return length(group) - 1 } translate-shell-0.9.2.1/man/000077500000000000000000000000001263477447500155615ustar00rootroot00000000000000translate-shell-0.9.2.1/man/trans.1000066400000000000000000000244301263477447500167750ustar00rootroot00000000000000.\" Automatically generated by Pandoc 1.15.2.1 .\" .hy .TH "TRANS" "1" "2015\-12\-18" "0.9.2.1" "" .SH NAME .PP trans \- Google Translate served as a command\-line tool .SH SYNOPSIS .PP \f[B]trans\f[] [\f[I]OPTIONS\f[]] [\f[I]SOURCE\f[]]:[\f[I]TARGETS\f[]] [\f[I]TEXT\f[]]... .SH DESCRIPTION .PP This tool uses Google Translate to translate text into any language. .PP Each command\-line argument which is not a valid option is treated as \f[I]TEXT\f[] to be translated. .PP If neither \f[I]TEXT\f[] 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[], \f[B]\-version\f[] Print version and exit. .RS .RE .TP .B \f[B]\-H\f[], \f[B]\-help\f[] Print help message and exit. .RS .RE .TP .B \f[B]\-M\f[], \f[B]\-man\f[] Show man page and exit. .RS .RE .TP .B \f[B]\-T\f[], \f[B]\-reference\f[] 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). .RS .RE .TP .B \f[B]\-R\f[], \f[B]\-reference\-english\f[] Print reference table of all supported languages and codes, and exit. Names of languages are displayed in English. .RS .RE .TP .B \f[B]\-L\f[] \f[I]CODES\f[], \f[B]\-list\f[] \f[I]CODES\f[] Print details of languages and exit. When specifying two or more language codes, concatenate them by plus sign "+". .RS .RE .TP .B \f[B]\-U\f[], \f[B]\-upgrade\f[] Check for upgrade of this program. .RS .RE .SS Display options .TP .B \f[B]\-verbose\f[] 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[], \f[B]\-brief\f[] Brief mode. .RS .PP Show the most relevant translation or its phonetic notation only. .RE .TP .B \f[B]\-d\f[], \f[B]\-dictionary\f[] Dictionary mode. .RS .PP Show the definition of the original word in the dictionary. .RE .TP .B \f[B]\-identify\f[] Language identification. .RS .PP Show the identified language of the original text. .RE .TP .B \f[B]\-show\-original\f[] \f[I]Y/n\f[] Show original text or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-original\-phonetics\f[] \f[I]Y/n\f[] Show phonetic notation of original text or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-translation\f[] \f[I]Y/n\f[] Show translation or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-translation\-phonetics\f[] \f[I]Y/n\f[] Show phonetic notation of translation or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-prompt\-message\f[] \f[I]Y/n\f[] Show prompt message or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-languages\f[] \f[I]Y/n\f[] Show source and target languages or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-original\-dictionary\f[] \f[I]y/N\f[] 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[] \f[I]Y/n\f[] Show dictionary entry of translation or not. (default: yes) .RS .RE .TP .B \f[B]\-show\-alternatives\f[] \f[I]Y/n\f[] Show alternative translations or not. (default: yes) .RS .RE .TP .B \f[B]\-w\f[] \f[I]NUM\f[], \f[B]\-width\f[] \f[I]NUM\f[] Specify the screen width for padding. .RS .PP This option overrides the setting of environment variable $\f[B]COLUMNS\f[]. .RE .TP .B \f[B]\-indent\f[] \f[I]NUM\f[] Specify the size of indent (number of spaces). (default: 4) .RS .RE .TP .B \f[B]\-theme\f[] \f[I]FILENAME\f[] Specify the theme to use. (default: default) .RS .RE .TP .B \f[B]\-no\-theme\f[] Do not use any other theme than default. .RS .RE .TP .B \f[B]\-no\-ansi\f[] Do not use ANSI escape codes. .RS .RE .SS Audio options .TP .B \f[B]\-p\f[], \f[B]\-play\f[] Listen to the translation. .RS .PP You must have at least one of the supported audio players (\f[B]mplayer\f[], \f[B]mpv\f[] or \f[B]mpg123\f[]) installed to stream from Google Text\-to\-Speech engine. Otherwise, a local speech synthesizer may be used instead (\f[B]say\f[] on Mac OS X, \f[B]espeak\f[] on Linux or other platforms). .RE .TP .B \f[B]\-speak\f[] Listen to the original text. .RS .RE .TP .B \f[B]\-player\f[] \f[I]PROGRAM\f[] Specify the audio player to use, and listen to the translation. .RS .PP Option \f[B]\-play\f[] will try to use \f[B]mplayer\f[], \f[B]mpv\f[] or \f[B]mpg123\f[] 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[]. .RE .TP .B \f[B]\-no\-play\f[] Do not listen to the translation. .RS .RE .SS Terminal paging and browsing options .TP .B \f[B]\-v\f[], \f[B]\-view\f[] View the translation in a terminal pager (\f[B]less\f[], \f[B]more\f[] or \f[B]most\f[]). .RS .RE .TP .B \f[B]\-pager\f[] \f[I]PROGRAM\f[] Specify the terminal pager to use, and view the translation. .RS .PP This option overrides the setting of environment variable $\f[B]PAGER\f[]. .RE .TP .B \f[B]\-no\-view\f[] Do not view the translation in a terminal pager. .RS .RE .TP .B \f[B]\-browser\f[] \f[I]PROGRAM\f[] Specify the web browser to use. .RS .PP This option overrides the setting of environment variable $\f[B]BROWSER\f[]. .RE .SS Networking options .TP .B \f[B]\-x\f[] \f[I]HOST:PORT\f[], \f[B]\-proxy\f[] \f[I]HOST:PORT\f[] Use HTTP proxy on given port. .RS .PP This option overrides the setting of environment variables $\f[B]HTTP_PROXY\f[] and $\f[B]http_proxy\f[]. .RE .TP .B \f[B]\-u\f[] \f[I]STRING\f[], \f[B]\-user\-agent\f[] \f[I]STRING\f[] Specify the User\-Agent to identify as. .RS .PP This option overrides the setting of environment variables $\f[B]USER_AGENT\f[]. .RE .SS Interactive shell options .TP .B \f[B]\-I\f[], \f[B]\-interactive\f[], \f[B]\-shell\f[] Start an interactive shell, invoking \f[B]rlwrap\f[] whenever possible (unless \f[B]\-no\-rlwrap\f[] is specified). .RS .RE .TP .B \f[B]\-E\f[], \f[B]\-emacs\f[] 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[] or \f[B]\-no\-rlwrap\f[]. .RE .TP .B \f[B]\-no\-rlwrap\f[] Do not invoke \f[B]rlwrap\f[] when starting an interactive shell. .RS .PP This option is useful when your terminal type is not supported by \f[B]rlwrap\f[] (e.g. \f[B]emacs\f[]). .RE .SS I/O options .TP .B \f[B]\-i\f[] \f[I]FILENAME\f[], \f[B]\-input\f[] \f[I]FILENAME\f[] 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[] \f[I]FILENAME\f[], \f[B]\-output\f[] \f[I]FILENAME\f[] 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[] \f[I]CODE\f[], \f[B]\-hl\f[] \f[I]CODE\f[], \f[B]\-lang\f[] \f[I]CODE\f[] 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]LANGUAGE\f[], $\f[B]LC_ALL\f[], $\f[B]LANG\f[] and $\f[B]HOME_LANG\f[]. .RE .TP .B \f[B]\-s\f[] \f[I]CODE\f[], \f[B]\-sl\f[] \f[I]CODE\f[], \f[B]\-source\f[] \f[I]CODE\f[] Specify the source language (the language of original text). .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[]. .RE .TP .B \f[B]\-t\f[] \f[I]CODES\f[], \f[B]\-tl\f[] \f[I]CODE\f[], \f[B]\-target\f[] \f[I]CODES\f[] Specify the target language(s) (the language(s) of translated text). When specifying two or more language codes, concatenate them by plus sign "+". .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]LANGUAGE\f[], $\f[B]LC_ALL\f[], $\f[B]LANG\f[] and $\f[B]TARGET_LANG\f[]. .RE .TP .B [\f[I]SOURCE\f[]]:[\f[I]TARGETS\f[]] 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[]:\f[I]TARGET\-CODE\f[] .IP \[bu] 2 \f[I]SOURCE\-CODE\f[]:\f[I]TARGET\-CODE1\f[]+\f[I]TARGET\-CODE2\f[]+... .IP \[bu] 2 \f[I]SOURCE\-CODE\f[]=\f[I]TARGET\-CODE\f[] .IP \[bu] 2 \f[I]SOURCE\-CODE\f[]=\f[I]TARGET\-CODE1\f[]+\f[I]TARGET\-CODE2\f[]+... .PP Delimiter ":" and "=" can be used interchangeably. .PP Either \f[I]SOURCE\f[] or \f[I]TARGETS\f[] may be omitted, but the delimiter character must be kept. .RE .SS Other options .TP .B \f[B]\-no\-init\f[] Do not load any initialization script. .RS .RE .TP .B \f[B]\-\-\f[] End\-of\-options. .RS .PP All arguments after this option are treated as \f[I]TEXT\f[] to be translated. .RE .SH EXIT STATUS .TP .B \f[B]0\f[] Successful translation. .RS .RE .TP .B \f[B]1\f[] Error. .RS .RE .SH ENVIRONMENT .TP .B \f[B]PAGER\f[] Equivalent to option setting \f[B]\-pager\f[]. .RS .RE .TP .B \f[B]BROWSER\f[] Equivalent to option setting \f[B]\-browser\f[]. .RS .RE .TP .B \f[B]PLAYER\f[] Equivalent to option setting \f[B]\-player\f[]. .RS .RE .TP .B \f[B]HTTP_PROXY\f[] Equivalent to option setting \f[B]\-proxy\f[]. .RS .RE .TP .B \f[B]USER_AGENT\f[] Equivalent to option setting \f[B]\-user\-agent\f[]. .RS .RE .TP .B \f[B]HOME_LANG\f[] Equivalent to option setting \f[B]\-lang\f[]. .RS .RE .TP .B \f[B]SOURCE_LANG\f[] Equivalent to option setting \f[B]\-source\f[]. .RS .RE .TP .B \f[B]TARGET_LANG\f[] Equivalent to option setting \f[B]\-target\f[]. .RS .RE .SH FILES .TP .B \f[I]/etc/translate\-shell\f[] Initialization script. (system\-wide) .RS .RE .TP .B \f[I]$HOME/.translate\-shell/init.trans\f[] Initialization script. (user\-specific) .RS .RE .TP .B \f[I]\&./.trans\f[] Initialization script. (current directory) .RS .RE .SH REPORTING BUGS .PP .SH AUTHORS Mort Yao . translate-shell-0.9.2.1/man/trans.1.md000066400000000000000000000207301263477447500173730ustar00rootroot00000000000000% TRANS(1) 0.9.2.1 % Mort Yao % 2015-12-18 # NAME trans - Google Translate served as a command-line tool # SYNOPSIS **trans** [*OPTIONS*] [*SOURCE*]:[*TARGETS*] [*TEXT*]... # DESCRIPTION This tool uses Google Translate to translate text into any language. Each command-line 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 "+". **-U**, **-upgrade** : Check for upgrade of this program. ## 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. ## 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 Mac OS X, **espeak** on Linux or other platforms). **-speak** : Listen to the original text. **-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. ## 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** : 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**. ## 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**. ## 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 $**LANGUAGE**, $**LC_ALL**, $**LANG** and $**HOME_LANG**. **-s** *CODE*, **-sl** *CODE*, **-source** *CODE* : Specify the source language (the language of original text). 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** *CODE*, **-target** *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 $**LANGUAGE**, $**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. ## 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) *./.trans* : Initialization script. (current directory) # REPORTING BUGS translate-shell-0.9.2.1/man/trans.1.template.md000066400000000000000000000207351263477447500212120ustar00rootroot00000000000000% TRANS(1) $Version$ % Mort Yao % $ReleaseDate$ # NAME trans - Google Translate served as a command-line tool # SYNOPSIS **trans** [*OPTIONS*] [*SOURCE*]:[*TARGETS*] [*TEXT*]... # DESCRIPTION This tool uses Google Translate to translate text into any language. Each command-line 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 "+". **-U**, **-upgrade** : Check for upgrade of this program. ## 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. ## 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 Mac OS X, **espeak** on Linux or other platforms). **-speak** : Listen to the original text. **-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. ## 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** : 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**. ## 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**. ## 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 $**LANGUAGE**, $**LC_ALL**, $**LANG** and $**HOME_LANG**. **-s** *CODE*, **-sl** *CODE*, **-source** *CODE* : Specify the source language (the language of original text). 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** *CODE*, **-target** *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 $**LANGUAGE**, $**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. ## 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) *./.trans* : Initialization script. (current directory) # REPORTING BUGS translate-shell-0.9.2.1/metainfo.awk000066400000000000000000000003521263477447500173140ustar00rootroot00000000000000BEGIN { Name = "Translate Shell" Description = "Google Translate to serve as a command-line tool" Version = "0.9.2.1" ReleaseDate = "2015-12-18" Command = "trans" EntryPoint = "translate.awk" } translate-shell-0.9.2.1/test.awk000066400000000000000000000043641263477447500165000ustar00rootroot00000000000000#!/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.2.1/test/000077500000000000000000000000001263477447500157655ustar00rootroot00000000000000translate-shell-0.9.2.1/test/Test.awk000066400000000000000000000001211263477447500174020ustar00rootroot00000000000000@include "test/TestCommons" @include "test/TestUtils" @include "test/TestParser" translate-shell-0.9.2.1/test/TestCommons.awk000066400000000000000000000135011263477447500207440ustar00rootroot00000000000000BEGIN { 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("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("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("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") } # 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.2.1/test/TestParser.awk000066400000000000000000000037521263477447500205740ustar00rootroot00000000000000@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("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.2.1/test/TestUtils.awk000066400000000000000000000016021263477447500204300ustar00rootroot00000000000000@include "include/Utils" BEGIN { START_TEST("Utils.awk") T("GawkVersion", 1) { initGawk() assertTrue(GawkVersion ~ "^4.") } 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")) } T("dump()", 3) { delete group assertEqual(dump("a", group), 1) delete group assertEqual(dump("Århus", group), 6) delete group assertEqual(dump("안녕하세요 세계", group), 22) } END_TEST() } translate-shell-0.9.2.1/translate000077500000000000000000000000711263477447500167270ustar00rootroot00000000000000#!/bin/sh cd `dirname $0` gawk -f translate.awk -- "$@" translate-shell-0.9.2.1/translate.awk000077500000000000000000000005101263477447500175060ustar00rootroot00000000000000#!/usr/bin/gawk -f @include "metainfo" @include "include/Commons" @include "include/Utils" @include "include/GenTK" @include "include/Languages" @include "include/Help" @include "include/Parser" @include "include/Theme" @include "include/Translate" @include "include/Script" @include "include/REPL" @include "include/Main"