Questions tagged [rails-i18n]

Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff.

About

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.

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 process of "localization" means to provide translations and localized formats for these bits.

Links:

  1. Homepage
  2. Guide
748 questions
387
votes
5 answers

Rails I18n validation deprecation warning

I just updated to rails 4.0.2 and I'm getting this warning: [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to…
Mauricio Moraes
  • 6,889
  • 5
  • 34
  • 54
89
votes
7 answers

i18n Pluralization

I want to be able to translate pluralized strings in i18n in rails. A string can be : You have 2 kids or You have 1 kid I know that I can use pluralize helper method, but I want to embed this in i18n translations so that I don't have to mess up…
Spyros
  • 41,000
  • 23
  • 80
  • 121
74
votes
9 answers

Rails I18n, check if translation exists?

Working on a rails 3 app where I want to check if a translation exists before outputting it, and if it doesn't exist fall back to some static text. I could do something like: if I18n.t("some_translation.key").to_s.index("translation missing") But I…
agmcleod
  • 12,451
  • 11
  • 52
  • 92
64
votes
3 answers

Rails: How to make Date strftime aware of the default locale?

I have my default locale set in the environment.rb as de (German). I also see all the error messages in German, so the locale is picked up by the server. But when I try to print date with strftime like following: some_date.strftime('%B, %y') It…
rangalo
  • 4,910
  • 8
  • 42
  • 65
39
votes
2 answers

Access translation file (i18n) from inside rails model

What I have in my model is: def body_color_enum [ ['Aqua', '#009c9c'], ['Grey', '#6d6e71'], ['Yellow', '#ffe600'], ['White', 'white'] ] end I want these values to come from the translation file 'en.yml' en: group: hero: …
Jake McAllister
  • 1,088
  • 3
  • 10
  • 24
34
votes
6 answers

How to retrieve all translations from yml files in Rails I18n

I'm guessing that rails stores all the parsed translations yml files in a sort of array/hash. Is there a way to access this? For example, if I've a file: en: test_string: "testing this" warning: "This is just an example Could I do something…
Tiago
  • 2,808
  • 4
  • 31
  • 41
33
votes
6 answers

How to use the I18n fallback features in Rails 3

I am getting an "translation missing" error message from Rails 3: activerecord: notices: messages: success: create: "Something was created" models: user: success: create: "Thanks for…
33
votes
3 answers

Use another I18n key in an I18n interpolation

This might be I18n-ception but lets say I have an en.yml file as below en: my_var: Foo my_message: "This is a message where I'd like to interpolate I18n's %{my_var}" Is there a way to indicate to I18n that %{my_var} should be the my_var key in…
Aaron
  • 10,807
  • 7
  • 58
  • 102
19
votes
2 answers

Rails 3 force localization language for specific text

Any way to force the translation to a specific language only for some text. Something like: t("my.text",:fr) The reason is that i want the user to be able to change the language of their content but not the site interface. Thanks!
montrealmike
  • 10,771
  • 6
  • 56
  • 80
18
votes
3 answers

undefined method `t' for Admin::FaqsController:Class

in my project i have controller in namespace admin and I'm using breadcrumbs_on_rails to build breadcrums. My controller looks like: module Admin class FaqsController < Admin::ApplicationController include FaqsHelper …
16
votes
6 answers

Check for hardcoded text in Rails views - I18n

some of our devs (me included) don't always take it serious to put text in a localization file, result is a lot of hardcoded texts scattered around a lot of views. I'm wondering if any of you has an idea to automate the search for hardcoded texts…
supersize
  • 10,844
  • 14
  • 56
  • 108
16
votes
3 answers

Day name with I18n

Without translation, this would get me today's day name: Date.today.strftime("%A") How would I localize it? I.e. "Mardi" if I18n.locale is set to fr.
Fellow Stranger
  • 25,431
  • 22
  • 134
  • 188
16
votes
4 answers

How to use I18n from controller in Rails

I have a PetsController in which a flash message is setted. Something like this: class PetsController ... def treat_dog #do somthing flash[:success] = 'Your dog is being treated.' end ... end this controller belongs to Admin, so…
15
votes
2 answers

How to make i18n aware of "genders" in gender-sensitive languages like e.g. French

I have to translate a website in French. Now, French, as many other languages, has genders and inflection. Questions are: How to create yaml files containing messages with variable parts being either male or female... How to modify the i18n…
Danny
  • 5,757
  • 4
  • 30
  • 51
14
votes
7 answers

Rails: Remove missing translation errors

I am using internationalization for english (en) and french (fr), I have used en.yml for limited use and most of the translations I am writing in fr.yml. With locale as fr everything works good, but with en it shows me error as missing translation…
1
2 3
49 50