rails-i18n

How to include ё in [а-я] regexp char interval

为君一笑 提交于 2019-12-12 07:23:49
问题 Russian alphabet includes the letter ё , which was undeservedly forgotten at beggining of computing. So, if i want to use a regexp with character diapason, I must mention this letter separately: [а-яА-яёЁ] instead of: [а-яА-Я] example: lets we have string "Верёвочка - 12" and need to parse only word by regular expression: word = "Верёвочка"[/а-яА-Я/] # => "" word = "Верёвочка"[/а-яА-ЯёЁ/] # => "Верёвочка" How can I upgrade regexp class in Ruby or Ruby on Rails to resolve this problem? 回答1:

rails i18n passed params get lost

≡放荡痞女 提交于 2019-12-12 01:53:25
问题 I started using i18n with my app, but all the pages that i access by passing a parameter with the link_to isn't working. so, let's say i'm currently on this page /ar/browse?type=art that i got to via clicking on this link_to <%= link_to "/ART/", browse_url(:type => "art")%> then i decided to change the language via clicking on this: <%= link_to_unless_current "en", locale: 'en', :class => 'my-navbar-link' %> after changing the language, that's what i get directed to /en/browse?class=my-navbar

Globalizing files (attachments, images) in rails

六月ゝ 毕业季﹏ 提交于 2019-12-11 10:55:02
问题 We can use globalize gem for globalizing text fields in models. For globalizing(translating) 'designation' attribute of an employee, we use translates :designation in the employee model, and employee.translations prints the translations for the employee object (one object for each supported locale with designation in corresponding locale). I have a model specific attribute (image for employee) which is a paperclip attachment. Need to globalize the image, so that employee.image will give the

Add locales to Singular controller in rails4

岁酱吖の 提交于 2019-12-11 10:36:41
问题 I have a singular controller i want to add locales to that. It looks like class AboutController < ApplicationController def home end def markdown_syntax end end And my about.en.yml looks like en: about: home: discover_message: 'Discover, Track and Compare Open Source' join_now: 'Join Now' whats_new: "What's New" popular_projects: 'Most Popular Projects' active_projects: 'Most Active Projects' I am getting translation missing error because it doesn't recognizing from about.en.yml Error Message

Way Rails does not raise I18n::MissingInterpolationArgument exception?

和自甴很熟 提交于 2019-12-11 10:02:01
问题 I created a dummy rails 4.1.5 application to show that I18n translate method doesn't raise I18n::MissingInterpolationArgument when the variable to be interpolated is not provided. It raises that exception only if provide something wrong. Is this the expected behaviour? Loading development environment (Rails 4.1.5) irb(main):001:0> I18n.backend.store_translations :en, thanks: 'Thanks %{name}!' => {:thanks=>"Thanks %{name}!"} irb(main):002:0> I18n.translate :thanks => "Thanks %{name}!" irb(main

Loading a YML file in Rails, and maybe using a i18n file instead

血红的双手。 提交于 2019-12-11 09:32:05
问题 I have a dropdown.yml file that stores all my dropdown values for my multi-select fields in my forms. It is not environment dependent, so I do not have :development, :production, etc. I would like cache the file into a constant so I can use across my app. I found this command. config = Rails.application.config_for(:payment) However, it looks like it is environment dependent. What is the best way to add the yml? Second, should I use locales for this instead of a custom yml file? config

Starting rails I18n and url helpers seem to confuse locale with id

此生再无相见时 提交于 2019-12-11 06:19:42
问题 I have just started trying to update our rails 3.2 app for internationalization. I have an optional scope in the routes, like scope "(:locale)", locale: /en|es|zh-HK|de|fr/ do as described by http://guides.rubyonrails.org/i18n.html. And my url helper like watch_url(@watch) gets errors in the form No route matches {:action=>"show", :controller=>"watches", :locale=>#<Watch id: 1, rule_name: "MyRule", start_time: "2014-06-08 03:30:03", end_time: nil, last_execution_time: nil, frequency_mins: 60,

Rails 4 - Would Like To Do Custom Error Pages in Public Folder Using I18n

随声附和 提交于 2019-12-11 05:06:14
问题 I had custom error pages in my Rails 3.2.13 application using config.exceptions_app = self.routes in config/application.rb with my logic in errors_controller and views in app/views/errors. I was using the Rails 3 version of the routing-filter gem which took care of the routing. I removed the gem because it does not work with Rails 4. I rewrote the routing logic using the native Rails functionality and rewrote the application in Rails 4. Using the native Rails functionality broke the logic I

I18n locale disregarding fallbacks

寵の児 提交于 2019-12-11 02:27:58
问题 I asked a previous question regarding locale-setting. I am trying to set up fallbacks of various Norwegian languages to Norwegian Bokmal (:nb). The desired behaviour is that if a browser passes nn or no as locale requests, the I18n.locale will be set to either :nn or :no, and then in the absence of translations for these locales, :nb will be served to the browser. Based on the answer to my previous question, I have this line in my application initialiser: config.i18n.default_locale = :en

upgrading to ruby 2.3.0 NameError: uninitialized constant I18n::Config::Backend

放肆的年华 提交于 2019-12-11 01:39:53
问题 I just upgraded Ruby 2.2.2 to 2.3.0. Whenever I run a rake task I get the following error: Christians-Air:my_rails_app cman77$ rake --trace rake aborted! NameError: uninitialized constant I18n::Config::Backend /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n/config.rb:19:in `backend' /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n.rb:147:in `translate' /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/actionview-4.2.6/lib/action_view/helpers/translation