views:

36

answers:

1

I'm displaying certain strings in my app in some places as regular case and in some places as upper case:

{% trans item.name %}
{% trans item.name.upper %}

I'm specifying translations using the .po/.mo files:

msgid "Welcome"  
msgstr "歓迎"

And the translation seems to be case-sensitive. 'Welcome' gets translated to '歓迎' but 'WELCOME' does not get translated. Is there an easy way to get it to translate case insensitive? It seems like it would be cleaner than providing each of these translations twice.

+3  A: 

The only "easy" way to do it is to always use either uppercase or lowercase strings and translate those. But as far as I know there is no support from either Django or Gettext for case insensitivity.

The question you should ask yourself is... is it really correct? I mean, in some languages the meaning of a word can change with casing. So I wonder if adding the capitalized translations automatically might be a better solution. That way you can atleast change them if it's needed for a specific language.

WoLpH
polish vs Polish for example :)
gnibbler
Great example gnibbler, I was trying hard to think of one.
WoLpH
This is definitely a valid point and seems to be the best answer in most cases. However, most of the data I'm translating is actually considered case insensitive and it's being treated as such in other ways within the system so I had never even thought about the possibility of case affecting the meaning. Still, it seems like it would be better to do as you say and add capitalized translations in case the situation changes in the future.
cloudshao