mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
Reviewed-by: bchristi
This commit is contained in:
parent
63ef779d96
commit
c1a99a0f33
4 changed files with 212 additions and 81 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,6 +33,7 @@ import java.text.spi.DecimalFormatSymbolsProvider;
|
|||
import java.text.spi.NumberFormatProvider;
|
||||
import java.util.Collections;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -550,15 +551,33 @@ public class HostLocaleProviderAdapterImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String calType, int field, int value,
|
||||
int style, Locale locale) {
|
||||
return null;
|
||||
public String getDisplayName(String calendarType, int field,
|
||||
int value, int style, Locale locale) {
|
||||
String[] names = getCalendarDisplayStrings(locale.toLanguageTag(),
|
||||
field, style);
|
||||
if (names != null && value >= 0 && value < names.length) {
|
||||
return names[value];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getDisplayNames(String calType,
|
||||
int field, int style, Locale locale) {
|
||||
return null;
|
||||
public Map<String, Integer> getDisplayNames(String calendarType,
|
||||
int field, int style, Locale locale) {
|
||||
Map<String, Integer> map = null;
|
||||
String[] names = getCalendarDisplayStrings(locale.toLanguageTag(),
|
||||
field, style);
|
||||
if (names != null) {
|
||||
map = new HashMap<>((int)Math.ceil(names.length / 0.75));
|
||||
for (int value = 0; value < names.length; value++) {
|
||||
if (names[value] != null) {
|
||||
map.put(names[value], value);
|
||||
}
|
||||
}
|
||||
map = map.isEmpty() ? null : map;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -901,6 +920,9 @@ public class HostLocaleProviderAdapterImpl {
|
|||
// For CalendarDataProvider
|
||||
private static native int getCalendarInt(String langTag, int type);
|
||||
|
||||
// For CalendarNameProvider
|
||||
private static native String[] getCalendarDisplayStrings(String langTag, int field, int style);
|
||||
|
||||
// For Locale/CurrencyNameProvider
|
||||
private static native String getDisplayString(String langTag, int key, String value);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue