- See also
- TestI18n.cpp
#pragma once
#include <string>
#if defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h>
#elif defined(__unix__) || defined(__linux__)
#include <locale>
#endif
#if defined(__APPLE__)
CFLocaleRef locale = CFLocaleCopyCurrent();
if (!locale)
return "en";
CFStringRef identifier = (CFStringRef)CFLocaleGetValue(locale, kCFLocaleIdentifier);
char buffer[16] = {0};
if (CFStringGetCString(identifier, buffer, sizeof(buffer), kCFStringEncodingUTF8)) {
CFRelease(locale);
return std::string(buffer, 2);
}
CFRelease(locale);
#elif defined(__unix__) || defined(__linux__)
try {
std::locale loc("");
std::string name = loc.name();
if (!name.empty() && name != "C" && name != "POSIX")
return name.substr(0, 2);
} catch (...) {}
#endif
return "en";
}
std::string getSystemCode()
Definition SystemCode.hpp:23