简体   繁体   English

如何为法语设置 Rails?

[英]How do I set up Rails for French language?

I have to develop a Ruby on Rails app for my company and don't know how to configure it for a French site.我必须为我的公司开发一个 Ruby on Rails 应用程序,但不知道如何为法国网站配置它。

I don't need multiple language support, I just want to have error messages, pluralization and date format for French.我不需要多语言支持,我只想要法语的错误消息、复数和日期格式。

I tried to set:我试图设置:

config.i18n.default_locale = :fr

in my application.rb file but it doesn't seem to have any effect.在我的application.rb文件中,但它似乎没有任何效果。

Are these features already implemented in RoR 3?这些功能是否已经在 RoR 3 中实现? Or I will have to translate these things myself?还是我必须自己翻译这些东西?

To set your application to French you need to set config.i18n.default_locale =:fr in your config/application.rb , create fr.yml file in your aplication config/locales folder and add needed localized strings to this file.要将您的应用程序设置为法语,您需要在config/application.rb中设置config.i18n.default_locale =:fr ,在您的应用程序config/locales文件夹中创建fr.yml文件并将所需的本地化字符串添加到该文件中。 Check this out:看一下这个:
fr.yml 框架

this will help you to translate dates and etc.这将帮助您翻译日期等。

As far as I know, Rails comes with en locale only.据我所知,Rails 仅带有 en locale。 You can get additional locales here: https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/您可以在此处获取其他语言环境: https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/

Add to rails-i18n your Gemfile :添加到rails-i18n你的Gemfile

gem 'rails-i18n'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM