The International Simutrans Forum

 

Author Topic: [Android] restore language selection at 1st run  (Read 340 times)

0 Members and 1 Guest are viewing this topic.

Offline krosk

  • *
  • Posts: 38
  • Languages: EN,FR,ZH
[Android] restore language selection at 1st run
« on: August 23, 2021, 03:00:06 PM »
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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10979
  • Languages: De,EN,JP
Re: [Android] restore language selection at 1st run
« Reply #1 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:
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.