From 1729a188555ab18269b793726eb72e8cd9217773 Mon Sep 17 00:00:00 2001
From: Jens-Heiner Rechtien
Date: Tue, 28 Jul 2009 16:27:10 +0000
Subject: CWS-TOOLING: integrate CWS thaical311_DEV300 2009-07-21 12:42:57
+0200 er r274181 : #i102356# init: force Gregorian calendar in spite of what
ICU may default to for a locale
---
i18npool/source/calendar/calendar_gregorian.cxx | 34 ++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
(limited to 'i18npool')
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 96eee0772bc1..50b61eae5cf1 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -148,10 +148,42 @@ void SAL_CALL
Calendar_gregorian::init(Era *_eraArray)
{
cCalendar = "com.sun.star.i18n.Calendar_gregorian";
+
+ // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
+ // th_TH system locale we accidentally used a Buddhist calendar. Though
+ // the ICU documentation says that should be the case only for
+ // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
+ // already triggers that behavior, ja_JP does not. Strange enough,
+ // passing a th_TH locale to the calendar creation doesn't trigger
+ // this.
+ // See also http://userguide.icu-project.org/datetime/calendar
+
+ // Whatever ICU offers as the default calendar for a locale, ensure we
+ // have a Gregorian calendar as requested.
+
+ /* XXX: with the current implementation the aLocale member variable is
+ * not set prior to loading a calendar from locale data. This
+ * creates an empty (root) locale for ICU, but at least the correct
+ * calendar is used. The language part must not be NULL (respectively
+ * not all, language and country and variant), otherwise the current
+ * default locale would be used again and the calendar keyword ignored.
+ * */
+ icu::Locale aIcuLocale( "", NULL, NULL, "calendar=gregorian");
+
UErrorCode status;
- body = icu::Calendar::createInstance(status = U_ZERO_ERROR);
+ body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
if (!body || !U_SUCCESS(status)) throw ERROR;
+#if 0
+ {
+ icu::Locale loc;
+ loc = body->getLocale( ULOC_ACTUAL_LOCALE, status = U_ZERO_ERROR);
+ fprintf( stderr, "\nICU calendar actual locale: %s\n", loc.getName());
+ loc = body->getLocale( ULOC_VALID_LOCALE, status = U_ZERO_ERROR);
+ fprintf( stderr, "ICU calendar valid locale: %s\n", loc.getName());
+ }
+#endif
+
eraArray=_eraArray;
}
--
cgit