The International Simutrans Forum

Development => Patches & Projects => Topic started by: krosk on August 23, 2021, 03:00:06 PM

Title: [Android] restore language selection at 1st run
Post by: krosk on August 23, 2021, 03:00:06 PM

Language selection at the first run was available in versions earlier than r9872 (the version that introduced detection of language on first start), never after that; instead, the first language of the list would be selected automatically, not following any language detection scheme. In my case it chooses the "be" language while my android phone is "en".

After some debuging, I observe that when no language is detected and we fallback to setting the language to 0 via set_language() (see, the initial ask_language() modal window is immediately skipped and never appears. I suspect the set_language function is trigerring side effects that disable the ask_language window, but I have not investigated deeper the code.

For the time being, I simply disabled the set language function for Android only.

Patch applicable to r10046
Title: Re: [Android] restore language selection at 1st run
Post by: prissi on August 24, 2021, 02:54:13 PM
That code was broken also for other platforms. Thank you, I get now the language question again.

Actually, Android has "Locale.getDefault().getLanguage();" which returns the locale. But I have no idea how to call this from C++ code. SDL2 does this, but my knowledge is too little if there is a way to call this function directly from C code. I found something here:
but since I do not have a working Android NDK for Simutrans (since this Laptop's SDD is too small to host also a Linux VM for Android builds), I did not dare to incorporate anythiing like this.