rails-i18n

Rails I18n Cascading - how to get it to work

和自甴很熟 提交于 2020-01-07 04:12:17
问题 I read in this blogpost from Sven Fuchs about the cascading possibility by I18n, but I am unable to get it to work. I tried to put the code mentioned in the blogpost into the application controller and into an initializer, I also tried to pass the cascade option, like it is mentioned in the comments in the module itself, but nothing seems to work. Does anybody have any hints or a working example about how to get I18n cascading in a Rails 4 App up and running? 回答1: So, finally got this working

App cannot access translation files in engine or gem

不问归期 提交于 2020-01-02 03:41:04
问题 I tried every combination I can think of but I cannot get my app to see the localized content provided by my engine. Now the engine does just fine. I see the same problem with Rails_admin . Where it's i18n files are in a separate gem. The main app cannot seem to see the files. I'm sure there must be an error in how I'm specifying the I18n.load_path , but it's got me beat. from Ryan Bates rails cast: I18n.load_path += Dir[Rails.root.join('config', 'locale', '*.{rb,yml}')] And one of my hack

How to configure locale aliases using i18n & rails?

微笑、不失礼 提交于 2020-01-01 19:52:31
问题 I am working on a rails app (3.2.13) that is being translated into several languages, including (one of the 3 available flavours of) Norwegian. On public pages, the app uses the browser's language settings to set locale. Most browsers offer 3 separate Norwegian shortcodes: no , nb & nn . The translations we have are in nb , but I think it would be best if no & nn also defaulted to nb . That way, if a user's browser language preferences were set to no then en , the app would try to supply nb

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 <

Add translation to I18N dynamically

回眸只為那壹抹淺笑 提交于 2019-12-25 01:45:04
问题 I have added humanized-money-accessors as described here: Decimals and commas when entering a number into a Ruby on Rails form Now I have two attributes in my model for the same type of data: the original version and the human-readable version. The problem: Since I am using activerecord-translation-yml-files, I have to put in the same translation for original attribute and the humanized_attribute, because my forms show the name of thie humanized_attribute, but on validation errors, the name

Ruby on Rails 3.2.13 - Getting Error With Custom Error Pages Using I18n

瘦欲@ 提交于 2019-12-25 00:43:25
问题 I have a Rails 3.2.13 application where I originally used the routing-filter gem for I18n. I plan to rewrite it in Rails 4. I removed the gem since there is no Rails 4 production version available and I could not get the beta version to work. I was successful in getting the routing set up for most of the application. The only problem I am having is with my custom error pages. I created custom error pages when I was using the routing-filter gem. I need help on how I should set up my routes for

Rails internationalization is not working in production mode

送分小仙女□ 提交于 2019-12-24 18:11:08
问题 I have a non-AR model, which I use for a form/composition object. There are lots input fields, which I collect in order to do some data manipulation inside AR transaction. I use I18n for internationalization. yml: pl: activemodel: attributes: catalog/checkout: name: Imię form: = f.input :name, required: true, label: I18n.t(:'.activemodel.attributes.catalog/checkout.name') The issue is that in development and production modes (locally) I see the input having proper label taken from config

Rails internationalization is not working in production mode

丶灬走出姿态 提交于 2019-12-24 18:10:37
问题 I have a non-AR model, which I use for a form/composition object. There are lots input fields, which I collect in order to do some data manipulation inside AR transaction. I use I18n for internationalization. yml: pl: activemodel: attributes: catalog/checkout: name: Imię form: = f.input :name, required: true, label: I18n.t(:'.activemodel.attributes.catalog/checkout.name') The issue is that in development and production modes (locally) I see the input having proper label taken from config

Testing helper in rspec with I18n lazy lookup

血红的双手。 提交于 2019-12-23 12:07:15
问题 Consider this example. I have a Product model which has discount_percentage . And we're maintaining multiple locales. In the view we do not want the i18n stuff mess up the view. So we make a helper to read better and probably reuse it in other views: render_product_discount (code please see below) which will render the discount status of this product. And we use i18n lazy lookup feature throughout the application. But when we want to test this helper method we get a Error: # RuntimeError: #