views:

32

answers:

1

Hi there,

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

+2  A: 

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.

Shadwell
Thanks for your answer. Maybe you're right. I checked again and it seems like it's always lowercased when using the string in a label. <%= t('email') %> gives the right one, but <%= f.label t('user.remember_me') %> lowercases it. Hmmm.
arnekolja
Checked the API. def label calls def label_tag, which translates with humanize. Hmmm, seems like there's no way around it for labels, right?
arnekolja
I've updated my answer. Looks like you can specify the text for the label manually.
Shadwell
Thanks, that's it. Should have seen this in the first place... I should not rely on the string anyway, as the label wouldn't work as expected then.
arnekolja