Class: RealTranslator
- Inherits:
-
Translator
- Object
- Translator
- RealTranslator
- Defined in:
- lib/translator.rb
Constant Summary
Constants inherited from Translator
Instance Attribute Summary collapse
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#locale ⇒ Object
Returns the value of attribute locale.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(locale_code) ⇒ RealTranslator
constructor
A new instance of RealTranslator.
- #localize(text) ⇒ Object
Methods inherited from Translator
Constructor Details
#initialize(locale_code) ⇒ RealTranslator
Returns a new instance of RealTranslator.
38 39 40 41 42 |
# File 'lib/translator.rb', line 38 def initialize(locale_code) md = locale_code.match(/([^-]+)(-(.*))?/) self.lang = md[1] self.locale = md[3] end |
Instance Attribute Details
#lang ⇒ Object
Returns the value of attribute lang.
36 37 38 |
# File 'lib/translator.rb', line 36 def lang @lang end |
#locale ⇒ Object
Returns the value of attribute locale.
36 37 38 |
# File 'lib/translator.rb', line 36 def locale @locale end |
Instance Method Details
#==(other) ⇒ Object
52 53 54 55 56 |
# File 'lib/translator.rb', line 52 def ==(other) return other.kind_of?(RealLocale) && lang == other.lang && locale == other.locale end |
#localize(text) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/translator.rb', line 44 def localize(text) md = text.match(/^--- #{lang}-#{locale} ----*\s*$/) md = text.match(/^--- #{lang} ----*\s*$/) if md.nil? md = text.match(/^--- #{lang}-\S+ ----*\s*$/) if md.nil? return default_text_from(text) if md.nil? return default_text_from(md.post_match) end |