Reputation: 3386
Localization is working fine, as per the official documentation. However I have found that Rails' humanize
method doesn't correctly capitalize the first character of a sentence if it's accented.
For example, if I have in config/locales/fr.yml:
fr:
about_me: "à propos de moi"
... and in the view:
<%= t("about_me").humanize %>
... the output in the browser is
à propos de moi
... whereas it should be
A propos de moi
If I change the à
to a
, humanize
works as expected.
Note that in French accents on capital letters are sometimes omitted but let's leave that aside. I'd be happy with:
À propos de moi
Do I just need to hardcode the capital letters in the YAML files to work around this? Naturally I'd prefer not to resort to this.
Upvotes: 1
Views: 396
Reputation: 434965
I'd recommend doing it in the YAML, capitalization depends on the language and the context; for example, German capitalizes all nouns but English only capitalizes proper nouns and the accent issue in French that you're already aware of, the relationship between ß
and SS
in German, etc. Getting things right though simple-minded string manipulation is very error prone. You're better off treating human-readable strings as opaque and immutable pieces of data that you pull out of your I18N/L10N string database and give to the user as-is.
This is more work but being correct is sort of important.
Upvotes: 1