forked from Mirrorlandia_minetest/minetest
Gettext support on Android (#11435)
Co-authored-by: sfan5 <sfan5@live.de> Co-authored-by: =?UTF-8?q?Olivier=20Samyn=20=F0=9F=8E=BB?= <code@oleastre.be>
This commit is contained in:
parent
4a3728d828
commit
c6eddb0bae
2
.github/workflows/android.yml
vendored
2
.github/workflows/android.yml
vendored
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -47,6 +47,11 @@ LOCAL_MODULE := OpenAL
|
||||
LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a
|
||||
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
|
||||
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user