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
9
votes
6 answers

Rails Devise I18n Flash Messages with Twitter Bootstrap

Hello I am new to ruby on rails and I am struggling to understand I18n's flash messages. I am using devise, rails 4, and twitter bootstrap.I understand that devise only uses flash[:notice] and flash[:alert]. I am able to get flash messages working…
Daniel
  • 2,650
  • 2
  • 21
  • 42
9
votes
3 answers

How do I recursively flatten a YAML file into a JSON object where keys are dot separated strings?

For example if I have YAML file with en: questions: new: 'New Question' other: recent: 'Recent' old: 'Old' This would end up as a json object like { 'questions.new': 'New Question', 'questions.other.recent': 'Recent', …
koonse
  • 1,468
  • 1
  • 14
  • 14
9
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
  • 26,414
  • 39
  • 123
  • 214
8
votes
1 answer

i18n for select boxes

I have a model named Role. And i am using the helper below in a form. Is there a way to change the value of name attribute to another language? <%= f.collection_select :role_id, Role.all, :id, name, {} -%> locales/de.yml de: role: admin:…
rookieruby
  • 113
  • 1
  • 3
8
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
  • 30,364
  • 11
  • 66
  • 91
8
votes
2 answers

I18n translation with i18n-active_record: same form for same key

I am working on an app in Rails 4 using i18n-active_record 0.1.0 to keep my translations in the database rather than in a .yml-file. It works fine. One thing that I am struggling with, however, is that each translation record is one record per…
Christoffer
  • 2,123
  • 3
  • 23
  • 50
8
votes
3 answers

Is it possible to have hyphens in a yaml key for use in my I18n en.yml file?

For example : en: foobar-does-not-work: 'This is my value' Then if I do : t(foobar-does-not-work) # => returns nil This will not parse in Ruby's yml. Is there some way to make it work though? My keys are based on URL's which have dashes ( - ) in…
Trip
  • 25,831
  • 41
  • 146
  • 260
8
votes
2 answers

How can I define a Map with arbitrary keys in a Swagger model

How can I define a map with arbitrary keys in a Swagger model Say I have the following internationalised model (in Ruby-style pseudocode, assuming use of something like Globalize) class Thingy translates :name attribute :code end and my API…
Dave Sag
  • 12,289
  • 8
  • 77
  • 118
8
votes
3 answers

How do I translate placeholder text in Rails 4?

I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: = f.text_field :first_name This helper uses the locale file: en: active_model: …
Jumbalaya Wanton
  • 1,571
  • 1
  • 21
  • 43
8
votes
3 answers

Rails does not permit changing locale

I'm trying to change the locale that my rails (4.1.4) application is using, but every time I try to change it in the console using commands such as I18n.locale = :es I18n.default_locale = :de an I18n::InvalidLocale error is brought up. This is the…
8
votes
1 answer

Rails 4 parse a date in a different language

I have a text_field :birthday_line in my user form, that I need to parse into the user's birthday attribute. So I'm doing something like this in my User class. attr_accessor :birthday_line before_save :set_birthday def set_birthday self.birthday…
Almaron
  • 3,947
  • 4
  • 22
  • 45
7
votes
1 answer

Rails 5: Can you pluralize two words in a string with two different counts?

I'm building a view for a store that lists a summary of a product's reviews. I'm grouping the reviews by score, and I want a string at the top of each group of the form "10 reviews of 5 stars". I know that if I just wanted to pluralize "review", I…
7
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…
Jeff
  • 606
  • 7
  • 21
7
votes
2 answers

Locale not switching in Rails 4

My Rails App is on rails 4.0.2 and I have a problem switching translations with the locale variable and the params[:locale] from the url scheme following the official rails guide. I have a single page website at my site. My routes for…
nuxxxx
  • 223
  • 2
  • 13
7
votes
2 answers

Override rails translations helper

I want I18n.translate() or I18n.t() to use a specific locale, but not I18n.locale. I don't want to use I18n.t(:my_key, locale: :my_locale) every time, so it would be great if I could override the function itself. I tried to put it in a new helper: #…
Railsana
  • 1,560
  • 2
  • 16
  • 29
1 2
3
49 50