Class: Air18n::PrimAndProper
- Inherits:
-
Object
- Object
- Air18n::PrimAndProper
- Defined in:
- lib/air18n/prim_and_proper.rb
Overview
Class for converting between text between similar locales. Right now only conversion between American English -> British, Canadian, Australian, New Zealand variations is provided.
Instance Method Summary collapse
-
#guess(text, orig_locale, other_locale) ⇒ Object
Given a text in orig_locale, tries to guess a translation into other_locale.
-
#initialize ⇒ PrimAndProper
constructor
A new instance of PrimAndProper.
Constructor Details
#initialize ⇒ PrimAndProper
Returns a new instance of PrimAndProper.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/air18n/prim_and_proper.rb', line 10 def initialize @converters = { :en => { :"en-AU" => AmericanToAustralian.new, :"en-CA" => AmericanToCanadian.new, :"en-GB" => AmericanToBritish.new, :"en-NZ" => AmericanToKiwi.new, :"en-SG" => AmericanToSinglish.new, }, :de => { :"de-CH" => GermanToSwissGerman.new } } end |
Instance Method Details
#guess(text, orig_locale, other_locale) ⇒ Object
Given a text in orig_locale, tries to guess a translation into other_locale.
Currently only :en -> :en-GB is supported.
Returns nil if we don’t know how to guess a translation for the specified language pair.
28 29 30 31 32 |
# File 'lib/air18n/prim_and_proper.rb', line 28 def guess(text, orig_locale, other_locale) if @converters.include?(orig_locale) && @converters[orig_locale].include?(other_locale) @converters[orig_locale][other_locale].convert(text) end end |