Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails i18n strings auto-lowercased?

I've noticed that in my new Rails 3.0 application all German i18n strings are converted to lowercase (except for the first letter).

When having a string like this:

de:
  email: "E-Mail"

the output is always like "E-mail". Same story with all the other strings - uppercase letters within a sentence are auto-converted to lowercase.

Is this default behaviour that I have to disable, or is there any other problem? I have successfully set the locale correctly, as these strings to actually work.

Thanks for your help

Arne

like image 304
arnekolja Avatar asked Sep 14 '10 15:09

arnekolja


2 Answers

Got the same issue. solved it by adding the _html suffix to the I18n translation key. it seems that using this suffix suppresses the humanize usage.

like image 41
Elad Meidar Avatar answered Nov 08 '22 02:11

Elad Meidar


There should be no modifications to the content you specify as part of the internationalization process. It sounds like something is calling humanize on the string before it is output. Some of the standard Rails form helper methods do this I believe. If you just output the translation using t('email') you should see 'E-Mail' correctly.

Update: From your comments it seems like it is a label that is causing the problem. If you explicitly specify the text for the label rather than relying on the default behaviour you will get the translation exactly as you specify. So,

<%= f.label(:email, t('email')) %>

should generate the correct label from the translations.

However, it isn't ideal. I think you may also run into problems with the generated validation error messages.

like image 99
Shadwell Avatar answered Nov 08 '22 01:11

Shadwell