#include <stdlib.h>
#include "gettext.h"
#include "util/string.h"
+#include "log.h"
#if USE_GETTEXT && defined(_MSC_VER)
-#include <WinNls.h>
+#include <windows.h>
#include <map>
#include <direct.h>
#include "filesys.h"
-#define setlocale(category,localename) \
- setlocale(category,MSVC_LocaleLookup(localename))
+#define setlocale(category, localename) \
+ setlocale(category, MSVC_LocaleLookup(localename))
-static std::map<std::wstring,std::wstring> glb_supported_locales;
+static std::map<std::wstring, std::wstring> 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,
std::wstring name = buffer;
- memset(buffer,0,sizeof(buffer));
+ memset(buffer, 0, sizeof(buffer));
GetLocaleInfoW(
LOCALEID,
LOCALE_SISO3166CTRYNAME,
std::wstring country = buffer;
- memset(buffer,0,sizeof(buffer));
+ memset(buffer, 0, sizeof(buffer));
GetLocaleInfoW(
LOCALEID,
LOCALE_SENGLISHLANGUAGENAME,
}
if (first_use) {
- EnumSystemLocalesA(UpdateLocaleCallback,LCID_SUPPORTED | LCID_ALTERNATE_SORTS);
+ EnumSystemLocalesA(UpdateLocaleCallback, LCID_SUPPORTED | LCID_ALTERNATE_SORTS);
first_use = false;
}
/******************************************************************************/
#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 **/
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 = "";
/** 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,
#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
/* 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;
}
-
-
-