Update Locale
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef LIME_SYSTEM_LOCALE_H
|
||||
#define LIME_SYSTEM_LOCALE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
@@ -10,7 +12,7 @@ namespace lime {
|
||||
|
||||
public:
|
||||
|
||||
static char* GetSystemLocale ();
|
||||
static std::string* GetSystemLocale ();
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1033,21 +1033,19 @@ namespace lime {
|
||||
|
||||
value lime_locale_get_system_locale () {
|
||||
|
||||
return alloc_null ();
|
||||
std::string* locale = Locale::GetSystemLocale ();
|
||||
|
||||
//char* locale = Locale::GetSystemLocale ();
|
||||
//
|
||||
//if (!locale) {
|
||||
//
|
||||
//return alloc_null ();
|
||||
//
|
||||
//} else {
|
||||
//
|
||||
//value result = alloc_string (locale);
|
||||
//free (locale);
|
||||
//return result;
|
||||
//
|
||||
//}
|
||||
if (!locale) {
|
||||
|
||||
return alloc_null ();
|
||||
|
||||
} else {
|
||||
|
||||
value result = alloc_string (locale->c_str ());
|
||||
delete locale;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
char* Locale::GetSystemLocale () {
|
||||
std::string* Locale::GetSystemLocale () {
|
||||
|
||||
#if defined(HX_WINDOWS)
|
||||
|
||||
char locale[8];
|
||||
int length = GetLocaleInfo (GetSystemDefaultUILanguage (), LOCALE_SISO639LANGNAME, locale, sizeof (locale));
|
||||
char *result = (char*)malloc (length + 1);
|
||||
strcpy (result, locale);
|
||||
std::string* result = new std::string (locale);
|
||||
return result;
|
||||
|
||||
#elif defined(HX_LINUX)
|
||||
@@ -34,9 +33,7 @@ namespace lime {
|
||||
|
||||
if (locale) {
|
||||
|
||||
char *result = (char*)malloc (sizeof (locale));
|
||||
strcpy (result, locale);
|
||||
|
||||
std::string* result = new std::string (locale);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,20 +10,19 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
char* Locale::GetSystemLocale () {
|
||||
std::string* Locale::GetSystemLocale () {
|
||||
|
||||
#ifndef OBJC_ARC
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
#endif
|
||||
|
||||
NSString* locale = [[NSLocale currentLocale] localeIdentifier];
|
||||
char* result = 0;
|
||||
std::string* result = 0;
|
||||
|
||||
if (locale) {
|
||||
|
||||
const char* ptr = [locale UTF8String];
|
||||
result = (char*)malloc ([locale length] + 1);
|
||||
strncpy (result, ptr, [locale length]);
|
||||
result = new std::string (ptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user