Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case Insensitive Translation

Tags:

python

django

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.

like image 539
pancakes Avatar asked Aug 05 '10 01:08

pancakes


1 Answers

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.

like image 96
Wolph Avatar answered Sep 22 '22 14:09

Wolph