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
0
votes
1 answer

human_attribute_name defaults to the wrong locale

I am developing a localised application with Rails 3.2.8, deployed on Heroku. I created a localisation it.yml file with the following structure: it: activerecord: attributes: company: name: "Nome" address: …
gianpi
  • 3,110
  • 1
  • 17
  • 13
0
votes
1 answer

Rails: i18n, variable gets printed if translation is not there

I am facing a weird problem. In my rails 3 app I am supporting internationalization with english and french. Here in my template I wrote something like this <%= t "Hi %{person}!", :person => "Simpson" %> When I set locale as french everything works…
0
votes
2 answers

Rails locale namespace differences in case

I use the Rails I18n feature. My locales are namespaces with for example: en-ZA. When I run my model specs, it picks up the activerecord locales. When I run my controller specs, it picks up on my activerecord locales. When I run my acceptance (full…
Joerg
  • 3,553
  • 4
  • 32
  • 41
-1
votes
2 answers

Rails I18n switch key based on user permissions

I have a namespace in my routes: namespace :fruit do resources :apple, only [:create, :destroy] resources :banana, only [:show] end and also the same key in my translation file: en: fruit: apple: name: apple banana: name:…
Vishal Rao
  • 872
  • 1
  • 7
  • 18
-1
votes
1 answer

Translation of active record models

I set the default_locale of my rails app to french: config.i18n.default_locale = :fr Then I installed devise gem. And applied devise to the model Membre. new.html.erb:

<%= t('login') %>

<%= form_for(resource, as: resource_name, url:…
thiebo
  • 1,339
  • 1
  • 17
  • 37
-1
votes
2 answers

Ruby on Rails I18n mailer subject translations in custom directory

I am using I18n gem for the translation. I have all my translation in a single file(en.yml, es.yml.. ). But for emails, instead of translating each sentence in the email body I have a separate email view for each locale. So my email view files are…
sonm10
  • 53
  • 2
  • 6
-1
votes
1 answer

What is the best practice to use ENV vars with translations i18n from yml

I have a very long text in yml, it's supossed to have a link somewhere in the middle. I wish to be able to change the link (from my env file), but doesn't seem right to parse ENV['link'] in the yml. Thoughts?
-1
votes
1 answer

Why my translation key is ignored

I'm using rails 5.0.2 with spree 3.2.0.rc3. I have this keys in my translation file: ru: spree: shipment_states: canceled: 'отменен' canceled_test: 'test' And in development I catch I18n::MissingTranslationData exception with…
vasily.sib
  • 3,871
  • 2
  • 23
  • 26
-1
votes
2 answers

Translate German country names to French

I got a YAML file with the following structure containing country names in German: countries: country_1: "Schweiz" country_2: "Deutschland" country_3: "Italien" country_4: "Frankreich" country_6: "Afghanistan" I…
Bergrebell
  • 4,263
  • 4
  • 40
  • 53
-1
votes
1 answer

How to access I18n translations for nil

How do I access translation for nil value? I tried with this locale(yml file): pt-BR: boolean: "true": "sim" "false": "não" "": "não" nil: "não" "nil": "não" But it does't work. {:true=>"sim", :false=>"não", :""=>"não",…
Luiz Carvalho
  • 1,549
  • 1
  • 23
  • 46
-1
votes
1 answer

Setting the locale at runtime just once in Rails

Is there a way to set the locale and keep it set between requests without using a before_action/before_filter in the application controller? I'm trying to avoid my current solution: class ApplicationController < ActionController::Base …
-2
votes
1 answer

Is there a faster way to convert text strings in Rails views to I18n keys?

I'm using Rails 4 and Sublime Text. I have a couple hundred views (templates) with plain strings of text that I need to convert to translatable keys. Example:

Hello world!

needs to be changed to: <%= t '.hello_world' %> ... and a…
-4
votes
2 answers

How can I set the error message automatically for 'validate'?

With a validation on a particular attribute using validates, one can, using the :message option, specify the key to the i18n message to be used when validation fails: In model: class Foo < ApplicationRecord validates :some_attribute, ....,…
sawa
  • 165,429
  • 45
  • 277
  • 381
1 2 3
51
52