Skip to content

Internationalization

Álvaro Casado Coscollá edited this page Dec 22, 2018 · 4 revisions

If you're interested in helping us translate our app to your language or a language you know, please check if there's any open issue for it. If not, be free to add one yourself! 😉

IMPORTANT NOTE: Currently, the most updated locale strings are located in the translations branch and you should open up a Pull Request for that branch. If you don't know how to do that, you can check this page on our wiki or contact us.


How the internationalization works in ruby on rails?

RoR use I18n, is easy to configure, we just add the string in the .yml of the language.

Where are the .yml of each language?

The .yml of each language are in config/locales/, there can be added all the .yml as [language_code].yml you can see here the code of all the languages.

How we organice the values of the .yml

We encapsulate the values by HTML elements such as cats, users, sufferings etc. in the second level of the hierarchy.

For example:

es:
  [...]
  cats:
    birthDate: 'Nacido aproximadamente el'
    gender: 'Género:'
    sterilized: 'Esterilizado:'
    abandonedDate: 'Abandonado aproximadamente el'
    document: 'Documento:'

How add the values to the HTML code.

We just need to add a line like this in our HTML file <%= I18n.t 'cats.sterilized'%>, this line will show Esterilizado:

Sources

Our es.yml: https://github.com/infusionvlc/ConexionFelina/blob/master/config/locales/es.yml

Example: https://github.com/infusionvlc/ConexionFelina/blob/master/app/views/cats/index.html.erb

Language codes: https://es.wikipedia.org/wiki/ISO_639-1

Source: http://guides.rubyonrails.org/i18n.html