rfvgyhn / min-ed-launcher

Minimal Elite Dangerous Launcher
MIT License
267 stars 10 forks source link

Linux: default language is set to English instead of system locale #12

Closed infoman closed 3 years ago

infoman commented 3 years ago

When config language is set to null, the game is run with /language English\\UK parameter despite having LANG=ru_RU.UTF-8 environment variable set

rfvgyhn commented 3 years ago

The default culture is determined by the ICU uloc_getDefault function. Looking at the docs, it looks like there are env vars with a higher precedence than LANG. Do you perhaps have something set in LC_ALL or LC_MESSAGES?

Also, which distro and kernel version are you running?

infoman commented 3 years ago

I'm on Ubuntu 18.04 with kernel 5.4.0-66-generic

I looked at the environment of the launcher by doing strings /proc/pid/environ and apparently Steam somewhere sets LC_ALL=C, but I can't find the source of it

rfvgyhn commented 3 years ago

Do you also see HOST_LC_ALL set? It looks like steam sets LC_ALL=C to help some games run but it might also set HOST_LC_ALL. What output do you get when you run locale?

Turns out that Proton has a block that handles this. I imagine if I implement the same thing, it should fix this issue. I'll update the issue when I've pushed a new build for you to try.

    def init_wine(self):
        if "HOST_LC_ALL" in self.env and len(self.env["HOST_LC_ALL"]) > 0:
            #steam sets LC_ALL=C to help some games, but Wine requires the real value
            #in order to do path conversion between win32 and host. steam sets
            #HOST_LC_ALL to allow us to use the real value.
            self.env["LC_ALL"] = self.env["HOST_LC_ALL"]
        else:
            self.env.pop("LC_ALL", "")
infoman commented 3 years ago

Do you also see HOST_LC_ALL set?

No

$ grep LC /tmp/steam.env 
LC_ALL=C
$ grep LANG /tmp/steam.env 
LANGUAGE=
LANG=ru_RU.UTF-8
$ locale
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
rfvgyhn commented 3 years ago

I wasn't able to get HOST_LC_ALL to be set on my machine either which means I can't know what the original LC_ALL value is. I'm wondering if that proton comment is out of date.

The fix for this is to set LC_ALL to the correct value in the game's launch options within steam (or set language in settings.json). e.g. LC_ALL=ru_RU.UTF-8 alacritty -e ./MinEdLauncher %command% /autoquit /EDH. I'll add this info to the readme.

infoman commented 3 years ago

Strangely enough, that LC_ALL variable gets lost somewhere and the actual game process doesn't have it set

rfvgyhn commented 3 years ago

Well, I had a typo when looking for HOST_LC_ALL. It looks like steam sets HOST_LC_ALL if LC_ALL is set. I should be able to implement the same fix that proton uses to get the correct game language.

rfvgyhn commented 3 years ago

Fixed in 7638b3250b3a3be972596f2d7983afcd1f094cb7. LC_ALL will be used if it's set on the system, otherwise, LANG should be used. You can use the CI build if you'd like to try it.