X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgettext.cpp;h=fc7569418a9105ab3ddac30f88bad74fa5bbbddc;hb=718bcafd5174690a7731f9b04873e9a09f7a47b7;hp=62cc138aee58a12ca5014adee8bff304f737605a;hpb=2d16ebf57c0a287c96f9575e5317230b27e66288;p=minetest.git diff --git a/src/gettext.cpp b/src/gettext.cpp index 62cc138ae..fc7569418 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, @@ -202,7 +203,7 @@ void init_gettext(const char *path,std::string configured_language) { } #else errorstream << "*******************************************************" << std::endl; - errorstream << "Can't apply locale workaround for server!" << std::encl; + errorstream << "Can't apply locale workaround for server!" << std::endl; errorstream << "Expect language to be broken!" << std::endl; errorstream << "*******************************************************" << std::endl; @@ -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; } - - -