X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgettext.cpp;h=85455ad3cb019785697b6b3284190b54e54ba581;hb=3be9787e64362b8a5020746220c65abbe31f8097;hp=0c0e520ca169e4322834edc5cfb647e0f92e6959;hpb=6922807fd526b9f4e9f75426e3278ee7239c1751;p=minetest.git diff --git a/src/gettext.cpp b/src/gettext.cpp index 0c0e520ca..85455ad3c 100644 --- a/src/gettext.cpp +++ b/src/gettext.cpp @@ -23,26 +23,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "gettext.h" #include "util/string.h" +#include "log.h" #if USE_GETTEXT && defined(_MSC_VER) -#include +#include #include #include #include "filesys.h" -#define setlocale(category,localename) \ - setlocale(category,MSVC_LocaleLookup(localename)) +#define setlocale(category, localename) \ + setlocale(category, MSVC_LocaleLookup(localename)) -static std::map glb_supported_locales; +static std::map glb_supported_locales; /******************************************************************************/ BOOL CALLBACK UpdateLocaleCallback(LPTSTR pStr) { char* endptr = 0; - int LOCALEID = strtol(pStr,&endptr,16); + int LOCALEID = strtol(pStr, &endptr,16); wchar_t buffer[LOCALE_NAME_MAX_LENGTH]; - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); if (GetLocaleInfoW( LOCALEID, LOCALE_SISO639LANGNAME, @@ -51,7 +52,7 @@ BOOL CALLBACK UpdateLocaleCallback(LPTSTR pStr) std::wstring name = buffer; - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); GetLocaleInfoW( LOCALEID, LOCALE_SISO3166CTRYNAME, @@ -60,7 +61,7 @@ BOOL CALLBACK UpdateLocaleCallback(LPTSTR pStr) std::wstring country = buffer; - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); GetLocaleInfoW( LOCALEID, LOCALE_SENGLISHLANGUAGENAME, @@ -95,7 +96,7 @@ const char* MSVC_LocaleLookup(const char* raw_shortname) { } if (first_use) { - EnumSystemLocalesA(UpdateLocaleCallback,LCID_SUPPORTED | LCID_ALTERNATE_SORTS); + EnumSystemLocalesA(UpdateLocaleCallback, LCID_SUPPORTED | LCID_ALTERNATE_SORTS); first_use = false; } @@ -116,9 +117,9 @@ const char* MSVC_LocaleLookup(const char* raw_shortname) { /******************************************************************************/ #ifdef _MSC_VER -void init_gettext(const char *path,std::string configured_language,int argc, char** argv) { +void init_gettext(const char *path, const std::string &configured_language, int argc, char** argv) { #else -void init_gettext(const char *path,std::string configured_language) { +void init_gettext(const char *path, const std::string &configured_language) { #endif #if USE_GETTEXT /** first try to set user override environment **/ @@ -147,8 +148,8 @@ void init_gettext(const char *path,std::string configured_language) { if (current_language_var != configured_language) { STARTUPINFO startupinfo; PROCESS_INFORMATION processinfo; - memset(&startupinfo,0,sizeof(startupinfo)); - memset(&processinfo,0,sizeof(processinfo)); + memset(&startupinfo, 0, sizeof(startupinfo)); + memset(&processinfo, 0, sizeof(processinfo)); errorstream << "MSVC localization workaround active restating minetest in new environment!" << std::endl; std::string parameters = ""; @@ -168,20 +169,20 @@ void init_gettext(const char *path,std::string configured_language) { /** users may start by short name in commandline without extention **/ std::string appname = argv[0]; - if (appname.substr(appname.length() -4) != ".exe") { + if (appname.substr(appname.length() - 4) != ".exe") { appname += ".exe"; } if (!CreateProcess(appname.c_str(), - (char*) ptr_parameters, - NULL, - NULL, - false, - DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT, - NULL, - NULL, - &startupinfo, - &processinfo)) { + (char*) ptr_parameters, + NULL, + NULL, + false, + DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT, + NULL, + NULL, + &startupinfo, + &processinfo)) { char buffer[1024]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -235,8 +236,8 @@ void init_gettext(const char *path,std::string configured_language) { #endif #endif - bindtextdomain(PROJECT_NAME, path); - textdomain(PROJECT_NAME); + bindtextdomain(PROJECT_NAME_LOWER, path); + textdomain(PROJECT_NAME_LOWER); #if defined(_WIN32) // Set character encoding for Win32 @@ -259,11 +260,8 @@ void init_gettext(const char *path,std::string configured_language) { /* no matter what locale is used we need number format to be "C" */ /* to ensure formspec parameters are evaluated correct! */ - setlocale(LC_NUMERIC,"C"); + setlocale(LC_NUMERIC, "C"); infostream << "Message locale is now set to: " - << setlocale(LC_ALL,0) << std::endl; + << setlocale(LC_ALL, 0) << std::endl; } - - -