Module: Typus::I18n
- Defined in:
- lib/typus/i18n.rb
Class Method Summary collapse
- .available_locales ⇒ Object
- .default_locale ⇒ Object
-
.t(key, options = {}) ⇒ Object
Instead of having to translate strings and defining a default value to avoid “missing translation” messages:.
Class Method Details
.available_locales ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/typus/i18n.rb', line 28 def available_locales { "Brazilian Portuguese" => "pt-BR", "Català" => "ca", "German" => "de", "Greek" => "el", "Italiano" => "it", "English" => "en", "Español" => "es", "Français" => "fr", "Magyar" => "hu", "Portuguese" => "pt-PT", "Russian" => "ru", "中文" => "zh-CN" } end |
.default_locale ⇒ Object
24 25 26 |
# File 'lib/typus/i18n.rb', line 24 def default_locale :en end |
.t(key, options = {}) ⇒ Object
Instead of having to translate strings and defining a default value to avoid “missing translation” messages:
I18n.t("Hello World!", :default => 'Hello World!')
We define a Typus translation method which will set up a default value for you: (Interpolation still works)
Typus::I18n.t("Hello World!")
Typus::I18n.t("Hello %{world}!", :world => @world)
19 20 21 22 |
# File 'lib/typus/i18n.rb', line 19 def t(key, = {}) [:default] ||= key ::I18n.t(key, ) end |