mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-08 15:19:50 +00:00
Correct OSX locale detection.
(For me this returns en_de, not sure why, but i can see some german strings in my OSX installation here and there so this might be feasible.) Also fix typo in Network.cpp.
This commit is contained in:
parent
1f3e472551
commit
b71dc80516
2 changed files with 19 additions and 14 deletions
|
@ -103,7 +103,7 @@ protected:
|
||||||
data->fp = fopen(data->tempFilename.c_str(), "wb");
|
data->fp = fopen(data->tempFilename.c_str(), "wb");
|
||||||
if(!data->fp)
|
if(!data->fp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SOCKET: Failed to save %u bytes, file not open");
|
fprintf(stderr, "SOCKET: Failed to save %u bytes, file not open", size);
|
||||||
data->fail = true;
|
data->fail = true;
|
||||||
// TODO: and now?
|
// TODO: and now?
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -40,7 +40,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BBGE_BUILD_MACOSX
|
#ifdef BBGE_BUILD_MACOSX
|
||||||
#include <CFLocale.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
#include <CoreFoundation/CFLocale.h>
|
||||||
|
#include <CoreFoundation/CFString.h>
|
||||||
|
|
||||||
|
// veeery clunky.
|
||||||
|
static std::string _CFToStdString(CFStringRef cs)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
CFStringGetCString(cs, &buf[0], 2048, kCFStringEncodingUTF8);
|
||||||
|
return &buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void UserSettings::save()
|
void UserSettings::save()
|
||||||
|
@ -647,30 +658,24 @@ void UserSettings::getSystemLocale()
|
||||||
}
|
}
|
||||||
#elif BBGE_BUILD_MACOSX
|
#elif BBGE_BUILD_MACOSX
|
||||||
CFLocaleRef locale = CFLocaleCopyCurrent();
|
CFLocaleRef locale = CFLocaleCopyCurrent();
|
||||||
CFTypeRef type;
|
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
|
||||||
CFStringRef buf;
|
CFStringRef buf;
|
||||||
|
|
||||||
type = CFLocaleGetValue(locale, kCFLocaleLanguageCode);
|
if ((buf = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleLanguageCode)) != NULL)
|
||||||
|
|
||||||
if ((buf = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleLanguageCode, type)) != NULL)
|
|
||||||
{
|
{
|
||||||
system.locale = buf;
|
system.locale = _CFToStdString(buf);
|
||||||
CFRelease(buf);
|
CFRelease(buf);
|
||||||
CFRelease(type);
|
|
||||||
|
|
||||||
type = CFLocaleGetValue(locale, kCFLocaleCountryCode);
|
if ((buf = (CFStringRef)CFArrayGetValueAtIndex(langs, 0)) != NULL)
|
||||||
|
|
||||||
if ((buf = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleCountryCode, type)) != NULL)
|
|
||||||
{
|
{
|
||||||
system.locale += "_";
|
system.locale += "_";
|
||||||
system.locale += buf;
|
system.locale += _CFToStdString(buf);
|
||||||
CFRelease(buf);
|
CFRelease(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(locale);
|
CFRelease(locale);
|
||||||
|
CFRelease(langs);
|
||||||
#else
|
#else
|
||||||
const char *lang = (const char *)getenv("LANG");
|
const char *lang = (const char *)getenv("LANG");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue