对于number_to_percentage
,我有以下两种不同的翻译选项:
lt:
percentage:
format:
precision: 2
delimiter: ''
format: "%n%"
strip_insignificant_zeros: false
separator: '.'
和
default:
percentage:
format:
precision: 2
delimiter: ''
format: "%n%"
strip_insignificant_zeros: true
separator: '.'
如果我有LT翻译键,我得到
number_to_percentage 150.000 => 150.00%
如果我删除LT翻译键:
number_to_percentage 150.000 => 150,000%
when expected:
150%
,因为我在翻译中有strip_insignificant_zeros: true
。我理解错了翻译是如何与助手一起工作的?翻译可以作为助手的选项吗?
谢谢。
application.rb
config.i18n.default_locale = :default
config.i18n.fallbacks = true
在.yml文件上试试
format: %{n}%
t(:format, :n => 150.000)