Setting envvar LANG to correct value from Java code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include "SDL_thread.h"
|
||||
@@ -57,6 +58,17 @@ JAVA_EXPORT_NAME(Settings_nativeIsSdcardUsed) ( JNIEnv* env, jobject thiz, jint
|
||||
isSdcardUsed = flag;
|
||||
}
|
||||
|
||||
extern C_LINKAGE void
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
|
||||
{
|
||||
jboolean iscopy;
|
||||
const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy);
|
||||
const char *value = (*env)->GetStringUTFChars(env, j_value, &iscopy);
|
||||
setenv(name, value, 1);
|
||||
(*env)->ReleaseStringUTFChars(env, j_name, name);
|
||||
(*env)->ReleaseStringUTFChars(env, j_value, value);
|
||||
}
|
||||
|
||||
#undef JAVA_EXPORT_NAME
|
||||
#undef JAVA_EXPORT_NAME1
|
||||
#undef JAVA_EXPORT_NAME2
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
|
||||
class Settings
|
||||
{
|
||||
@@ -177,6 +178,12 @@ class Settings
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard(0, 4);
|
||||
}
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
System.out.println( "libSDL: setting envvar LANG to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
}
|
||||
|
||||
static void startDownloader(MainActivity p)
|
||||
@@ -202,5 +209,6 @@ class Settings
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int nbuttons);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user