While working on an internationalized Rails application, I came across a case where the names of countries were being translated through the YAML locale configuration files. While a valid short-term measure, I would prefer using a gem like Globalize and storing the translations in a Country model, for example.
But in the meanwhile, I was asked to update some of the translations, and quickly discovered that you can’t use a period (a.k.a full-stop) in the token names. I tried surrounding them with quotes: "St. Lucia": St. Lucia
, escaping them with a slash "St\. Lucia": St. Lucia
, looking up the documentation, to no avail. I finally realized I could just break them into parent and child level tokens, like a period is meant to do:
Horrible, but works. If you use t("St. Lucia")
in your code you get a valid result!