summaryrefslogtreecommitdiffstats
path: root/core/jni/android_text_format_Time.cpp
diff options
context:
space:
mode:
authorEric Fischer <enf@google.com>2009-05-12 16:29:46 -0700
committerEric Fischer <enf@google.com>2009-05-15 10:15:50 -0700
commit5bd644caf73e76750feef1a82b8817d32f5367fc (patch)
tree345fac5c8625cb5ce037613fec1ab5015b7e7fd6 /core/jni/android_text_format_Time.cpp
parent4535e40544aeb957d44fad75fbe5676effe03689 (diff)
downloadframeworks_base-5bd644caf73e76750feef1a82b8817d32f5367fc.zip
frameworks_base-5bd644caf73e76750feef1a82b8817d32f5367fc.tar.gz
frameworks_base-5bd644caf73e76750feef1a82b8817d32f5367fc.tar.bz2
Start using CLDR for some date-and-time strings and formats.
Use java.text.DateFormat where possible, since that is already using the CLDR data for the things it supports. Remove an unused date format object from DatePickerDialog. Add a new method for getting the standalone month names from applications, although @hidden for now because it is an API change. Pass the standalone month names down to native code in Time so that tztime's strftime() can use them. And then the bulk of the change: replace all the names for the months and the days of the week, and AM and PM, and yesterday, today, and tomorrow, with strings from CLDR. And replace several of the date format strings with ones derived from CLDR, but reformatted to use strftime() style instead of SimpleDateFormat style. All these resource changes go into new donottranslate-cldr.xml files and are removed from strings.xml so that they aren't part of the normal translation process and the translators don't have to bother with them (and risk messing them up).
Diffstat (limited to 'core/jni/android_text_format_Time.cpp')
-rw-r--r--core/jni/android_text_format_Time.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/jni/android_text_format_Time.cpp b/core/jni/android_text_format_Time.cpp
index 923e1aa..7c208e9 100644
--- a/core/jni/android_text_format_Time.cpp
+++ b/core/jni/android_text_format_Time.cpp
@@ -44,6 +44,7 @@ static jfieldID g_timezoneField = 0;
static jfieldID g_shortMonthsField = 0;
static jfieldID g_longMonthsField = 0;
+static jfieldID g_longStandaloneMonthsField = 0;
static jfieldID g_shortWeekdaysField = 0;
static jfieldID g_longWeekdaysField = 0;
static jfieldID g_timeOnlyFormatField = 0;
@@ -193,6 +194,7 @@ static jstring android_text_format_Time_format(JNIEnv* env, jobject This,
static jobject js_locale_previous = NULL;
static struct strftime_locale locale;
static jstring js_mon[12], js_month[12], js_wday[7], js_weekday[7];
+ static jstring js_standalone_month[12];
static jstring js_X_fmt, js_x_fmt, js_c_fmt, js_am, js_pm, js_date_fmt;
Time t;
@@ -206,8 +208,10 @@ static jstring android_text_format_Time_format(JNIEnv* env, jobject This,
for (int i = 0; i < 12; i++) {
env->ReleaseStringUTFChars(js_mon[i], locale.mon[i]);
env->ReleaseStringUTFChars(js_month[i], locale.month[i]);
+ env->ReleaseStringUTFChars(js_standalone_month[i], locale.standalone_month[i]);
env->DeleteGlobalRef(js_mon[i]);
env->DeleteGlobalRef(js_month[i]);
+ env->DeleteGlobalRef(js_standalone_month[i]);
}
for (int i = 0; i < 7; i++) {
@@ -245,6 +249,12 @@ static jstring android_text_format_Time_format(JNIEnv* env, jobject This,
locale.month[i] = env->GetStringUTFChars(js_month[i], NULL);
}
+ ja = (jobjectArray) env->GetStaticObjectField(timeClass, g_longStandaloneMonthsField);
+ for (int i = 0; i < 12; i++) {
+ js_standalone_month[i] = (jstring) env->NewGlobalRef(env->GetObjectArrayElement(ja, i));
+ locale.standalone_month[i] = env->GetStringUTFChars(js_standalone_month[i], NULL);
+ }
+
ja = (jobjectArray) env->GetStaticObjectField(timeClass, g_shortWeekdaysField);
for (int i = 0; i < 7; i++) {
js_wday[i] = (jstring) env->NewGlobalRef(env->GetObjectArrayElement(ja, i));
@@ -639,6 +649,7 @@ int register_android_text_format_Time(JNIEnv* env)
g_shortMonthsField = env->GetStaticFieldID(timeClass, "sShortMonths", "[Ljava/lang/String;");
g_longMonthsField = env->GetStaticFieldID(timeClass, "sLongMonths", "[Ljava/lang/String;");
+ g_longStandaloneMonthsField = env->GetStaticFieldID(timeClass, "sLongStandaloneMonths", "[Ljava/lang/String;");
g_shortWeekdaysField = env->GetStaticFieldID(timeClass, "sShortWeekdays", "[Ljava/lang/String;");
g_longWeekdaysField = env->GetStaticFieldID(timeClass, "sLongWeekdays", "[Ljava/lang/String;");
g_timeOnlyFormatField = env->GetStaticFieldID(timeClass, "sTimeOnlyFormat", "Ljava/lang/String;");