Ruby On Rails:其他语言的复数形式 [英] Ruby On Rails: pluralize for other languages

查看:89
本文介绍了Ruby On Rails:其他语言的复数形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为非英语受众开发应用程序.现在,我使用英语名词来命名我的模型,但我更喜欢使用荷兰语的名词.由于约定使用表的类名的复数形式,因此我假设它是Rails内部的复数方法(我不知道它位于何处).如何更改复数方法及其位置?这会打破Rails吗?

I am building apps for a non-english audience. Right now, I use english nouns to name my models, yet I prefer to use native dutch ones. As the convention uses the plural of the class name for tables, I assume it is the pluralize method inside Rails (where it resides, I wouldn't know). How can I change the pluralize method and where is it located? Would this break Rails?

我正在使用Rails 2.3.5和Ruby 1.8.7

I am using Rails 2.3.5 and Ruby 1.8.7

示例: Book类现在成为 books . 我的Boek班级成为 boeks ,但是使用 boeken

Example: The Book class becomes books now. My Boek class becomes boeks, but it is grammatically correct to use boeken

推荐答案

将规则添加到config/initializers中的 inflections.rb 文件中.请参见 API文档:

Add your rules to an inflections.rb file in config/initializers. See the API documentation:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.plural 'boek', 'boeken'
end

这篇关于Ruby On Rails:其他语言的复数形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆