Module: Translate::Language
- Defined in:
- lib/language.rb
Constant Summary collapse
- EN =
Language module contains the different languages available and defined the directions which can be used.
"English"
- FR =
"French"
- IT =
"Italian"
- PL =
"Polish"
- RO =
"Romanian"
- CZ =
"Czech"
- GR =
"Greek"
- TR =
"Turkish"
- ZH =
"Chinese"
- JA =
"Japanese"
- KO =
"Korean"
- DIRECTIONS =
{ EN => [ "CZ", "FR", "GR", "IT", "JA", "KO", "PL", "RO", "TR", "ZH" ], FR => [ "EN" ], IT => [ "EN" ] }
Class Method Summary collapse
-
.available_translation?(*args) ⇒ Boolean
Check if the original and final languages are available.
-
.available_translations ⇒ Object
Show the available translations on the command line.
-
.klass_fren ⇒ Object
available_translation?.
- .klass_iten ⇒ Object
Class Method Details
.available_translation?(*args) ⇒ Boolean
Check if the original and final languages are available.
38 39 40 41 42 |
# File 'lib/language.rb', line 38 def self.available_translation?(*args) from, to = args.map { |a| a.to_s.strip.upcase } return false if from.blank? or to.blank? self.const_defined?(from) and self.const_defined?(to) and DIRECTIONS[self.const_get(from)].include?(to) end |
.available_translations ⇒ Object
Show the available translations on the command line. You can invoke this method by using :
$ translate -l
It will print the languageās abbreviation and real name (in english).
27 28 29 30 31 32 33 34 35 |
# File 'lib/language.rb', line 27 def self.available_translations puts "Available translations :\n" (Language.constants - [DIRECTIONS]).sort.each do |l| constant = const_get(l) puts "\t- #{constant} (#{l.downcase}) to #{DIRECTIONS[constant].map { |c| "#{const_get(c)} (#{c.downcase})" }.join(', ')}" if Language::DIRECTIONS.include?(constant) end end |
.klass_fren ⇒ Object
available_translation?
44 |
# File 'lib/language.rb', line 44 def self.klass_fren; end |
.klass_iten ⇒ Object
45 |
# File 'lib/language.rb', line 45 def self.klass_iten; end |