diff options
Diffstat (limited to 'intern/locale/osx_user_locale.mm')
-rw-r--r-- | intern/locale/osx_user_locale.mm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/locale/osx_user_locale.mm b/intern/locale/osx_user_locale.mm new file mode 100644 index 00000000000..1ed33bb1713 --- /dev/null +++ b/intern/locale/osx_user_locale.mm @@ -0,0 +1,22 @@ +#include "boost_locale_wrapper.h" + +#import <Cocoa/Cocoa.h> + +#include <cstdlib> + +static char* user_locale = NULL; + +// get current locale +const char* osx_user_locale() +{ + ::free(user_locale); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + CFLocaleRef myCFLocale = CFLocaleCopyCurrent(); + NSLocale * myNSLocale = (NSLocale *) myCFLocale; + [myNSLocale autorelease]; + NSString *nsIdentifier = [myNSLocale localeIdentifier]; + user_locale = ::strdup([nsIdentifier UTF8String]); + [pool drain]; + + return user_locale; +} |