Skip to content

Commit

Permalink
Bug 794807 - Calendar widget current month shown as (null).
Browse files Browse the repository at this point in the history
Locales need to end in UTF-8 to work right.
  • Loading branch information
jralls committed Nov 29, 2020
1 parent b0a5673 commit 4006e5a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gnucash/gnucash-core-app.cpp
Expand Up @@ -135,7 +135,7 @@ mac_find_close_country(NSString *locale_str, NSString *country_str,
NSString *this_locale, *new_locale = nil;
PWARN("Apple Locale is set to a value %s not supported"
" by the C runtime", [locale_str UTF8String]);
while ((this_locale = (NSString*)[locale_iter nextObject]))
while ((this_locale = [(NSString*)[locale_iter nextObject] stringByAppendingString: @".UTF-8"]))
if ([ [ [NSLocale componentsFromLocaleIdentifier: this_locale]
objectForKey: NSLocaleCountryCode]
isEqualToString: country_str] &&
Expand All @@ -158,7 +158,7 @@ mac_find_close_country(NSString *locale_str, NSString *country_str,
locale_str = new_locale;
else
{
locale_str = @"en_US";
locale_str = @"en_US.UTF-8";
setlocale(LC_ALL, [locale_str UTF8String]);
}
PWARN("Using %s instead.", [locale_str UTF8String]);
Expand Down Expand Up @@ -233,8 +233,9 @@ set_mac_locale()
{
lang_str = [locale objectForKey: NSLocaleLanguageCode];
country_str = [locale objectForKey: NSLocaleCountryCode];
locale_str = [ [lang_str stringByAppendingString: @"_"]
stringByAppendingString: country_str];
locale_str = [[[lang_str stringByAppendingString: @"_"]
stringByAppendingString: country_str]
stringByAppendingString: @".UTF-8"];
}
@catch (NSException *err)
{
Expand All @@ -246,7 +247,7 @@ set_mac_locale()
}
/* If we didn't get a valid current locale, the string will be just "_" */
if ([locale_str isEqualToString: @"_"])
locale_str = @"en_US";
locale_str = @"en_US.UTF-8";

lang_str = mac_convert_complex_language(lang_str);
if (!setlocale(LC_ALL, [locale_str UTF8String]))
Expand Down

0 comments on commit 4006e5a

Please sign in to comment.