diff --git a/CMakeLists.txt b/CMakeLists.txt index bbcb5b630..40c236a34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1176,17 +1176,6 @@ else() add_executable(furnace ${USED_SOURCES}) endif() -if (WITH_LOCALE) - set(FURNACE_LANGUAGES de es fr fi hy ko nl pl pt_BR ru sk sv th tr uk) - set(FURNACE_LANGUAGE_DEPENDS "") - - foreach(I IN LISTS FURNACE_LANGUAGES) - add_custom_command(OUTPUT "locale/${I}/LC_MESSAGES/furnace.mo" COMMAND mkdir -p "${CMAKE_BINARY_DIR}/locale/${I}/LC_MESSAGES/" COMMAND msgfmt ${CMAKE_SOURCE_DIR}/po/${I}.po -o "${CMAKE_BINARY_DIR}/locale/${I}/LC_MESSAGES/furnace.mo" DEPENDS po/${I}.po WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - list(APPEND FURNACE_LANGUAGE_DEPENDS "locale/${I}/LC_MESSAGES/furnace.mo") - endforeach() - add_custom_target(furnace-locale ALL DEPENDS ${FURNACE_LANGUAGE_DEPENDS}) -endif() - target_include_directories(furnace SYSTEM PRIVATE ${DEPENDENCIES_INCLUDE_DIRS}) target_compile_options(furnace PRIVATE ${DEPENDENCIES_COMPILE_OPTIONS}) target_link_libraries(furnace PRIVATE ${DEPENDENCIES_LIBRARIES}) diff --git a/android/app/build.gradle b/android/app/build.gradle index 646701c5a..7ff21893a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,7 +19,7 @@ android { versionName "0.6.3" externalNativeBuild { cmake { - arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DWARNINGS_ARE_ERRORS=ON" + arguments "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DWARNINGS_ARE_ERRORS=ON", "-DWITH_LOCALE=ON", "-DUSE_MOMO=ON" // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' abiFilters 'arm64-v8a' } diff --git a/android/app/src/main/assets/locale b/android/app/src/main/assets/locale new file mode 120000 index 000000000..c8da044c2 --- /dev/null +++ b/android/app/src/main/assets/locale @@ -0,0 +1 @@ +../../../../../po/locale \ No newline at end of file diff --git a/po/locale/de/LC_MESSAGES/furnace.mo b/po/locale/de/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..4645dd2b8 Binary files /dev/null and b/po/locale/de/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/es/LC_MESSAGES/furnace.mo b/po/locale/es/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..4cf6cbb0e Binary files /dev/null and b/po/locale/es/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/fi/LC_MESSAGES/furnace.mo b/po/locale/fi/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..0108c0dca Binary files /dev/null and b/po/locale/fi/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/fr/LC_MESSAGES/furnace.mo b/po/locale/fr/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..53afcc0a7 Binary files /dev/null and b/po/locale/fr/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/hy/LC_MESSAGES/furnace.mo b/po/locale/hy/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..cf38ee528 Binary files /dev/null and b/po/locale/hy/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/ko/LC_MESSAGES/furnace.mo b/po/locale/ko/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..97297f47f Binary files /dev/null and b/po/locale/ko/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/nl/LC_MESSAGES/furnace.mo b/po/locale/nl/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..e348aa901 Binary files /dev/null and b/po/locale/nl/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/pl/LC_MESSAGES/furnace.mo b/po/locale/pl/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..7290aa248 Binary files /dev/null and b/po/locale/pl/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/pt_BR/LC_MESSAGES/furnace.mo b/po/locale/pt_BR/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..e6a48eed7 Binary files /dev/null and b/po/locale/pt_BR/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/ru/LC_MESSAGES/furnace.mo b/po/locale/ru/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..a13a62644 Binary files /dev/null and b/po/locale/ru/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/sk/LC_MESSAGES/furnace.mo b/po/locale/sk/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..98936155b Binary files /dev/null and b/po/locale/sk/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/sv/LC_MESSAGES/furnace.mo b/po/locale/sv/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..c7dc449d2 Binary files /dev/null and b/po/locale/sv/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/th/LC_MESSAGES/furnace.mo b/po/locale/th/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..0fe7ee229 Binary files /dev/null and b/po/locale/th/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/tr/LC_MESSAGES/furnace.mo b/po/locale/tr/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..344091c55 Binary files /dev/null and b/po/locale/tr/LC_MESSAGES/furnace.mo differ diff --git a/po/locale/uk/LC_MESSAGES/furnace.mo b/po/locale/uk/LC_MESSAGES/furnace.mo new file mode 100644 index 000000000..c64061179 Binary files /dev/null and b/po/locale/uk/LC_MESSAGES/furnace.mo differ diff --git a/scripts/build-po.sh b/scripts/build-po.sh new file mode 100755 index 000000000..8ccddafa3 --- /dev/null +++ b/scripts/build-po.sh @@ -0,0 +1,7 @@ +#!/bin/sh +EXPORT_LANGS=("de" "es" "fr" "fi" "hy" "ko" "nl" "pl" "pt_BR" "ru" "sk" "sv" "th" "tr" "uk") + +for i in ${EXPORT_LANGS[@]}; do + echo "compiling $i.po..." + mkdir -p "po/locale/$i/LC_MESSAGES/" && msgfmt "po/$i.po" -o "po/locale/$i/LC_MESSAGES/furnace.mo" +done diff --git a/src/main.cpp b/src/main.cpp index e24d7a147..85bbebb75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,13 @@ struct sigaction termsa; #define TA_TEXTDOMAIN textdomain #endif +#ifndef LC_CTYPE +#define LC_CTYPE 0 +#endif +#ifndef LC_MESSAGES +#define LC_MESSAGES 1 +#endif + #include "cli/cli.h" #ifdef HAVE_GUI @@ -501,12 +508,12 @@ int main(int argc, char** argv) { #ifdef HAVE_LOCALE const char* localeRet=NULL; - if ((localeRet=TA_SETLOCALE(LC_CTYPE,""))==NULL) { + if ((localeRet=TA_SETLOCALE(LC_CTYPE,"pt_BR"))==NULL) { logE("could not set locale (CTYPE)!"); } else { logV("locale: %s",localeRet); } - if ((localeRet=TA_SETLOCALE(LC_MESSAGES,""))==NULL) { + if ((localeRet=TA_SETLOCALE(LC_MESSAGES,"pt_BR"))==NULL) { logE("could not set locale (MESSAGES)!"); } else { logV("locale: %s",localeRet); diff --git a/src/momo/momo.c b/src/momo/momo.c index 5125f57cc..477c4f383 100644 --- a/src/momo/momo.c +++ b/src/momo/momo.c @@ -24,7 +24,7 @@ #include #include #include -#include "libintl.h" +#include "momo.h" static char curLocale[64]; static char tempPath[4096]; diff --git a/src/momo/momo.h b/src/momo/momo.h index 3c64098bd..1f72ad638 100644 --- a/src/momo/momo.h +++ b/src/momo/momo.h @@ -24,11 +24,13 @@ extern "C" { #endif +#define MOMO_FORMATARG __attribute__((format_arg(1))) + const char* momo_setlocale(int type, const char* locale); const char* momo_bindtextdomain(const char* domainName, const char* dirName); const char* momo_textdomain(const char* domainName); -const char* momo_gettext(const char* str); +const char* momo_gettext(const char* str) MOMO_FORMATARG; const char* momo_ngettext(const char* str1, const char* str2, unsigned long amount); #ifdef __cplusplus