Skip to content

Commit

Permalink
fix python local weekday name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rechi committed Aug 7, 2016
1 parent ecc9bd1 commit 2542902
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions xbmc/LangInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,18 @@ void CLangInfo::CRegion::SetGlobalLocale()
// decimal separator is changed depending of the current language
// (ie. "," in French or Dutch instead of "."). This breaks atof() and
// others similar functions.
#if defined(TARGET_FREEBSD) || defined(TARGET_DARWIN_OSX) || defined(__UCLIBC__)
// on FreeBSD, darwin and uClibc-based systems libstdc++ is compiled with
// "generic" locale support
if (setlocale(LC_COLLATE, strLocale.c_str()) == NULL
|| setlocale(LC_CTYPE, strLocale.c_str()) == NULL)
{
strLocale = "C";
setlocale(LC_COLLATE, strLocale.c_str());
setlocale(LC_CTYPE, strLocale.c_str());
}
#else
#if !(defined(TARGET_FREEBSD) || defined(TARGET_DARWIN_OSX) || defined(__UCLIBC__))
// on FreeBSD, darwin and uClibc-based systems libstdc++ is compiled
// only with "generic" locale support
std::locale current_locale = std::locale::classic(); // C-Locale
try
{
std::locale lcl = std::locale(strLocale.c_str());
strLocale = lcl.name();
current_locale = current_locale.combine< std::collate<wchar_t> >(lcl);
current_locale = current_locale.combine< std::ctype<wchar_t> >(lcl);
current_locale = current_locale.combine< std::time_get<wchar_t> >(lcl);
current_locale = current_locale.combine< std::time_put<wchar_t> >(lcl);

assert(std::use_facet< std::numpunct<char> >(current_locale).decimal_point() == '.');

Expand All @@ -313,6 +307,19 @@ void CLangInfo::CRegion::SetGlobalLocale()
g_langInfo.m_systemLocale = current_locale; //! @todo move to CLangInfo class
std::locale::global(current_locale);
#endif

#ifndef TARGET_WINDOWS
if (setlocale(LC_COLLATE, strLocale.c_str()) == NULL ||
setlocale(LC_CTYPE, strLocale.c_str()) == NULL ||
setlocale(LC_TIME, strLocale.c_str()) == NULL)
{
strLocale = "C";
setlocale(LC_COLLATE, strLocale.c_str());
setlocale(LC_CTYPE, strLocale.c_str());
setlocale(LC_TIME, strLocale.c_str());
}
#endif

g_charsetConverter.resetSystemCharset();
CLog::Log(LOGINFO, "global locale set to %s", strLocale.c_str());
}
Expand Down

0 comments on commit 2542902

Please sign in to comment.