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
778 questions
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
  • 13,764
  • 18
  • 74
  • 133
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…
13
votes
2 answers

Rails i18n : "fr" is not a valid locale

I would like to translate my rails application in two languages, french and english but got some problem. I've got the following error: "fr" is not a valid locale In my config/application.rb: I18n.enforce_available_locales =…
12
votes
3 answers

Translate model nested attribute validation message

I have a nested attribute on which I perform presence validation. I am trying without success to provide translations for the attribute name that is returned in the full error message text. The model is called Identity and contains an attribute…
starfry
  • 9,273
  • 7
  • 66
  • 96
11
votes
2 answers

Clean way to avoid I18n::InvalidLocale?

I get a I18n::InvalidLocale: "zh-CN" is not a valid locale exception that I want to avoid. To solve it, I have heard of two hacks: # meh config.i18n.enforce_available_locales = false # Ever heard of convention over…
Gwendal Roué
  • 3,949
  • 15
  • 34
11
votes
4 answers

Rails i18n how to get all values for a certain key?

In Rails i18n, how to get all values for a certain key using the following: translations = I18n.backend.send(:translations) get all the keys I need to be able to get a certain section for example only return everything under "home" en: home: …
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
10
votes
1 answer

Using the gem globalize, how to switch locales for input only and not the whole page?

Context: For a Ruby on Rails app for bike rentals, I am using the gem globalize to deal with input :description in different languages. Curent state: The globalize implementation worked, depending on my locale I am able to store description in a…
techquestion
  • 489
  • 5
  • 20
10
votes
1 answer

Specs of my Rails app fail randomly because of wrong default locale

From time to time, some specs of my Rails app seem to fail randomly because suddenly English is not the default language anymore, but German: expected: "Project test customer - Project test name (Audit, Access for all, 2015-06-15).pdf" …
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
10
votes
2 answers

I18n.t Translation Missing Default Value Nil

So I know how return a default value if I get "translation missing:" when reading a yaml file. some = I18n.t("something.something_else", default: "value") But how do I do that in the Ruby way if I want the default value to be nil? I know I can…
LemonPie
  • 806
  • 1
  • 11
  • 23
10
votes
1 answer

Rails I18n validation deprecation warning, after setting enforce_available_locales = true

You placed something like this in config/application.rb I18n.enforce_available_locales = true config.i18n.load_path += Dir[Rails.root.join('config/locales/', '*.{rb,yml}').to_s] config.i18n.available_locales =…
givanse
  • 14,503
  • 8
  • 51
  • 75
10
votes
3 answers

Can't I just simply get the day name I18n-ed?

I'm pretty new with rails also with ruby. I just want to get the I18n.l of a day name or a month name, without a whole date or time. Because I don't have it. For example, I simply want to internationalize for example = l Date::DAYNAMES[0] or = l…
raulricardo21
  • 2,499
  • 4
  • 20
  • 27
10
votes
1 answer

Changing devise_invitable mailer subject

on default, the subject for invitation mail is mailer: invitation_instructions: subject: 'Invitation instructions' I'd like to change it to subject: '%{invited_by} has invited you!' but this requires to have invited_by variable…
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
10
votes
1 answer

Is lazy lookup in Rails I18n a bad practice?

Using shorter i18n keys (e.g. t '.submit_button') in Rails views makes them easier to type, but is it actually good? When later you decide to refactor your views and partials you have to remember to update the respective localization entries.…
RocketR
  • 3,626
  • 2
  • 25
  • 38
9
votes
2 answers

Rails 5 I18n default_locale and fallback locale

How do I set a fallback locale in Rails 5.2? Right now it prints ''(blank) for attribute names if not found in locale. I would like it to fallback to :en when that happens. Rails 5 specific? # config/application.rb config.load_defaults…
oma
  • 38,642
  • 11
  • 71
  • 99
9
votes
6 answers

Rails commands in home directory result in "i18n gem is not available" error

I was in my Ubuntu home directory, trying to create a new rails app with rails new, but I got this error: The i18n gem is not available. Please add it to your Gemfile and run bundle install Any rails command I run gives that error. I'm really…
Joe Morano
  • 1,715
  • 10
  • 50
  • 114
1
2
3
51 52