From 052bb24c7f03e5542be2b8c2a14662fcbf928a42 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Wed, 20 Jul 2011 16:51:19 +0200 Subject: added gettext support german translation file and bashscript to update translations --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 698c5fc71..1cc479d65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -401,6 +401,8 @@ Doing currently: #include "keycode.h" #include "tile.h" +#include "gettext.h" + // This makes textures ITextureSource *g_texturesource = NULL; @@ -1058,6 +1060,9 @@ int main(int argc, char *argv[]) std::locale::global(std::locale("C")); // This enables printing all characters in bitmap font setlocale(LC_CTYPE, "en_US"); + setlocale(LC_ALL, ""); + bindtextdomain("minetest-c55", "./../locale"); + textdomain("minetest-c55"); /* Parse command line -- cgit v1.2.3 From 3fb5b7a3bd95eb6327c6894072739a7c28c711ce Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 9 Jun 2011 22:31:40 +0200 Subject: Set the window caption for the initial window too --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1cc479d65..7d0ea12ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1350,6 +1350,9 @@ int main(int argc, char *argv[]) // Set device in game parameters device = device; + + // Set the window caption + device->setWindowCaption(L"Minetest [Main Menu]"); // Create time getter g_timegetter = new IrrlichtTimeGetter(device); -- cgit v1.2.3 From 4d43a674190767cd85288b48737f97e94854e6f4 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Wed, 20 Jul 2011 18:49:18 +0200 Subject: fixed problem with wront paths in gettext --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1cc479d65..00248a203 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1060,10 +1060,6 @@ int main(int argc, char *argv[]) std::locale::global(std::locale("C")); // This enables printing all characters in bitmap font setlocale(LC_CTYPE, "en_US"); - setlocale(LC_ALL, ""); - bindtextdomain("minetest-c55", "./../locale"); - textdomain("minetest-c55"); - /* Parse command line */ @@ -1135,6 +1131,10 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); + + setlocale(LC_ALL, ""); + bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); + textdomain("minetest-c55"); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3 From a09660dc85a6dd6eed83f72a85bacd62f1d9eb1a Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Fri, 22 Jul 2011 12:54:07 +0200 Subject: fixed problem with displaying special chars --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b6a53566e..a7634a3c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1132,7 +1132,7 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); - setlocale(LC_ALL, ""); + setlocale(LC_MESSAGES, ""); bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); textdomain("minetest-c55"); -- cgit v1.2.3 From fb4c3ab4fbd29498a72a488199be58ead7505cc7 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Fri, 22 Jul 2011 20:19:43 +0200 Subject: fixed some problems with filenames of the translations --- src/CMakeLists.txt | 2 +- src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc9dc03a6..c93762cab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -330,7 +330,7 @@ if (USE_GETTEXT) COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} COMMENT "mo-update [${LOCALE}]: Creating locale directory.") - set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + set(MO_FILE_PATH "${MO_BUILD_PATH}/minetest.mo") add_custom_command( OUTPUT ${MO_FILE_PATH} diff --git a/src/main.cpp b/src/main.cpp index a7634a3c1..b94d0c361 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1133,8 +1133,8 @@ int main(int argc, char *argv[]) fs::CreateDir(porting::path_userdata); setlocale(LC_MESSAGES, ""); - bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); - textdomain("minetest-c55"); + bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str()); + textdomain("minetest"); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3 From f6d9bcc9bb020f79f73bc2cf0187f73a6d1d9275 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Sat, 23 Jul 2011 22:36:11 +0200 Subject: updated cmakerules to autodetect if gettext can be used fixed error if gettext is disabled --- cmake/Modules/FindGettextLib.cmake | 3 +++ src/CMakeLists.txt | 31 ++++++++++++++----------------- src/gettext.h | 6 ++++++ src/main.cpp | 4 +++- 4 files changed, 26 insertions(+), 18 deletions(-) (limited to 'src/main.cpp') diff --git a/cmake/Modules/FindGettextLib.cmake b/cmake/Modules/FindGettextLib.cmake index b99fd33b8..1c36f8c6e 100644 --- a/cmake/Modules/FindGettextLib.cmake +++ b/cmake/Modules/FindGettextLib.cmake @@ -77,4 +77,7 @@ IF(GETTEXT_FOUND) STRING(REPLACE "" ${_locale} ${_buildvar} ${GETTEXT_MO_BUILD_PATH}) STRING(REPLACE "" ${_locale} ${_destvar} ${GETTEXT_MO_DEST_PATH}) ENDMACRO(SET_MO_PATHS) +ELSE() + SET(GETTEXT_INCLUDE_DIR "") + SET(GETTEXT_LIBRARY "") ENDIF() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c93762cab..5554ec448 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,10 +5,11 @@ if(RUN_IN_PLACE) add_definitions ( -DRUN_IN_PLACE ) endif(RUN_IN_PLACE) -OPTION(USE_GETTEXT "Use GetText for internationalization" OFF) +OPTION(USE_GETTEXT "Use GetText for internationalization" ON) -if(USE_GETTEXT) - find_package(GettextLib REQUIRED) +find_package(GettextLib) + +if(GETTEXT_FOUND AND USE_GETTEXT) message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") if(WIN32) @@ -16,16 +17,12 @@ if(USE_GETTEXT) message(STATUS "gettext dll: ${GETTEXT_DLL}") message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") endif() - if (GETTEXT_FOUND) - add_definitions( -DUSE_GETTEXT ) - message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") - else() - message(STATUS "ERROR: GetText enabled but not found, disabling") - set(USE_GETTEXT FALSE) - endif(GETTEXT_FOUND) -else(USE_GETTEXT) + message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") +elseif(GETTEXT_FOUND AND NOT USE_GETTEXT) + MESSAGE(STATUS "GetText found but disabled;") +else(GETTEXT_FOUND AND USE_GETTEXT) message(STATUS "GetText disabled") -endif(USE_GETTEXT) +endif(GETTEXT_FOUND AND USE_GETTEXT) if(NOT MSVC) set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++") @@ -268,7 +265,7 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) - if (USE_GETTEXT) + if(GETTEXT_FOUND AND USE_GETTEXT) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") @@ -283,14 +280,14 @@ if(BUILD_CLIENT) if(DEFINED ZLIB_DLL) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() - if(USE_GETTEXT) + if(GETTEXT_FOUND AND USE_GETTEXT) if(DEFINED GETTEXT_DLL) install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR}) endif() if(DEFINED GETTEXT_ICONV_DLL) install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR}) endif() - endif(USE_GETTEXT) + endif(GETTEXT_FOUND AND USE_GETTEXT) endif() endif(BUILD_CLIENT) @@ -298,7 +295,7 @@ if(BUILD_SERVER) install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR}) endif(BUILD_SERVER) -if (USE_GETTEXT) +if (GETTEXT_FOUND AND USE_GETTEXT) add_custom_command(OUTPUT "${GETTEXT_PO_PATH}/en" COMMAND ${CMAKE_COMMAND} -E make_directory "${GETTEXT_PO_PATH}/en" COMMENT "po-update [en]: creating translation template base directory") @@ -347,7 +344,7 @@ if (USE_GETTEXT) add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) add_custom_target(updatepo COMMENT "po update" DEPENDS ${PO_FILES}) -endif(USE_GETTEXT) +endif(GETTEXT_FOUND AND USE_GETTEXT) # Subdirectories diff --git a/src/gettext.h b/src/gettext.h index 8ddb95346..e74b4eb96 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -1,3 +1,4 @@ +#ifdef GETTEXT_FOUND #ifdef USE_GETTEXT #include #else @@ -5,6 +6,11 @@ #define bindtextdomain(domain, dir) /* */ #define textdomain(domain) /* */ #endif +#else +#define gettext(String) String +#define bindtextdomain(domain, dir) /* */ +#define textdomain(domain) /* */ +#endif #define _(String) gettext(String) #define gettext_noop(String) String diff --git a/src/main.cpp b/src/main.cpp index b94d0c361..11941a43f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1132,10 +1132,12 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); +#ifdef LC_MESSAGES setlocale(LC_MESSAGES, ""); bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str()); textdomain("minetest"); - +#endif + // Initialize debug streams #ifdef RUN_IN_PLACE std::string debugfile = DEBUGFILE; -- cgit v1.2.3 From d4e7faca219ca2d9d84b02e46d591799afed32d8 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 23 Jul 2011 15:49:06 +0200 Subject: Gettext domain should match the project name This partially reverts 023cc0d37776976b4b192b7363f73a5d2debdef6, goes back to using PROJECT_NAME for the filename and also uses PROJECT_NAME as text domain in the source code. --- src/CMakeLists.txt | 2 +- src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5554ec448..6daf9385c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -327,7 +327,7 @@ if (GETTEXT_FOUND AND USE_GETTEXT) COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} COMMENT "mo-update [${LOCALE}]: Creating locale directory.") - set(MO_FILE_PATH "${MO_BUILD_PATH}/minetest.mo") + set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") add_custom_command( OUTPUT ${MO_FILE_PATH} diff --git a/src/main.cpp b/src/main.cpp index 11941a43f..2f48d229f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1134,8 +1134,8 @@ int main(int argc, char *argv[]) #ifdef LC_MESSAGES setlocale(LC_MESSAGES, ""); - bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str()); - textdomain("minetest"); + bindtextdomain(PROJECT_NAME, (porting::path_userdata+"/locale").c_str()); + textdomain(PROJECT_NAME); #endif // Initialize debug streams -- cgit v1.2.3 From c578efb32b57b08275b9a0a2fd4a76b4e4b9e87d Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 23 Jul 2011 16:38:37 +0200 Subject: Refactor gettext init Put the gettext init code in a macro and define it appropriately depending on whether gettext is actually available or not. --- src/gettext.h | 18 +++++++++--------- src/main.cpp | 6 +----- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src/main.cpp') diff --git a/src/gettext.h b/src/gettext.h index e74b4eb96..751b83774 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -1,21 +1,21 @@ -#ifdef GETTEXT_FOUND -#ifdef USE_GETTEXT +#if defined(GETTEXT_FOUND) && defined(USE_GETTEXT) #include #else #define gettext(String) String -#define bindtextdomain(domain, dir) /* */ -#define textdomain(domain) /* */ -#endif -#else -#define gettext(String) String -#define bindtextdomain(domain, dir) /* */ -#define textdomain(domain) /* */ #endif #define _(String) gettext(String) #define gettext_noop(String) String #define N_(String) gettext_noop (String) +inline void init_gettext(const char *path) { +#if USE_GETTEXT + setlocale(LC_MESSAGES, ""); + bindtextdomain(PROJECT_NAME, path); + textdomain(PROJECT_NAME); +#endif +} + inline wchar_t* chartowchar_t(const char *str) { size_t l = strlen(str)+1; diff --git a/src/main.cpp b/src/main.cpp index 2f48d229f..bdfbc35f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1132,11 +1132,7 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); -#ifdef LC_MESSAGES - setlocale(LC_MESSAGES, ""); - bindtextdomain(PROJECT_NAME, (porting::path_userdata+"/locale").c_str()); - textdomain(PROJECT_NAME); -#endif + init_gettext((porting::path_userdata+"/locale").c_str()); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3 From 423109e64c9e723f9f2a52e3537892f584383865 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 24 Jul 2011 18:12:11 +0200 Subject: Two more instances of unhardcoding the project name --- src/main.cpp | 2 +- src/servermain.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index bdfbc35f7..0001d33ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1153,7 +1153,7 @@ int main(int argc, char *argv[]) BEGIN_DEBUG_EXCEPTION_HANDLER // Print startup message - dstream< Date: Sun, 24 Jul 2011 19:20:40 +0200 Subject: Locale dir should be parallel to global data dir --- cmake/Modules/FindGettextLib.cmake | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/cmake/Modules/FindGettextLib.cmake b/cmake/Modules/FindGettextLib.cmake index a215f3f8d..18935eaad 100644 --- a/cmake/Modules/FindGettextLib.cmake +++ b/cmake/Modules/FindGettextLib.cmake @@ -56,7 +56,7 @@ ENDIF() IF(GETTEXT_FOUND) SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po) SET(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale//LC_MESSAGES) - SET(GETTEXT_MO_DEST_PATH locale//LC_MESSAGES) + SET(GETTEXT_MO_DEST_PATH ${DATADIR}/../locale//LC_MESSAGES) FILE(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*") LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot) MACRO(SET_MO_PATHS _buildvar _destvar _locale) diff --git a/src/main.cpp b/src/main.cpp index 0001d33ec..bcca60d95 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1132,7 +1132,7 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); - init_gettext((porting::path_userdata+"/locale").c_str()); + init_gettext((porting::path_data+"/../locale").c_str()); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3