mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 15:05:53 +00:00
ICU-10125 merge from branch
X-SVN-Rev: 35642
This commit is contained in:
parent
093580b5dc
commit
e22cfd6ac1
16 changed files with 72 additions and 138 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -601,6 +601,7 @@ icu4j/perf-tests/.settings/org.eclipse.jdt.ui.prefs -text
|
|||
icu4j/perf-tests/data/icuperf2report.xsl -text
|
||||
icu4j/samples/build.properties -text
|
||||
icu4j/samples/manifest.stub -text
|
||||
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/en.res -text
|
||||
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/es.res -text
|
||||
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/res_index.res -text
|
||||
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/root.res -text
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-charset"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-collate"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-currdata"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-langdata"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-regiondata"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j-translit"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ICU_JAR"/>
|
||||
<classpathentry kind="output" path="out"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#*******************************************************************************
|
||||
#* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
#* Copyright (C) 2011-2014, International Business Machines Corporation and *
|
||||
#* others. All Rights Reserved. *
|
||||
#*******************************************************************************
|
||||
shared.dir = ../main/shared
|
||||
#shared.dir = ../main/shared
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!--
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011-2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2011-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
-->
|
||||
|
@ -36,6 +36,7 @@
|
|||
<property name="iuc.dataoutdir" value="src/${iuc.package}/data" />
|
||||
<!-- tmp location -->
|
||||
<property name="iuc.tmp" value="out/tmp" />
|
||||
<property name="iuc.res.src" value="c" />
|
||||
<!-- property for the root dir of our messages. -->
|
||||
<fail unless="iuc.res.src" message="Please set -Diuc.res.src=/path/ where /path/ is a checkout of http://source.icu-project.org/repos/icu/icuapps/trunk/icufacts/c" />
|
||||
<!-- properties for the two packages we will be building. -->
|
||||
|
@ -44,7 +45,7 @@
|
|||
<!-- paths for these two packages -->
|
||||
<property name="iuc.res.reshello.path" value="${iuc.res.src}/s30_reshello/${iuc.res.reshello}" />
|
||||
<property name="iuc.res.popmsg.path" value="${iuc.res.src}/s40_popmsg/${iuc.res.popmsg}" />
|
||||
<property name="iuc.bldicures" value="bldicures" />
|
||||
<property name="iuc.bldicures" value="${iuc.res.src}/bldicures.py" />
|
||||
<!-- <available file="${iuc.bldicures}" type="file" property="iuc.bldicures.present" /> -->
|
||||
<fail unless="iuc.bldicures" message="Please set -Diuc.bldicures=/path/bldicures.py - which you can get from <http://source.icu-project.org/repos/icu/tools/trunk/scripts/bldicures.py>" />
|
||||
<mkdir dir="${iuc.tmp}" />
|
||||
|
@ -82,4 +83,4 @@
|
|||
<move file="${iuc.tmp}/${iuc.res.popmsg}/${iuc.res.popmsg}" todir="${iuc.dataoutdir}/" />
|
||||
<delete dir="${iuc.tmp}" /> <!-- clean up -->
|
||||
</target>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2013-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.samples.iuc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
import com.ibm.icu.util.UResourceBundleIterator;
|
||||
|
@ -44,7 +46,7 @@ public class PopulationData {
|
|||
return rc;
|
||||
}
|
||||
};
|
||||
public static Set<TerritoryEntry> getTerritoryEntries(ULocale loc, Set<TerritoryEntry> entries) {
|
||||
public static Set<TerritoryEntry> getTerritoryEntries(Locale loc, Set<TerritoryEntry> entries) {
|
||||
// Note: format of supplementalData is NOT STATIC and may change. It is internal to ICU!
|
||||
UResourceBundle suppData = SupplementalUtilities.getICUSupplementalData();
|
||||
UResourceBundle territoryInfo = suppData.get("territoryInfo");
|
||||
|
@ -58,17 +60,18 @@ public class PopulationData {
|
|||
// territoryF = { gdp, literacy, population }
|
||||
String terrID = rawEntry.getKey();
|
||||
ULocale territory = new ULocale("und", terrID);
|
||||
entries.add(new TerritoryEntry(territory.getDisplayCountry(loc), SupplementalUtilities.ldml2d(vec[2])));
|
||||
entries.add(new TerritoryEntry(territory.getDisplayCountry(ULocale.forLocale(loc)), SupplementalUtilities.ldml2d(vec[2])));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
System.out.println("Loading population/territory data from CLDR");
|
||||
Set<TerritoryEntry> territoryEntries = getTerritoryEntries(ULocale.getDefault(), new HashSet<TerritoryEntry>());
|
||||
System.out.println(".. count="+ territoryEntries.size());
|
||||
Set<TerritoryEntry> territoryEntries = getTerritoryEntries(Locale.getDefault(), new HashSet<TerritoryEntry>());
|
||||
System.out.println(".. count="+ nf.format(territoryEntries.size()));
|
||||
for(TerritoryEntry te : territoryEntries) {
|
||||
System.out.println(" "+ te.territoryName() + " = " + te.population());
|
||||
System.out.println(" "+ te.territoryName() + " = " + nf.format(te.population()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2013-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.samples.iuc;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.LocaleDisplayNames;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class Sample13_Hello {
|
||||
public static void main(String... args) {
|
||||
Locale locale = Locale.getDefault();
|
||||
String world = LocaleDisplayNames
|
||||
.getInstance(ULocale.getDefault()).regionDisplayName("001");
|
||||
.getInstance(ULocale.forLocale(locale))
|
||||
.regionDisplayName("001");
|
||||
System.out.println("Hello, " + world + "\u2603");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.samples.iuc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.text.LocaleDisplayNames;
|
||||
import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* @author srl
|
||||
*
|
||||
*/
|
||||
public class Sample20_Message {
|
||||
public static void main(String... args) {
|
||||
ULocale defaultLocaleID = ULocale.getDefault();
|
||||
LocaleDisplayNames ldn = LocaleDisplayNames.getInstance(defaultLocaleID, DialectHandling.DIALECT_NAMES);
|
||||
String defaultLocaleName = ldn.localeDisplayName(defaultLocaleID);
|
||||
String world = ldn.regionDisplayName("001");
|
||||
MessageFormat fmt = new MessageFormat("A hello to {part, number, percent} of the {world}, in {mylocale}, on {today, date}!",
|
||||
defaultLocaleID);
|
||||
Map<String, Object> msgargs = new HashMap<String, Object>();
|
||||
msgargs.put("part", 1.00);
|
||||
msgargs.put("world", world);
|
||||
msgargs.put("mylocale", defaultLocaleName);
|
||||
msgargs.put("today", System.currentTimeMillis());
|
||||
System.out.println(fmt.format(msgargs, new StringBuffer(), null));
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2013-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.samples.iuc;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
/**
|
||||
|
@ -15,7 +16,7 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
*/
|
||||
public class Sample30_ResHello {
|
||||
public static void main(String... args) {
|
||||
ULocale locale = ULocale.getDefault();
|
||||
Locale locale = Locale.getDefault();
|
||||
UResourceBundle bundle =
|
||||
UResourceBundle.getBundleInstance(
|
||||
Sample30_ResHello.class.getPackage().getName().replace('.', '/')+"/data/reshello",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2013-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -8,11 +8,14 @@ package com.ibm.icu.samples.iuc;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.samples.iuc.PopulationData.TerritoryEntry;
|
||||
import com.ibm.icu.text.LocaleDisplayNames;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
|
@ -23,21 +26,29 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
public class Sample40_PopMsg {
|
||||
public static void main(String... args) {
|
||||
// setup
|
||||
ULocale locale = ULocale.getDefault();
|
||||
Locale defaultLocaleID = Locale.getDefault();
|
||||
LocaleDisplayNames ldn = LocaleDisplayNames.getInstance(ULocale.forLocale(defaultLocaleID),
|
||||
DialectHandling.DIALECT_NAMES);
|
||||
String defaultLocaleName = ldn.localeDisplayName(defaultLocaleID);
|
||||
|
||||
Set<PopulationData.TerritoryEntry> territoryList;
|
||||
territoryList = PopulationData.getTerritoryEntries(locale,
|
||||
territoryList = PopulationData.getTerritoryEntries(defaultLocaleID,
|
||||
new HashSet<TerritoryEntry>());
|
||||
int territoryCount = territoryList.size();
|
||||
UResourceBundle resourceBundle =
|
||||
UResourceBundle.getBundleInstance(
|
||||
Sample40_PopMsg.class.getPackage().getName().replace('.', '/')+"/data/popmsg",
|
||||
locale,
|
||||
defaultLocaleID,
|
||||
Sample40_PopMsg.class.getClassLoader());
|
||||
|
||||
// say hello
|
||||
String welcome = resourceBundle.getString("welcome");
|
||||
Map<String, Object> welcomeArgs = new HashMap<String, Object>();
|
||||
welcomeArgs.put("territoryCount", territoryList.size());
|
||||
System.out.println( MessageFormat.format(welcome, welcomeArgs) );
|
||||
String pattern = resourceBundle.getString("welcome");
|
||||
MessageFormat fmt = new MessageFormat(pattern,defaultLocaleID);
|
||||
Map<String, Object> msgargs = new HashMap<String, Object>();
|
||||
msgargs.put("territoryCount", territoryCount);
|
||||
msgargs.put("myLanguage", defaultLocaleName);
|
||||
msgargs.put("today", System.currentTimeMillis());
|
||||
System.out.println(fmt.format(msgargs, new StringBuffer(), null));
|
||||
|
||||
// Population roll call
|
||||
String info = resourceBundle.getString("info");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* Copyright (C) 2013-2014, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -8,13 +8,17 @@ package com.ibm.icu.samples.iuc;
|
|||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.samples.iuc.PopulationData.TerritoryEntry;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.text.LocaleDisplayNames;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
|
@ -25,10 +29,20 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
public class Sample50_PopSort {
|
||||
public static void main(String... args) {
|
||||
// setup
|
||||
final ULocale locale = ULocale.getDefault();
|
||||
// setup
|
||||
Locale defaultLocaleID = Locale.getDefault();
|
||||
LocaleDisplayNames ldn = LocaleDisplayNames.getInstance(ULocale.forLocale(defaultLocaleID),
|
||||
DialectHandling.DIALECT_NAMES);
|
||||
String defaultLocaleName = ldn.localeDisplayName(defaultLocaleID);
|
||||
|
||||
Set<PopulationData.TerritoryEntry> territoryList;
|
||||
final Collator collator = Collator.getInstance(locale);
|
||||
territoryList = PopulationData.getTerritoryEntries(locale,
|
||||
territoryList = PopulationData.getTerritoryEntries(defaultLocaleID,
|
||||
new HashSet<TerritoryEntry>());
|
||||
int territoryCount = territoryList.size();
|
||||
|
||||
// sort it
|
||||
final Collator collator = Collator.getInstance(defaultLocaleID);
|
||||
territoryList = PopulationData.getTerritoryEntries(defaultLocaleID,
|
||||
new TreeSet<TerritoryEntry>(new Comparator<TerritoryEntry>(){
|
||||
public int compare(TerritoryEntry o1, TerritoryEntry o2) {
|
||||
return collator.compare(o1.territoryName(), o2.territoryName());
|
||||
|
@ -36,14 +50,17 @@ public class Sample50_PopSort {
|
|||
UResourceBundle resourceBundle =
|
||||
UResourceBundle.getBundleInstance(
|
||||
Sample40_PopMsg.class.getPackage().getName().replace('.', '/')+"/data/popmsg",
|
||||
locale,
|
||||
defaultLocaleID,
|
||||
Sample40_PopMsg.class.getClassLoader());
|
||||
|
||||
// say hello
|
||||
String welcome = resourceBundle.getString("welcome");
|
||||
Map<String, Object> welcomeArgs = new HashMap<String, Object>();
|
||||
welcomeArgs.put("territoryCount", territoryList.size());
|
||||
System.out.println( MessageFormat.format(welcome, welcomeArgs) );
|
||||
String pattern = resourceBundle.getString("welcome");
|
||||
MessageFormat fmt = new MessageFormat(pattern,defaultLocaleID);
|
||||
Map<String, Object> msgargs = new HashMap<String, Object>();
|
||||
msgargs.put("territoryCount", territoryCount);
|
||||
msgargs.put("myLanguage", defaultLocaleName);
|
||||
msgargs.put("today", System.currentTimeMillis());
|
||||
System.out.println(fmt.format(msgargs, new StringBuffer(), null));
|
||||
|
||||
// Population roll call
|
||||
String info = resourceBundle.getString("info");
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2013, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.samples.iuc;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.samples.iuc.PopulationData.TerritoryEntry;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
/**
|
||||
* @author srl
|
||||
*
|
||||
*/
|
||||
public class Sample55_PopTranslit {
|
||||
public static void main(String... args) {
|
||||
// setup
|
||||
final ULocale fromLocale = new ULocale(args[0]);
|
||||
final ULocale locale = ULocale.getDefault();
|
||||
Set<PopulationData.TerritoryEntry> territoryList;
|
||||
final Collator collator = Collator.getInstance(locale);
|
||||
territoryList = PopulationData.getTerritoryEntries(fromLocale,
|
||||
new TreeSet<TerritoryEntry>(new Comparator<TerritoryEntry>(){
|
||||
public int compare(TerritoryEntry o1, TerritoryEntry o2) {
|
||||
return collator.compare(o1.territoryName(), o2.territoryName());
|
||||
}}));
|
||||
UResourceBundle resourceBundle =
|
||||
UResourceBundle.getBundleInstance(
|
||||
Sample40_PopMsg.class.getPackage().getName().replace('.', '/')+"/data/popmsg",
|
||||
locale,
|
||||
Sample40_PopMsg.class.getClassLoader());
|
||||
|
||||
// say hello
|
||||
String welcome = resourceBundle.getString("welcome");
|
||||
Map<String, Object> welcomeArgs = new HashMap<String, Object>();
|
||||
welcomeArgs.put("territoryCount", territoryList.size());
|
||||
System.out.println( MessageFormat.format(welcome, welcomeArgs) );
|
||||
|
||||
// Population roll call
|
||||
String info = resourceBundle.getString("info");
|
||||
Map<String, Object> infoArgs = new HashMap<String, Object>();
|
||||
|
||||
Transliterator translit = Transliterator.getInstance("Any-Latin");
|
||||
|
||||
for(PopulationData.TerritoryEntry entry : territoryList) {
|
||||
infoArgs.put("territory", translit.transform(entry.territoryName()));
|
||||
infoArgs.put("population", entry.population());
|
||||
System.out.println(MessageFormat.format(info, infoArgs));
|
||||
}
|
||||
}
|
||||
}
|
BIN
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/en.res
Normal file
BIN
icu4j/samples/src/com/ibm/icu/samples/iuc/data/popmsg/en.res
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue