News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

[Android] restore language selection at 1st run

Started by krosk, August 23, 2021, 03:00:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

krosk

Hello,

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 https://github.com/krosk/simutrans/commit/70f1ce2b26d6e1bc3f1aad63afb91b2a37a64f01), 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

prissi

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:
https://stackoverflow.com/questions/12900695/how-to-obtain-jni-interface-pointer-jnienv-for-asynchronous-calls
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.