Comment 23 for bug 650910

Revision history for this message
Mikko Rantalainen (mira) wrote :

Executing
$ LC_ALL=fi_FI.UTF-8 openshot
gives me UI mostly in Finnish (some parts are missing translation but it seems that those are not translated instead of using incorrect locale). Output to stdout and stderr are a mixture of Finnish and English even with this locale setting.

$ LC_ALL=en_US.UTF-8 openshot
gives me UI fully in English as expected.

$ locale
LANG=en_DK.utf8
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC=en_DK.UTF-8
LC_TIME=en_DK.UTF-8
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY=fi_FI.UTF-8
LC_MESSAGES=en_DK.UTF-8
LC_PAPER=fi_FI.UTF-8
LC_NAME=fi_FI.UTF-8
LC_ADDRESS=fi_FI.UTF-8
LC_TELEPHONE=fi_FI.UTF-8
LC_MEASUREMENT=fi_FI.UTF-8
LC_IDENTIFICATION="en_DK.utf8"
LC_ALL=
$ LC_CTYPE=en_US.UTF-8 openshot
gives me UI fully in English, which is not expected. It seems that OpenShot is incorrectly using LC_CTYPE for message localizations instead of LC_MESSAGES.

Steps to reproduce:
1) sudo apt-get install language-pack-fi language-pack-en
2) LC_ALL= LC_CTYPE=fi_FI.UTF-8 LC_MESSAGES=en_US.UTF-8 openshot
# notice the space after "LC_ALL=" to unset the LC_ALL environment variable

This will result in a mixture of Finnish and English. It seems that part of the UI is incorrectly using localization messages set by LC_CTYPE instead of LC_MESSAGES. LC_CTYPE is supposed to define character classes (which characters are numbers, which are letters, etc) and conversions (if lowercase of "SS" is "ss" (Finnish) or "ß" (German), for example).

The locale.getpreferredencoding() does not return a pair of locale and encoding, just the encoding. Locale should be queried with
    lc = locale.getlocale(locale.LC_MESSAGES)
which seems to return correct values for me (tried with python interpreter, not openshot).

It seems that locale.getdefaultlocale() returns value of LC_CTYPE in reality. That should be fine for decising the *encoding* for stdout and stderr but it's definitely not ok to use that to select language for message localization.

I'll repeat: use LC_CTYPE for output encoding and possible uppercase and lowercase conversions ("how unicode characters should be treated in this environment regardless of language of those characters"). However, use LC_MESSAGES for message localizations ("which unicode character string to output for a given message").

Also see comment 14.