2015-06-02 43 views
1

我需要设置默认区域设置西班牙语我的应用程序。轨生成缺省地点

这些都是我的文件application.rb中的台词:

class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    # config.time_zone = 'Central Time (US & Canada)' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] 
    Rails.application.config.i18n.default_locale = :es 

    end 

但是,当我生成支架的拐点是错误的。它是英文的语言环境。

轨摹支架Preparado NOMBRE:字符串

我拿错复数:Preparadoes,它必须是:Preparados。

在控制台上我尝试这样做:

irb(main):015:0> I18n.locale = 'es' 
=> "es" 
irb(main):016:0> 'preparado'.pluralize() 
=> "preparadoes" 
irb(main):017:0> 'preparado'.pluralize(:es) 
=> "preparados" 
irb(main):018:0> 

我的Gemfile包含:

gem 'inflections' 

总之,我需要创建一个正确的多元化的支架。

对不起我的英语。我知道这不是最好的。

谢谢。

回答

1

国际化并不影响多元化这里,导轨采用拐点的它,只有一个方法,我知道来定制它:

ActiveSupport::Inflector.inflections do |inflect| 
    inflect.irregular 'preparado', 'preparados' 
end 

config/initializers/inflections.rb

Spanish locale#pluralize,但你每次调用它时都需要明确地设置它。并且generator不带参数地调用它。