You may skip the next section and head over to the Internationalize your application section, if you want to try things out by manually placing the locale in the URL and reloading the page. (This is, for example, Google’s approach.) So will load the Portuguese localization, whereas would load the German localization, and so on. This requires you to pass the locale as a URL query parameter as in. You can pick whatever directory and translation file naming scheme makes sense for you. The translations load path ( I18n.load_path) is just a Ruby Array of paths to your translation files that will be loaded automatically and available in your application. Various Rails I18n plugins such as Globalize2 may help you implement it.
Nothing stops you from separating regional and other settings in this way: you just have to provide full “English – United Kingdom” locale in a :en-GB dictionary. For instance, in the :en-US locale you would have $ as a currency symbol, while in :en-GB, you would have £. However, there are also regional differences within different language groups that may be important. Many international applications use only the “language” element of a locale such as :cs, :th or :es (for Czech, Thai and Spanish). The i18n library takes a pragmatic approach to locale keys (after some discussion), including only the locale (“language”) part, like :en, :pl, not the region part, like :en-US or :en-GB, which are traditionally used for separating “languages” and “regional setting” or “dialects”.
A default backend (which is intentionally named Simple backend) that implements these methodsĪs a user you should always only access the public methods on the I18n module, but it is useful to know about the capabilities of the backend.The public API of the i18n framework - a Ruby module with public methods that define how the library works.Thus, the Ruby I18n gem is split into two parts: 1.1 The Overall Architecture of the Library Active Record validation messages, time and date formats - has been internationalized, so localization of a Rails application means “over-riding” these defaults. making it easy to customize and extend everything for other languagesĪs part of this solution, every static string in the Rails framework - e.g.providing support for English and similar languages out of the box.For that reason the Rails I18n API focuses on: in pluralization rules) that it is hard to provide tools for solving all problems at once. Natural languages differ in so many ways (e.g. Internationalization is a complex problem. See the Rails I18n Wiki for more information. You may, however, use any of various plugins and extensions available, which add additional functionality or features. The Ruby I18n framework provides you with all necessary means for internationalization/localization of your Rails application. Overview of Other Built-In Methods that Provide I18n Support.Setting the Locale from the Client Supplied Information.Setting the Locale from the Domain Name.Optional: Custom I18n Configuration Setup.Setup the Rails Application for Internationalization.The Overall Architecture of the Library.
This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start. Store the resulting dictionaries somewhere.flash messages, static text in your views, etc. Abstract strings in your application into keyed dictionaries - e.g.date and time formats, month names, Active Record model names, etc. Replace or supplement Rails’ default locale - e.g.In the process of localizing your application you’ll probably want to do the following three things: Tell Rails how to set, preserve and switch locales.Tell Rails where to find locale dictionaries.So, in the process of internationalizing your Rails application you have to: The process of “localization” means to provide translations and localized formats for these bits. The process of “internationalization” usually means to abstract all strings and other locale specific bits (such as date or currency formats) out of your application. The Ruby I18n (shorthand for internationalization) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for translating your application to a single custom language other than English or for providing multi-language support in your application.