Temporarily change locale/language of the KDE application

Good evening!

I’m trying to launch, for example, KInfoCenter to be shown in English instead of my native language using this script:

LANG=en_US.UTF-8 \
   LC_ALL=en_US.UTF-8 \
   DICTIONARY=english \
   KDE_LANG=en_US.UTF-8 \
   exec "$@"

However, neither of those variables have effect on the display of the application. It is still in Russian. I googled a little and found out that there were times where KDE_LANG were effective, but it does not seem to work now.
How can I launch KDE application in a language different from my system one?

Try LANG=C /usr/bin/kinfocenter.

It works, thank you very much!

Maybe you do not need more, but please note that C is “system language” with happens to be US English.
As you report LANG=en_US.UTF-8 does not work and I thus fear that e.g. LANG =nl_NL.UTF-8, etc will also not work.

I think there is still a problem there somewhere in Plasma.

AFAICT translations are read from /usr/share/locale and /usr/share/locale/kf5 according to LANGUAGE environment variable. LANGUAGE is set to colon separated list of language codes, the first found under mentioned directory is used. If requested language does not exist, builtin default (English) is used. Note that different parts of the same application window may use different message catalogs, so LANGUAGE=[noparse]xx:pt[/noparse] kinfocenter displays some parts in English (because xx is invalid) and some parts in Portuguese.

This still requires valid locale in the first place. LANG=C effectively disables localization completely, falling back to built-in default English. Setting LANG to any non-existing locale string will have the same effect. E.g. LANG=ru is invalid (it does not exist), while LANG=ru_RU.UTF-8 works. “LANG=ru_RU.UTF-8 LANGUAGE=zh_CN kinfocenter” shows nice Chinese application :slight_smile: While LANGUAGE=zh translates only some parts of screen.

I have default locale LANG=de_DE.UTF-8 LANGUAGE=de. LANG=uk LANGUAGE=en /usr/bin/kinfocenter is same as LANG=C /usr/bin/kinfocenter.

And? What exactly do you want to say? Was it really necessary to quote my post in full just to add zero information to it?

This is explained in the “gettext” man page btw.
From “man 3 gettext”:

   If the LANGUAGE environment variable is set  to  a  nonempty  value,  and  the
   locale  is  not  the "C" locale, the value of LANGUAGE is assumed to contain a
   colon separated list of locale names. The functions will attempt to look up  a
   translation of msgid in each of the locales in turn. This is a GNU extension.

In the “C” locale, or if none of the used catalogs contain a translation for
msgid, the gettext, dgettext and dcgettext functions return msgid.

Plasma does set LANGUAGE on login if you explicitly configured the language(s) in Systemsettings->Language. That’s why LANG=en_US didn’t have any effect (but LANG=C does).

The windows opened by the two invocations have the same text.