Simple backend • Allows using the ICU Message Format in Rails • Ecosystem compatibility as a fi rst-class goal: • Use your existing YAML translations via Chain backend • Use your existing date and number formats • Use translations and other data from gems such as rails-i18n
C/C++ library • Unicode — non-pro fi t org which maintains the emojis Unicode Standard • Message Format — ICU standard syntax for formatting user-visible text
co m .ib m .icu. text. M essageFor mat FormatJS intl- messageformat widely used in React Babel Support vai babel. m essages PyICU Native bindings ICU4N ICU APIs for .NET Cross-platform support
you to <%= case @ user.pronouns w hen Pronouns::HE_H I M % > his < % w hen Pronouns::SHE_HER % > her < % w hen Pronouns:: T HEY _T H E M % > their < % end % > party
M I18n.t('invited_his', name: user.name) w hen Pronouns::SHE_HER I18n.t('invited_her', name: user.name) w hen Pronouns:: T HEY _ T H EM I18n.t('invited_their', name: user.name) end end
pronouns • Locales that distinguish fewer pronouns will have duplicates for some • A locale that needs a new pronoun forces all the others to add it too • The helper function duplicates the pronouns’ semantics • 3 when branches re fl ect the 3 pronouns • A new pronoun requires a code change
has invited you to his party} she_her {{name} has invited you to her party} other {{name} has invited you to their party}} YAML heredoc like case case branches “other” as fallback
One message contains all variants • Translators can change the {select} as needed • e.g. collapse everything to only other for a language without gendered pronouns
% {count} m hír)" tw o: "Fo-io m l án ( % {count} m hír)" fe w : "Fo-io m l án ( % {count} m hír)" m any: "Fo-io m l án ( % {count} mí r)" other: "Fo-io m l án ( % {count} m í reanna)"
% {count} m hír)" tw o: "Fo-io m l án ( % {count} m hír)" fe w : "Fo-io m l án ( % {count} m hír)" m any: "Fo-io m l án ( % {count} mí r)" other: "Fo-io m l án ( % {count} m í reanna)"
into the YAML structure • This means di ff erent languages may have di ff erent YAML structures • “Missing” or “unused” keys depend on the locale’s plural categories • Translation tools (i18n_tasks) also have to change the YAML structure in order to add/remove plural categories
l án ({#} m hír)} t w o {Fo-io m l án ({#} m hír)} fe w {Fo-io m l án ({#} m hír)} m any {Fo-io m l án ({#} m í r)} other {Fo-io m l án ({#} m í reanna)}}
via {plural} formatter • 1-to-1 correspondence of YAML keys between locales is restored • Missing and unused key detection is much easier • Machine translation tools can more easily add/remove plural categories
app can work with multiple languages • That means fi nding places in your code that implicitly assume a particular language is being used • This is generally called “hard-coding” and usually is thought of in terms of text embedded in views
text in your ERB! • Hard-coding is anything that bakes linguistic assumptions into your app: • Hard-coded formats: l(date, format: : m ediu m ) • Hard-coded variation: branching calls to I18n.t • Hard-coded fi le structure: plural keys in YAML
no matter the locale. What changes is the messages. • Default I18n still forces your code to account for some linguistic variation • Message Format’s richer syntax allows you to move variation into the messages themselves, keeping it out of your code