ManaPlus
Functions
gettexthelper.cpp File Reference

(986a3bf)

#include "utils/gettexthelper.h"
#include "configuration.h"
#include "client.h"
#include "logger.h"
#include "fs/virtfs/fs.h"
#include <libintl.h>
#include <locale.h>
#include "utils/env.h"
#include "debug.h"

Go to the source code of this file.

Functions

static std::string setLangEnv ()
 

Function Documentation

◆ setLangEnv()

static std::string setLangEnv ( )
static

Definition at line 55 of file gettexthelper.cpp.

56 {
57  std::string lang = config.getStringValue("lang");
58 #if defined(ENABLE_NLS) && defined(WIN32)
59  if (lang.empty())
60  lang = std::string(_nl_locale_name_default());
61 #elif defined(ENABLE_CUSTOMNLS) && defined(__native_client__)
62  if (lang.empty())
63  {
64  NaclMessageHandle *handle = naclRegisterMessageHandler(
65  "get-uilanguage");
66  naclPostMessage("get-uilanguage", "");
67  lang = naclWaitForMessage(handle);
68  }
69 #endif // defined(ENABLE_NLS) && defined(WIN32)
70 
71  if (!lang.empty())
72  {
73 #ifdef WIN32
74  putenv(const_cast<char*>(("LANG=" + lang).c_str()));
75  putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
76 #else // WIN32
77 
78  setEnv("LANG", lang.c_str());
79  setEnv("LANGUAGE", lang.c_str());
80 #endif // WIN32
81  }
82 
83  return lang;
84 }
std::string getStringValue(const std::string &key) const
Configuration config
void setEnv(const char *const name, const char *const value)
Definition: env.cpp:60

References config, Configuration::getStringValue(), and setEnv().

Referenced by GettextHelper::initLang().