(Android) Added localization support

This commit is contained in:
Leon Styhre 2024-07-02 18:04:42 +02:00
parent 302305b3ee
commit 63729cce19
2 changed files with 9 additions and 1 deletions

View file

@ -498,6 +498,7 @@ elseif(ANDROID)
${CMAKE_CURRENT_SOURCE_DIR}/external/ffmpeg-kit/src/ffmpeg
${CMAKE_CURRENT_SOURCE_DIR}/external/freeimage/FreeImage/Source
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype/include
${CMAKE_CURRENT_SOURCE_DIR}/external/gettext/gettext-runtime/intl
${CMAKE_CURRENT_SOURCE_DIR}/external/libgit2/include
${CMAKE_CURRENT_SOURCE_DIR}/external/pugixml/src
${CMAKE_CURRENT_SOURCE_DIR}/external/SDL_Android)
@ -580,6 +581,7 @@ elseif(ANDROID)
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreeimage.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreetype.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libgit2.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libintl.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libjpeg.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libpoppler.so
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libpugixml.a

View file

@ -70,8 +70,13 @@ namespace Utils
}
// No need to perform translations if we're using the default language.
if (locale == "en_US")
if (locale == "en_US") {
setenv("LANGUAGE", locale.c_str(), 1);
setenv("LANG", locale.c_str(), 1);
setlocale(LC_MESSAGES, std::string {locale + ".UTF-8"}.c_str());
textdomain(locale.c_str());
return;
}
std::string localePath;
localePath.append("/")
@ -97,6 +102,7 @@ namespace Utils
SetThreadLocale(localeID);
#else
setenv("LANGUAGE", locale.c_str(), 1);
setenv("LANG", locale.c_str(), 1);
setlocale(LC_MESSAGES, std::string {locale + ".UTF-8"}.c_str());
#endif
textdomain(locale.c_str());