Across the world, natural or regional languages differ in many ways, (e.g. in pluralization rules). Therefore, Internationalization became a complex problem and it is hard to provide tools for solving all problems at once. Sven Fuchs focused to provide an extensible framework and easy to use gem that is Ruby I18n (internationalization) gem.
The Ruby I18n gem is mainly designed for translating your application to a single custom language other than English or for providing multi-language support for your ruby on rails application. The pivotal point of the new I18n api in Rails is the I18n module which is provided as a gem and shipped with Rails (starting from Rails 2.2) in ActiveSupport’s vendor directory.
Therefore, during my presentation I will try to go over some of the advanced optional features and architecture of I18n gem. Besides, I will also try to cover begin with I18n gem, setup, benefits, the work flow, what's in? and what's not? Etc.
20. en:
activerecord:
models:
user: foo
admin: bar
attributes:
user:
login: “Handle” # => will translate User
attribute “login” as “Handle”
21. en:
activerecord:
errors:
messages:
blank: “can not has nottin”
# => u = User.new
# => #<User id:nil, etc>
# => u.valid?
# => false
# => u.errors.on(:name)
# => “can not has nottin”
22.
23. en:
activerecord:
errors:
messages:
already_registered: “u already is
{{model}}”
# => u.errors.on(:email)
# => “u already is foo”
24. en:
activerecord:
errors:
template:
header:
one: “1 error prohibted this {{model}} from being
saved”
other: “{{count}} errors prohibted this {{model}} from
being saved”
body: “There were problems with the following fields:”
25. i18n
i18n i18n
backend
backend core_ext helpers locales
exceptions
gettext
gettext
helpers
tag fallbacks locale
version
49. case match
when '%a' then I18n.t(:"date.abbr_day_names”, :locale =>
locale, :format => format)[object.wday]
when '%A' then I18n.t(:"date.day_names”, :locale =>
locale, :format => format)[object.wday]
when '%b' then I18n.t(:"date.abbr_month_names", :locale =>
locale, :format => format)[object.mon]
50. when '%B' then I18n.t(:"date.month_names", :locale =>
locale, :format => format)[object.mon]
when '%p' then I18n.t(:"time.#{object.hour <
12 ? :am : :pm}", :locale => locale, :format => format) if
object.respond_to? :hour
end
51.
52. MissingTranslationData # no translation was found for the
requested key
InvalidLocale # the locale set to I18n.locale is invalid (e.g. nil)