Rails locale not working

前端 未结 2 973
走了就别回头了
走了就别回头了 2021-01-14 06:03

I am using Rails 4
I have set the default locale to is in config/application.rb
is.yml is in config/locales
In Rails console I type

I18n.availa         


        
相关标签:
2条回答
  • 2021-01-14 06:26

    1.250 is exactly what you should get with your settings. To get 1,25 this will work.

    format:
      delimiter: ! ','
      precision: 2
      separator: ','
      significant: false
      strip_insignificant_zeros: false
    
    0 讨论(0)
  • 2021-01-14 06:39

    You can create your default configuration of delimiter on locale. Like:

    en:
      format:
        number:
          delimiter: ','
    
    
    pt-BR:
      format:
        number:
          delimiter: '.'
    

    After you set up this. You can call locale on normal delimiter like:

    for pt-BR:

    number_with_precision(6419336, precision: 2, delimiter: 
    I18n.t('number.format.delimiter')) #=> "6,419,336.00"
    

    for en:

    number_with_precision(6419336, precision: 2, delimiter: 
    I18n.t('number.format.delimiter')) #=> "6.419.336,00"
    
    0 讨论(0)
提交回复
热议问题