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