西班牙语的复数和单数
抱歉我的英语...
我有一个开发到西班牙的rails应用程序,因此,所有内容都是西班牙语,所以,我有一个搜索框可以在mysql数据库中搜索,所有行都是西班牙语,我想改进我的搜索允许用户以单数或复数形式搜索关键字,例如:
keyword: patatas
found: patata
keyword: veces
found: vez
keyword: vez
found: veces
keyword: actividades
found: actividad
在英语中,借助单数和复数方法这可能相对容易......
where `searching_field` like '%singularized_keyword%' or `searching_field` like '%pluralized_keyword%'
但是,对于西班牙语......
有帮助吗?
谢谢!
sorry for my english...
I have a rails application developed to spain, therefore, all content is in spanish, so, I have a search box to search in a mysql database, all rows are in spanish, I'd like to improve my search to allow to users to search keywords in singular or plural form, for example:
keyword: patatas
found: patata
keyword: veces
found: vez
keyword: vez
found: veces
keyword: actividades
found: actividad
In english, this could be relatively easy with help of singularize and pluralize methods ...
where `searching_field` like '%singularized_keyword%' or `searching_field` like '%pluralized_keyword%'
But, for spanish....
Some help?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您现在可以定义自己的变化。
查看 config/initializers/inflections.rb 中的
根据您的问题
示例因此,
当然您需要提前知道关键字列表才能使用 config/inflections.rb 中的不规则方法。查看该文件中注释掉的示例。还有其他方法允许您使用正则表达式定义规则,并且您可以设计模式匹配来影响与已知模式匹配的任意关键字的变形。
You can define your own inflections now.
look in config/initializers/inflections.rb
an example based on your question
Thus
Of course you need to know the list of keywords in advance to use the irregular method in config/inflections.rb. Have a look at the commented out examples in that file. There are other methods that allow one to define rules using regular expressions and you could devise pattern matches to affect inflections for arbitrary keywords that match known patterns.
您必须清除英语中的所有默认词形变化并用西班牙语创建新的词形变化。
添加config/initializers/inflections.rb
You have to clear all default inflections in English and create new ones in Spanish.
Add in config/initializers/inflections.rb
我发现了这个好方法:
http://www.slideshare.net/crnixon/advanced-internationalization-with-rails问候
。
I found this great way:
http://www.slideshare.net/crnixon/advanced-internationalization-with-rails
Regards.
看来现在可以使用本地化的变形:
这样(并且在重新启动服务器后)您可以使用:
It seems that it is now possible to use localized inflections now:
With that (and after restarting the server) you can use: