-1

How do I access translation for nil value?

I tried with this locale(yml file):

pt-BR:
  boolean:
    "true": "sim"
    "false": "não"
    "": "não"
    nil: "não"
    "nil": "não"

But it does't work.

{:true=>"sim", :false=>"não", :""=>"não", :nil=>"não"}
Surya
  • 15,703
  • 3
  • 51
  • 74
Luiz Carvalho
  • 1,549
  • 1
  • 23
  • 46

1 Answers1

0

If your locale file is like this:

pt-BR:
  boolean:
    'true': "sim"
    'false': "não"
    nil: "não"

then you should be able to access them with:

2.0.0-p353 :001 > I18n.locale = 'pt-BR'
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 => "pt-BR"
2.0.0-p353 :002 > I18n.t('boolean.true')
 => "sim"
2.0.0-p353 :003 > I18n.t('boolean.nil')
 => "não"
2.0.0-p353 :004 > I18n.t('boolean.false')
 => "não"
Surya
  • 15,703
  • 3
  • 51
  • 74