i18n-gem

Rails 3.1, internalization of values from a habtm relationship?

有些话、适合烂在心里 提交于 2020-01-06 20:06:46
问题 I got a Event model that HABTM Categories. The relationship works fine and I can insert/retrieve values from Categories with no problem. My questions is, is there a way to interzationalize(I18n) the values of this categories. Category Model class Category < ActiveRecord::Base has_and_belongs_to_many :events end Event Model class Event < ActiveRecord::Base .... has_and_belongs_to_many :categories .... _form.html.haml (for events) - Category.all.each do |category| .field = check_box_tag

Rails 3.1, internalization of values from a habtm relationship?

[亡魂溺海] 提交于 2020-01-06 20:06:39
问题 I got a Event model that HABTM Categories. The relationship works fine and I can insert/retrieve values from Categories with no problem. My questions is, is there a way to interzationalize(I18n) the values of this categories. Category Model class Category < ActiveRecord::Base has_and_belongs_to_many :events end Event Model class Event < ActiveRecord::Base .... has_and_belongs_to_many :categories .... _form.html.haml (for events) - Category.all.each do |category| .field = check_box_tag

Locale not set in Application Controller

对着背影说爱祢 提交于 2019-12-25 11:46:18
问题 I've spent the last few hours trying everything possible to make this work, googled, redesigned, tested, etc. - but somehow doesn't get it working. ok, I would like to set the I18n.locale - fairly simple. Basically I implemented what is written on the guide here: http://guides.rubyonrails.org/i18n.html Application_controller.rb before_action :set_locale def set_locale I18n.locale = params[:locale] || I18n.default_locale end In fact mine looks like this: class ApplicationController <

Locale not set in Application Controller

馋奶兔 提交于 2019-12-25 11:44:56
问题 I've spent the last few hours trying everything possible to make this work, googled, redesigned, tested, etc. - but somehow doesn't get it working. ok, I would like to set the I18n.locale - fairly simple. Basically I implemented what is written on the guide here: http://guides.rubyonrails.org/i18n.html Application_controller.rb before_action :set_locale def set_locale I18n.locale = params[:locale] || I18n.default_locale end In fact mine looks like this: class ApplicationController <

i18n search using tire and Globalize3

这一生的挚爱 提交于 2019-12-11 03:36:42
问题 i have a site that uses globalize3 gem (https://github.com/svenfuchs/globalize3) and i'm currently adding the Tire gem to make site search. How do i do to Index a table translations depending on the actual locale? right now the model that gets indexed only does with the default locale. 回答1: You'd have to index all the translations: class Centre < ActiveRecord::Base include Tire::Model::Search include Tire::Model::Callbacks mapping do indexes :title_en, :as => lambda { |post| I18n.locale = :en

Rails Internationalization: i18n look up with nested locales directories

隐身守侯 提交于 2019-12-10 17:49:20
问题 I am trying to organize my localization files with a nested file structure so that it is easier to look up. I have followed Organization of Locale Files in rails app How do you structure i18n yaml files in Rails? but I am getting a translation missing: en.view.fruits.apple . I think that Rails is trying to only look up the translation in locales/en.yml file but not the sub-directories although, I have included them. config/application.rb: config.i18n.load_path += Dir["#{Rails.root.to_s}

Inheriting Rails i18n validation error messages in the subclass

我的未来我决定 提交于 2019-12-07 04:44:52
问题 What I understand Suppose I have a class with a handy validation like: User < ActiveRecord::Base validates :username, :format => {/regex/}, :message => :name_format end In this case, I can use i18n to make the error message translatable, by including the following in my /config/locals/en.yml : en: activerecord: errors: models: user: attributes: username: name_format: 'has the way-wrong format, bro!' This is fine and generally really handy. What I want to know: My question is: What happens

Organization of Locale Files in rails app

无人久伴 提交于 2019-12-06 17:15:24
问题 I currently have the following 4 files in my config/locales of my root application: -en.yml -de.yml -simple_form.en.yml -simple_form.de.yml In my application.rb which resides in a spec/dummy folder for testing the application gem I have the following line of code which seems to be retrieving the translations as expected: # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to