mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #4318: Use user locale on macOS
This commit is contained in:
parent
676c734f4c
commit
2c89d30f26
|
@ -148,6 +148,34 @@ void platform_posix_sub_resolve_openrct_data_path(utf8 *out) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_currency(){
|
||||
char *langstring = setlocale(LC_MONETARY, "");
|
||||
|
||||
if (langstring == NULL) {
|
||||
return platform_get_currency_value(NULL);
|
||||
}
|
||||
|
||||
struct lconv *lc = localeconv();
|
||||
|
||||
return platform_get_currency_value(lc->int_curr_symbol);
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_measurement_format(){
|
||||
// LC_MEASUREMENT is GNU specific.
|
||||
#ifdef LC_MEASUREMENT
|
||||
const char *langstring = setlocale(LC_MEASUREMENT, "");
|
||||
#else
|
||||
const char *langstring = setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
if(langstring != NULL){
|
||||
//using https://en.wikipedia.org/wiki/Metrication#Chronology_and_status_of_conversion_by_country as reference
|
||||
if(!fnmatch("*_US*", langstring, 0) || !fnmatch("*_MM*", langstring, 0) || !fnmatch("*_LR*", langstring, 0)){
|
||||
return MEASUREMENT_FORMAT_IMPERIAL;
|
||||
}
|
||||
}
|
||||
return MEASUREMENT_FORMAT_METRIC;
|
||||
}
|
||||
|
||||
static void execute_cmd(char *command, int *exit_value, char *buf, size_t *buf_size) {
|
||||
FILE *f;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <mach-o/dyld.h>
|
||||
#include "platform.h"
|
||||
#include "../util/util.h"
|
||||
#include "config.h"
|
||||
|
||||
bool platform_check_steam_overlay_attached() {
|
||||
STUB();
|
||||
|
@ -191,4 +192,27 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer)
|
|||
}
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_currency()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
NSString *currencyCode = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencyCode];
|
||||
return platform_get_currency_value(currencyCode.UTF8String);
|
||||
}
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_measurement_format()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
NSNumber *metricSystem = [[NSLocale currentLocale] objectForKey:NSLocaleUsesMetricSystem];
|
||||
|
||||
if (metricSystem.boolValue) {
|
||||
return MEASUREMENT_FORMAT_METRIC;
|
||||
}
|
||||
|
||||
return MEASUREMENT_FORMAT_IMPERIAL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -863,35 +863,6 @@ time_t platform_file_get_modified_time(const utf8* path){
|
|||
return 100;
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_currency(){
|
||||
char *langstring = setlocale(LC_MONETARY, "");
|
||||
|
||||
if (langstring == NULL) {
|
||||
return platform_get_currency_value(NULL);
|
||||
}
|
||||
|
||||
struct lconv *lc = localeconv();
|
||||
|
||||
return platform_get_currency_value(lc->int_curr_symbol);
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_measurement_format(){
|
||||
// LC_MEASUREMENT is GNU specific.
|
||||
#ifdef LC_MEASUREMENT
|
||||
const char *langstring = setlocale(LC_MEASUREMENT, "");
|
||||
#else
|
||||
const char *langstring = setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
if(langstring != NULL){
|
||||
//using https://en.wikipedia.org/wiki/Metrication#Chronology_and_status_of_conversion_by_country as reference
|
||||
if(!fnmatch("*_US*", langstring, 0) || !fnmatch("*_MM*", langstring, 0) || !fnmatch("*_LR*", langstring, 0)){
|
||||
return MEASUREMENT_FORMAT_IMPERIAL;
|
||||
}
|
||||
}
|
||||
return MEASUREMENT_FORMAT_METRIC;
|
||||
}
|
||||
|
||||
uint8 platform_get_locale_temperature_format(){
|
||||
// LC_MEASUREMENT is GNU specific.
|
||||
#ifdef LC_MEASUREMENT
|
||||
|
|
Loading…
Reference in New Issue