Railsで以下のようなlocaleファイルを書いたところ、translation missing となってしまった。

ja:
  yes: はい
  no: いいえ
I18n.t("yes")
# => "translation missing: ja.yes"

調べてみたところこれは YAML の仕様で、yes/no は真偽値と判定され、”yes”/”no” ではなく true/false と扱われるためらしい。

In YAML, untagged nodes are given an type depending on the application. The examples in this specification generally use the seqmap and str types from the YAML tag repository. A few examples also use the int and float types. The repository includes additional types such as nullboolset and others.

https://yaml.org/spec/1.1/#id858600

なので、”yes”ではなく”true”でアクセスできた。

I18n.t("true")
=> "はい"

YAML で yes/no を使いたい場合はクォートすれば良い。

ja:
  "yes": はい

ちなみに yes/no だけでなく、on/off も真偽値と判定されるよう。

https://yaml.org/type/bool.html

YAMLは型をもっていて文字列以外も扱えるのだけど、キーにも文字列以外が使えることが抜けがちだなと思いました。

irb(main):001:0> YAML.load("0xff: yes")
=> {255=>true}