This repository has been archived by the owner. It is now read-only.

MKVToolnix GUI: interface language cannot be changed (stays English) #2070

Closed
be-sc opened this Issue Aug 7, 2017 · 8 comments

Comments

@be-sc

be-sc commented Aug 7, 2017

Problem

Changing the interface language in Preferences › GUI has no effect. Even after a restart MKVToolnix GUI is still displayed in English.

This happens with MKVToolnix v14.0.0 64bit from the Arch repo (installed packages mkvtoolnix-cli and mkvtoolnix-gui through pacman)

To reproduce, starting with a fresh install (~/.config/bunkus.org not present):

  • Start MKVToolnix GUI. UI is in English (see locale settings below)
  • Go to Preferences › GUI. Interestingly the interface language combo says Catalan (which is also the very first item in that combo box).
  • Change it to non-English, e.g. German.
  • Restart MKVToolnix GUI.
  • UI still displayed in English, but Preferences › GUI says German.

mkvtoolnix-gui.ini after these actions: mkvtoolnix-gui.ini.zip

My system

Arch Linux (Antergos) running KDE Plasma

$ plasmashell -v
qt5ct: using qt5ct plugin
plasmashell 5.10.4
$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_COLLATE=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Aug 7, 2017

Owner

Works just fine here on my Arch system (Arch is my primary development platform).

Please post the output of the following:

ls -l /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo
LC_ALL=de_DE.UTF-8 perl -le 'use utf8; binmode STDOUT, ":utf8"; print "möp"'
/usr/bin/mkvmerge --debug locale --ui-language de_DE --help | grep '^Debug'
/usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
Owner

mbunkus commented Aug 7, 2017

Works just fine here on my Arch system (Arch is my primary development platform).

Please post the output of the following:

ls -l /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo
LC_ALL=de_DE.UTF-8 perl -le 'use utf8; binmode STDOUT, ":utf8"; print "möp"'
/usr/bin/mkvmerge --debug locale --ui-language de_DE --help | grep '^Debug'
/usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
@be-sc

This comment has been minimized.

Show comment
Hide comment
@be-sc

be-sc Aug 7, 2017

Thanks for the quick reply. Here’s the output; still English messages:

$ ls -l /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo
-rw-r--r-- 1 root root 355693 Jul 31 20:39 /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo

$ LC_ALL=de_DE.UTF-8 perl -le 'use utf8; binmode STDOUT, ":utf8"; print "möp"'
möp

$ /usr/bin/mkvmerge --debug locale --ui-language de_DE --help | grep '^Debug'
Debug> src/common/translation.cpp:0268: [init_locales start: locale de_DE]
Debug> src/common/translation.cpp:0163: [get_default_ui_locale previous en_GB.UTF-8]
Debug> src/common/translation.cpp:0170: [get_default_ui_locale new en_GB.UTF-8]
Debug> src/common/translation.cpp:0316: [init_locales loc_default is en_GB.UTF-8; trying locale de_DE followed by loc_req_with_default_codeset de_DE.UTF-8]
Debug> src/common/translation.cpp:0335: [init_locales chosen locale de_DE.UTF-8]

$ /usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

Then I tried successfully (note the missing --ui-language):

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Adding --ui-language:

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language en_GB --help | head -n 1
Fehler: Für »en_GB« ist keine Übersetzung verfügbar.

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language en_US --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

For comparison: Git exhibits similar behaviour: With LC_ALL=de_DE.UTF-8 git its output is English, with LANGUAGE=de_DE.UTF-8 git it switches to German.

This may be interesting:

$ env|grep LANG
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en_US

I’m not sure what to make of this. On the one hand I’m kind of inclined to call it not-a-bug but a strangeness of my system’s config. On the other hand so far MKVToolnix GUI is the only GUI application that refuses to switch language. For example SMPlayer and KeePassXC (both Qt5 based) switch as expected without env variable tampering.

be-sc commented Aug 7, 2017

Thanks for the quick reply. Here’s the output; still English messages:

$ ls -l /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo
-rw-r--r-- 1 root root 355693 Jul 31 20:39 /usr/share/locale/de/LC_MESSAGES/mkvtoolnix.mo

$ LC_ALL=de_DE.UTF-8 perl -le 'use utf8; binmode STDOUT, ":utf8"; print "möp"'
möp

$ /usr/bin/mkvmerge --debug locale --ui-language de_DE --help | grep '^Debug'
Debug> src/common/translation.cpp:0268: [init_locales start: locale de_DE]
Debug> src/common/translation.cpp:0163: [get_default_ui_locale previous en_GB.UTF-8]
Debug> src/common/translation.cpp:0170: [get_default_ui_locale new en_GB.UTF-8]
Debug> src/common/translation.cpp:0316: [init_locales loc_default is en_GB.UTF-8; trying locale de_DE followed by loc_req_with_default_codeset de_DE.UTF-8]
Debug> src/common/translation.cpp:0335: [init_locales chosen locale de_DE.UTF-8]

$ /usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

Then I tried successfully (note the missing --ui-language):

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Adding --ui-language:

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language en_GB --help | head -n 1
Fehler: Für »en_GB« ist keine Übersetzung verfügbar.

$ LANGUAGE=de_DE.UTF-8 /usr/bin/mkvmerge --ui-language en_US --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

For comparison: Git exhibits similar behaviour: With LC_ALL=de_DE.UTF-8 git its output is English, with LANGUAGE=de_DE.UTF-8 git it switches to German.

This may be interesting:

$ env|grep LANG
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en_US

I’m not sure what to make of this. On the one hand I’m kind of inclined to call it not-a-bug but a strangeness of my system’s config. On the other hand so far MKVToolnix GUI is the only GUI application that refuses to switch language. For example SMPlayer and KeePassXC (both Qt5 based) switch as expected without env variable tampering.

@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Aug 7, 2017

Owner

Which LC_… variables do you have set (env|grep LC_)?

Owner

mbunkus commented Aug 7, 2017

Which LC_… variables do you have set (env|grep LC_)?

@be-sc

This comment has been minimized.

Show comment
Hide comment
@be-sc

be-sc Aug 7, 2017

$ env|grep LC_
LC_MEASUREMENT=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
LC_COLLATE=de_DE.UTF-8
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8

$ locale -a
C
de_DE.utf8
en_GB.utf8
en_US.utf8
POSIX

be-sc commented Aug 7, 2017

$ env|grep LC_
LC_MEASUREMENT=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
LC_COLLATE=de_DE.UTF-8
LC_NUMERIC=de_DE.UTF-8
LC_TIME=de_DE.UTF-8

$ locale -a
C
de_DE.utf8
en_GB.utf8
en_US.utf8
POSIX
@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Aug 7, 2017

Owner

Thanks. I can reproduce the behavior with the environment variables you've shown. However, I' not sure if I'd really call this a bug in MKVToolNix. It's basically an interaction with GNU gettext and the LANGUAGE environment variable you might not be aware of.

Quoting the first paragraph of section 2.3.3 "Specifying a Priority List of Languages" of the gettext manual:

…GNU gettext gives preference to LANGUAGE over LC_ALL and LANG for
the purpose of message handling, but you still need to have LANG (or
LC_ALL) set to the primary language…

Your LANGUAGE is set to include en_GB and en_US but no other languages. This means that gettext itself will only chose one of those translations, no matter what mkvmerge tells gettext to use via the LC_MESSAGES environment variable.

Here's the status quo that doesn't work:

[0 mosu@sweet-chili ~/tmp] echo $LANGUAGE
en_GB:en_US:de_DE
[0 mosu@sweet-chili ~/tmp] mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

That's your status quo.

Unsetting LANGUAGE makes this work suddenly:

[0 mosu@sweet-chili ~/tmp] LANGUAGE= mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Including de_DE in the list of languages to chose the messages from works, too:

[0 mosu@sweet-chili ~/tmp] LANGUAGE=en_GB:en_US:de_DE mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Basically by using LANGUAGE you're not only expressing a preference or an order, but a hard restriction on which are actually chosen by gettext.

As far as I know (and a quick search seems to confirm this) there's no way to force gettext to use a specific language.

What I'll try later tonight (and which might actually be a fix, not sure yet) is to let mkvmerge unset the LANGUAGE environment variable if the --ui-language parameter is present. The GUI would always have to unset it always tries to enforce the language.

Owner

mbunkus commented Aug 7, 2017

Thanks. I can reproduce the behavior with the environment variables you've shown. However, I' not sure if I'd really call this a bug in MKVToolNix. It's basically an interaction with GNU gettext and the LANGUAGE environment variable you might not be aware of.

Quoting the first paragraph of section 2.3.3 "Specifying a Priority List of Languages" of the gettext manual:

…GNU gettext gives preference to LANGUAGE over LC_ALL and LANG for
the purpose of message handling, but you still need to have LANG (or
LC_ALL) set to the primary language…

Your LANGUAGE is set to include en_GB and en_US but no other languages. This means that gettext itself will only chose one of those translations, no matter what mkvmerge tells gettext to use via the LC_MESSAGES environment variable.

Here's the status quo that doesn't work:

[0 mosu@sweet-chili ~/tmp] echo $LANGUAGE
en_GB:en_US:de_DE
[0 mosu@sweet-chili ~/tmp] mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

That's your status quo.

Unsetting LANGUAGE makes this work suddenly:

[0 mosu@sweet-chili ~/tmp] LANGUAGE= mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Including de_DE in the list of languages to chose the messages from works, too:

[0 mosu@sweet-chili ~/tmp] LANGUAGE=en_GB:en_US:de_DE mkvmerge --ui-language de_DE --help | head -n 1
mkvmerge -o Ziel [globale Optionen] [Optionen1] <Datei1> [@Optionsdatei.json] …

Basically by using LANGUAGE you're not only expressing a preference or an order, but a hard restriction on which are actually chosen by gettext.

As far as I know (and a quick search seems to confirm this) there's no way to force gettext to use a specific language.

What I'll try later tonight (and which might actually be a fix, not sure yet) is to let mkvmerge unset the LANGUAGE environment variable if the --ui-language parameter is present. The GUI would always have to unset it always tries to enforce the language.

@be-sc

This comment has been minimized.

Show comment
Hide comment
@be-sc

be-sc Aug 7, 2017

No, I wasn’t aware of that behaviour. I just abandoned Windows 7 for Antergos, so this is all still rather new … :)

I also agree that MKVToolnix is not really to blame. What tripped me up was the name of the Preferred Languages list in KDE’s Regional Settings. That list is directly responsible for the content of LANGUAGE. With the way gettext works it’s apparently best to keep it empty. Did that and I can confirm that now both MKVMerge and the GUI behave as expected.

Thank you for your help!

be-sc commented Aug 7, 2017

No, I wasn’t aware of that behaviour. I just abandoned Windows 7 for Antergos, so this is all still rather new … :)

I also agree that MKVToolnix is not really to blame. What tripped me up was the name of the Preferred Languages list in KDE’s Regional Settings. That list is directly responsible for the content of LANGUAGE. With the way gettext works it’s apparently best to keep it empty. Did that and I can confirm that now both MKVMerge and the GUI behave as expected.

Thank you for your help!

@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Aug 7, 2017

Owner

You're welcome, and thanks for the feedback. I think I'll still call this a bug. Traditionally we have the following order where programs get their settings from (in descending order of importance):

  1. command-line arguments,
  2. user's configuration file (e.g. one in $HOME/.config/…)
  3. environment variables
  4. system's configuration file (e.g. one in /etc/…)

If my tools fail to set the language when the user uses the variant with the highest importance, then considering that a bug is probably correct.

Owner

mbunkus commented Aug 7, 2017

You're welcome, and thanks for the feedback. I think I'll still call this a bug. Traditionally we have the following order where programs get their settings from (in descending order of importance):

  1. command-line arguments,
  2. user's configuration file (e.g. one in $HOME/.config/…)
  3. environment variables
  4. system's configuration file (e.g. one in /etc/…)

If my tools fail to set the language when the user uses the variant with the highest importance, then considering that a bug is probably correct.

@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Aug 7, 2017

Owner

Un-setting LANGUAGE inside the programs in case the user requests a certain language works fine for both mkvmerge and the GUI. I consider this fixed now.

Owner

mbunkus commented Aug 7, 2017

Un-setting LANGUAGE inside the programs in case the user requests a certain language works fine for both mkvmerge and the GUI. I consider this fixed now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.