Module: ToLang
- Defined in:
- lib/to_lang.rb,
lib/to_lang/codemap.rb,
lib/to_lang/version.rb,
lib/to_lang/connector.rb,
lib/to_lang/translatable.rb
Overview
ToLang is a Ruby library that adds language translation methods to strings and arrays, backed by the Google Translate API.
Defined Under Namespace
Modules: Translatable Classes: Connector
Constant Summary collapse
- CODEMAP =
A list of all the languages ToLang supports and the language code each maps to. Strings and arrays will gain
to_language
,to_language_from_language
, andfrom_language_to_language
methods for anylanguage
in this list. { 'afrikaans' => 'af', 'albanian' => 'sq', 'arabic' => 'ar', 'belarusian' => 'be', 'bulgarian' => 'bg', 'catalan' => 'ca', 'simplified_chinese' => 'zh-CN', 'traditional_chinese' => 'zh-TW', 'croatian' => 'hr', 'czech' => 'cs', 'danish' => 'da', 'dutch' => 'nl', 'english' => 'en', 'estonian' => 'et', 'filipino' => 'tl', 'finnish' => 'fi', 'french' => 'fr', 'galician' => 'gl', 'german' => 'de', 'greek' => 'el', 'haitian_creole' => 'ht', 'hebrew' => 'iw', 'hindi' => 'hi', 'hungarian' => 'hu', 'icelandic' => 'is', 'indonesian' => 'id', 'irish' => 'ga', 'italian' => 'it', 'japanese' => 'ja', 'latvian' => 'lv', 'lithuanian' => 'lt', 'macedonian' => 'mk', 'malay' => 'ms', 'maltese' => 'mt', 'norwegian' => 'no', 'persian' => 'fa', 'polish' => 'pl', 'portuguese' => 'pt', 'romanian' => 'ro', 'russian' => 'ru', 'serbian' => 'sr', 'slovak' => 'sk', 'slovenian' => 'sl', 'spanish' => 'es', 'swahili' => 'sw', 'swedish' => 'sv', 'thai' => 'th', 'turkish' => 'tr', 'ukrainian' => 'uk', 'vietnamese' => 'vi', 'welsh' => 'cy', 'yiddish' => 'yi', }
- VERSION =
The current version of the Ruby gem.
"0.3.0"
Class Attribute Summary collapse
-
.connector ⇒ ToLang::Constructor, NilClass
readonly
A Connector object to use for translation requests.
Class Method Summary collapse
-
.start(key) ⇒ Class, Boolean
Initializes ToLang, after which the translation methods will be available from strings and arrays.
Class Attribute Details
.connector ⇒ ToLang::Constructor, NilClass (readonly)
A Connector object to use for translation requests.
17 18 19 |
# File 'lib/to_lang.rb', line 17 def connector @connector end |
Class Method Details
.start(key) ⇒ Class, Boolean
Initializes ToLang, after which the translation methods will be available from strings and arrays.
25 26 27 28 29 30 |
# File 'lib/to_lang.rb', line 25 def start(key) return false if defined?(@connector) && !@connector.nil? @connector = Connector.new key String.send :include, Translatable Array.send :include, Translatable end |