rails-i18n

Rails: How to make Date strftime aware of the default locale?

久未见 提交于 2019-11-29 21:13:24
I have my default locale set in the environment.rb as de (German). I also see all the error messages in German, so the locale is picked up by the server. But when I try to print date with strftime like following: some_date.strftime('%B, %y') It prints in English ( January, 11 ), and not the expected German ( Januar, 11 ). How can I print the date according to the default locale? Milan Novota Use the l (alias for localize ) method instead of raw strftime, like this: l(date, format: '%B %d, in the year %Y') See here for more information, hope that helps. You can also define 'named' formats, a

Rails: Remove missing translation errors

我与影子孤独终老i 提交于 2019-11-29 17:30:32
问题 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 span. For eg if I have got something like <%= text_field_tag( "search", params[:search], :placeholder=>t("Search"), :class=>"search_input") %> and i get output for en is: <input class="search_input" id="search" name="search" placeholder="<span

Why word 'translate' is messing irb?

末鹿安然 提交于 2019-11-29 16:01:46
I don't understand why my method translate undefines start_with? method and is messing something in irb, so I can exit irb only by pressing Ctrl + d , not exit or quit : >> "hello".respond_to?(:start_with?) => true >> def translate(string) >> if string.start_with?("a", "e", "i", "o", "u") >> string += "ay" >> end >> end NoMethodError: undefined method `start_with?' for #<RubyVM::InstructionSequence:0x00000001d4c960> from (irb):3:in `translate' from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>' >> "hello".respond_to?(:start_with?) NoMethodError: undefined method `start_with?' for

bundler install getting “i18n requires Ruby version >= 1.9.3”

懵懂的女人 提交于 2019-11-29 15:18:44
How can I correct this "i18n requires Ruby version >= 1.9.3" I get when I run "bundler install"? Background: Need to use ruby 1.8.7 on dreamhost, so have targeted Rails v3.2 for this. Command Line Gregs-MacBook-Pro:weekends Greg$ ruby -v ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin14.1.0] Gregs-MacBook-Pro:weekends Greg$ bundler -v Bundler version 1.9.2 Gregs-MacBook-Pro:weekends Greg$ bundler install Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/... Fetching dependency metadata from https://rubygems.org/.. Resolving

i18n Routing To Mounted Engine - Ignoring locale

六眼飞鱼酱① 提交于 2019-11-29 04:32:25
I have an application (my_test_app) with working i18n support built. Currently, there are two language files available, FR & EN, and if I toggle back and forth between them, everything works as I expect to see it for non-engine functions such as the User index/show/edit/delete (ISED) options. Within my_test_app I have a Rails Engine mounted (my_engine) which has a controller & model set (engine_job). So, a workable URL should be http://0.0.0.0:3000/fr/my_engine/engine_job No matter what language I choose, however, it always shows up in EN. Examining the parameters shows: --- !ruby/hash

i18n Pluralization

橙三吉。 提交于 2019-11-28 15:00:00
I want to be able to translate pluralized strings in i18n in rails. A string can be : You have 2 kids or You have 1 kid I know that I can use pluralize helper method, but I want to embed this in i18n translations so that I don't have to mess up with my views at any point in the future. I read that :count is somehow used in translations for plural, but I can't find any real resources on how it gets implemented. Notice that I know that I can pass a variable in a translation string. I also tried something like : <%= t 'misc.kids', :kids_num => pluralize(1, 'kid') %> Which works fine, but has a

bundler install getting “i18n requires Ruby version >= 1.9.3”

青春壹個敷衍的年華 提交于 2019-11-28 09:16:57
问题 How can I correct this "i18n requires Ruby version >= 1.9.3" I get when I run "bundler install"? Background: Need to use ruby 1.8.7 on dreamhost, so have targeted Rails v3.2 for this. Command Line Gregs-MacBook-Pro:weekends Greg$ ruby -v ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin14.1.0] Gregs-MacBook-Pro:weekends Greg$ bundler -v Bundler version 1.9.2 Gregs-MacBook-Pro:weekends Greg$ bundler install Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata

i18n Routing To Mounted Engine - Ignoring locale

送分小仙女□ 提交于 2019-11-27 18:23:57
问题 I have an application (my_test_app) with working i18n support built. Currently, there are two language files available, FR & EN, and if I toggle back and forth between them, everything works as I expect to see it for non-engine functions such as the User index/show/edit/delete (ISED) options. Within my_test_app I have a Rails Engine mounted (my_engine) which has a controller & model set (engine_job). So, a workable URL should be http://0.0.0.0:3000/fr/my_engine/engine_job No matter what

how to use rails i18n fallback features

落爺英雄遲暮 提交于 2019-11-27 14:35:27
I have this i18n problem activerecord: notices: messages: success: create: "Something was created" models: user: success: create: "Thanks for registration" I18n.t("activerecord.notices.models.user.success.create") # => "Thanks for registration" I18n.t("activerecord.notices.models.book.success.create") # => "translation missing: de, activerecord, notices, models, book, success, create" I don't know why the book model doesn't get the fallback massage. I have set config.i18n.fallbacks = true . I'm using Rails 3 When a :default option is given, its value will be returned if the translation is

Rails I18n validation deprecation warning

自古美人都是妖i 提交于 2019-11-27 05:46:38
I just updated to rails 4.0.2 and I'm getting this warning: [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. Is there any security issue in setting it to false? Simone Carletti Important : Make sure your app is not using I18n 0.6.8, it has a bug that prevents the configuration to be set correctly . Short answer In order to silence the warning edit the application.rb file and include the following line inside the Rails::Application body