diff options
-rw-r--r-- | .github/workflows/android.yml | 2 | ||||
-rw-r--r-- | android/app/build.gradle | 11 | ||||
-rw-r--r-- | android/native/jni/Android.mk | 9 | ||||
-rw-r--r-- | src/gettext.cpp | 4 | ||||
-rw-r--r-- | src/gui/modalMenu.cpp | 2 | ||||
-rw-r--r-- | src/porting_android.cpp | 1 |
6 files changed, 23 insertions, 6 deletions
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 47ab64d11..660b5c8df 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -28,6 +28,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 + - name: Install deps + run: sudo apt-get update; sudo apt-get install -y --no-install-recommends gettext - name: Build with Gradle run: cd android; ./gradlew assemblerelease - name: Save armeabi artifact diff --git a/android/app/build.gradle b/android/app/build.gradle index b7d93ef0f..53fe85910 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -76,10 +76,13 @@ task prepareAssets() { copy { from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}" } - /*copy { - // ToDo: fix broken locales - from "${projRoot}/po" into "${assetsFolder}/po" - }*/ + fileTree("${projRoot}/po").include("**/*.po").forEach { poFile -> + def moPath = "${assetsFolder}/locale/${poFile.parentFile.name}/LC_MESSAGES/" + file(moPath).mkdirs() + exec { + commandLine 'msgfmt', '-o', "${moPath}/minetest.mo", poFile + } + } copy { from "${projRoot}/textures" into "${assetsFolder}/textures" } diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk index 5039f325e..f92ac1d60 100644 --- a/android/native/jni/Android.mk +++ b/android/native/jni/Android.mk @@ -48,6 +48,11 @@ LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/ include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_MODULE := GetText +LOCAL_SRC_FILES := deps/Android/GetText/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libintl.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) LOCAL_MODULE := Vorbis LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a include $(PREBUILT_STATIC_LIBRARY) @@ -64,6 +69,7 @@ LOCAL_CFLAGS += \ -DUSE_FREETYPE=1 \ -DUSE_LEVELDB=0 \ -DUSE_LUAJIT=1 \ + -DUSE_GETTEXT=1 \ -DVERSION_MAJOR=${versionMajor} \ -DVERSION_MINOR=${versionMinor} \ -DVERSION_PATCH=${versionPatch} \ @@ -89,6 +95,7 @@ LOCAL_C_INCLUDES := \ deps/Android/Freetype/include \ deps/Android/Irrlicht/include \ deps/Android/LevelDB/include \ + deps/Android/GetText/include \ deps/Android/libiconv/include \ deps/Android/libiconv/libcharset/include \ deps/Android/LuaJIT/src \ @@ -194,7 +201,7 @@ LOCAL_SRC_FILES += \ # SQLite3 LOCAL_SRC_FILES += deps/Android/sqlite/sqlite3.c -LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS) #LevelDB +LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT GetText android_native_app_glue $(PROFILER_LIBS) #LevelDB LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES diff --git a/src/gettext.cpp b/src/gettext.cpp index 6818004df..de042cf35 100644 --- a/src/gettext.cpp +++ b/src/gettext.cpp @@ -127,6 +127,10 @@ void init_gettext(const char *path, const std::string &configured_language, // Add user specified locale to environment setenv("LANGUAGE", configured_language.c_str(), 1); +#ifdef __ANDROID__ + setenv("LANG", configured_language.c_str(), 1); +#endif + // Reload locale with changed environment setlocale(LC_ALL, ""); #elif defined(_MSC_VER) diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp index 0d3fb55f0..1016de389 100644 --- a/src/gui/modalMenu.cpp +++ b/src/gui/modalMenu.cpp @@ -268,7 +268,7 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event) std::string label = wide_to_utf8(getLabelByID(hovered->getID())); if (label.empty()) label = "text"; - message += gettext(label) + ":"; + message += strgettext(label) + ":"; // single line text input int type = 2; diff --git a/src/porting_android.cpp b/src/porting_android.cpp index f5870c174..29e95b8ca 100644 --- a/src/porting_android.cpp +++ b/src/porting_android.cpp @@ -190,6 +190,7 @@ void initializePathsAndroid() path_user = path_storage + DIR_DELIM + PROJECT_NAME_C; path_share = path_storage + DIR_DELIM + PROJECT_NAME_C; + path_locale = path_share + DIR_DELIM + "locale"; path_cache = getAndroidPath(nativeActivity, app_global->activity->clazz, mt_getAbsPath, "getCacheDir"); migrateCachePath(); |