简体   繁体   English

如何更改 Rails 中的默认单词?

[英]How to change default words in Rails?

I am using Rails 5.2.2 .我正在使用 Rails 5.2.2 。 I use the method:我用的方法:

distance_of_time_in_words(@customer.accounts.last.updated_at,Time.now)

And this gives me the output like " 9 days ".这给了我像“ 9 days ”这样的输出。 I want to change that days to my language.What is the correct way to change it ?我想将那days更改为我的语言。更改它的正确方法是什么?

Install the I18n Gem安装I18n Gem

and in config/environment/development.rb并在config/environment/development.rb

add this line添加这一行

config.i18n.default_locale = :fr #:fr is for french language  for example

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

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