Implement taking date strings from messages locale.
* mimic LocaleKit and add option to POSIX locale backend for taking the date strings from the messages locale (instead of time locale)
This commit is contained in:
@@ -31,6 +31,8 @@ public:
|
|||||||
const char* PosixLocaleName()
|
const char* PosixLocaleName()
|
||||||
{ return fPosixLocaleName; }
|
{ return fPosixLocaleName; }
|
||||||
|
|
||||||
|
const Locale& ICULocale() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
status_t _ConvertUnicodeStringToLocaleconvEntry(
|
status_t _ConvertUnicodeStringToLocaleconvEntry(
|
||||||
const UnicodeString& string,
|
const UnicodeString& string,
|
||||||
@@ -52,6 +54,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
const Locale&
|
||||||
|
ICUCategoryData::ICULocale() const
|
||||||
|
{
|
||||||
|
return fLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Libroot
|
} // namespace Libroot
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ namespace BPrivate {
|
|||||||
namespace Libroot {
|
namespace Libroot {
|
||||||
|
|
||||||
|
|
||||||
|
class ICUMessagesData;
|
||||||
|
|
||||||
|
|
||||||
class ICUTimeData : public ICUCategoryData {
|
class ICUTimeData : public ICUCategoryData {
|
||||||
typedef ICUCategoryData inherited;
|
typedef ICUCategoryData inherited;
|
||||||
public:
|
public:
|
||||||
ICUTimeData(pthread_key_t tlsKey,
|
ICUTimeData(pthread_key_t tlsKey,
|
||||||
struct lc_time_t& lcTimeInfo);
|
struct lc_time_t& lcTimeInfo,
|
||||||
|
const ICUMessagesData& messagesData);
|
||||||
~ICUTimeData();
|
~ICUTimeData();
|
||||||
|
|
||||||
void Initialize(LocaleTimeDataBridge* dataBridge);
|
void Initialize(LocaleTimeDataBridge* dataBridge);
|
||||||
@@ -33,8 +37,6 @@ public:
|
|||||||
|
|
||||||
const char* GetLanginfo(int index);
|
const char* GetLanginfo(int index);
|
||||||
|
|
||||||
const Locale& ICULocale() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _SetLCTimeEntries(const UnicodeString* strings,
|
status_t _SetLCTimeEntries(const UnicodeString* strings,
|
||||||
char* destination, int entrySize,
|
char* destination, int entrySize,
|
||||||
@@ -59,6 +61,8 @@ private:
|
|||||||
struct lc_time_t& fLCTimeInfo;
|
struct lc_time_t& fLCTimeInfo;
|
||||||
|
|
||||||
LocaleTimeDataBridge* fDataBridge;
|
LocaleTimeDataBridge* fDataBridge;
|
||||||
|
|
||||||
|
const ICUMessagesData& fMessagesData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ ICULocaleBackend::ICULocaleBackend()
|
|||||||
fMessagesData(fThreadLocalStorageKey),
|
fMessagesData(fThreadLocalStorageKey),
|
||||||
fMonetaryData(fThreadLocalStorageKey, fLocaleConv),
|
fMonetaryData(fThreadLocalStorageKey, fLocaleConv),
|
||||||
fNumericData(fThreadLocalStorageKey, fLocaleConv),
|
fNumericData(fThreadLocalStorageKey, fLocaleConv),
|
||||||
fTimeData(fThreadLocalStorageKey, fLCTimeInfo),
|
fTimeData(fThreadLocalStorageKey, fLCTimeInfo, fMessagesData),
|
||||||
fTimeConversion(fTimeData)
|
fTimeConversion(fTimeData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,16 +15,19 @@
|
|||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
|
#include "ICUMessagesData.h"
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace Libroot {
|
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),
|
inherited(tlsKey),
|
||||||
fLCTimeInfo(lcTimeInfo),
|
fLCTimeInfo(lcTimeInfo),
|
||||||
fDataBridge(NULL)
|
fDataBridge(NULL),
|
||||||
|
fMessagesData(messagesData)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 12; ++i) {
|
for (int i = 0; i < 12; ++i) {
|
||||||
fLCTimeInfo.mon[i] = fMon[i];
|
fLCTimeInfo.mon[i] = fMon[i];
|
||||||
@@ -66,7 +69,19 @@ ICUTimeData::SetTo(const Locale& locale, const char* posixLocaleName)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
UErrorCode icuStatus = U_ZERO_ERROR;
|
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))
|
if (!U_SUCCESS(icuStatus))
|
||||||
return B_UNSUPPORTED;
|
return B_UNSUPPORTED;
|
||||||
|
|
||||||
@@ -407,13 +422,5 @@ ICUTimeData::_SetLCTimePattern(DateFormat* format, char* destination,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Locale&
|
|
||||||
ICUTimeData::ICULocale() const
|
|
||||||
{
|
|
||||||
return fLocale;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Libroot
|
} // namespace Libroot
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user