diff --git a/headers/private/libroot/locale/ICUCategoryData.h b/headers/private/libroot/locale/ICUCategoryData.h index dd25d57a3b..82df10ccf8 100644 --- a/headers/private/libroot/locale/ICUCategoryData.h +++ b/headers/private/libroot/locale/ICUCategoryData.h @@ -31,6 +31,8 @@ public: const char* PosixLocaleName() { return fPosixLocaleName; } + const Locale& ICULocale() const; + protected: status_t _ConvertUnicodeStringToLocaleconvEntry( const UnicodeString& string, @@ -52,6 +54,14 @@ private: }; +inline +const Locale& +ICUCategoryData::ICULocale() const +{ + return fLocale; +} + + } // namespace Libroot } // namespace BPrivate diff --git a/headers/private/libroot/locale/ICUTimeData.h b/headers/private/libroot/locale/ICUTimeData.h index 24f1477eab..c06fc0a4df 100644 --- a/headers/private/libroot/locale/ICUTimeData.h +++ b/headers/private/libroot/locale/ICUTimeData.h @@ -18,11 +18,15 @@ namespace BPrivate { namespace Libroot { +class ICUMessagesData; + + class ICUTimeData : public ICUCategoryData { typedef ICUCategoryData inherited; public: ICUTimeData(pthread_key_t tlsKey, - struct lc_time_t& lcTimeInfo); + struct lc_time_t& lcTimeInfo, + const ICUMessagesData& messagesData); ~ICUTimeData(); void Initialize(LocaleTimeDataBridge* dataBridge); @@ -33,8 +37,6 @@ public: const char* GetLanginfo(int index); - const Locale& ICULocale() const; - private: status_t _SetLCTimeEntries(const UnicodeString* strings, char* destination, int entrySize, @@ -59,6 +61,8 @@ private: struct lc_time_t& fLCTimeInfo; LocaleTimeDataBridge* fDataBridge; + + const ICUMessagesData& fMessagesData; }; diff --git a/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp b/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp index ca9078555d..b8251bb602 100644 --- a/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp +++ b/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp @@ -34,7 +34,7 @@ ICULocaleBackend::ICULocaleBackend() fMessagesData(fThreadLocalStorageKey), fMonetaryData(fThreadLocalStorageKey, fLocaleConv), fNumericData(fThreadLocalStorageKey, fLocaleConv), - fTimeData(fThreadLocalStorageKey, fLCTimeInfo), + fTimeData(fThreadLocalStorageKey, fLCTimeInfo, fMessagesData), fTimeConversion(fTimeData) { } diff --git a/src/system/libroot/add-ons/icu/ICUTimeData.cpp b/src/system/libroot/add-ons/icu/ICUTimeData.cpp index ee6f65cb3d..da756d63e7 100644 --- a/src/system/libroot/add-ons/icu/ICUTimeData.cpp +++ b/src/system/libroot/add-ons/icu/ICUTimeData.cpp @@ -15,16 +15,19 @@ #include +#include "ICUMessagesData.h" namespace BPrivate { namespace Libroot { -ICUTimeData::ICUTimeData(pthread_key_t tlsKey, struct lc_time_t& lcTimeInfo) +ICUTimeData::ICUTimeData(pthread_key_t tlsKey, struct lc_time_t& lcTimeInfo, + const ICUMessagesData& messagesData) : inherited(tlsKey), fLCTimeInfo(lcTimeInfo), - fDataBridge(NULL) + fDataBridge(NULL), + fMessagesData(messagesData) { for (int i = 0; i < 12; ++i) { fLCTimeInfo.mon[i] = fMon[i]; @@ -66,7 +69,19 @@ ICUTimeData::SetTo(const Locale& locale, const char* posixLocaleName) return result; UErrorCode icuStatus = U_ZERO_ERROR; - DateFormatSymbols formatSymbols(fLocale, icuStatus); + + // check if the date strings should be taken from the messages-locale + // or from the time-locale (default) + const Locale* symbolsLocale = &fLocale; + char stringsValue[16]; + fLocale.getKeywordValue("strings", stringsValue, sizeof(stringsValue), + icuStatus); + if (U_SUCCESS(icuStatus) && strcasecmp(stringsValue, "messages") == 0) + symbolsLocale = &fMessagesData.ICULocale(); + else + icuStatus = U_ZERO_ERROR; + + DateFormatSymbols formatSymbols(*symbolsLocale, icuStatus); if (!U_SUCCESS(icuStatus)) return B_UNSUPPORTED; @@ -407,13 +422,5 @@ ICUTimeData::_SetLCTimePattern(DateFormat* format, char* destination, } -const Locale& -ICUTimeData::ICULocale() const -{ - return fLocale; - -} - - } // namespace Libroot } // namespace BPrivate