Rails locale not working

前端 未结 2 983
走了就别回头了
走了就别回头了 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    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"
    

提交回复
热议问题