From 266eb8307cb2128827ed379b7ec654373693ca50 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 16 Jun 2010 13:23:21 +0000 Subject: [PATCH] sort countries using collator for locale for current language --- .../src/net/i2p/router/web/NetDbRenderer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java index 829c680155..244cc13a0f 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java @@ -11,12 +11,14 @@ package net.i2p.router.web; import java.io.IOException; import java.io.Writer; import java.math.BigInteger; // debug +import java.text.Collator; import java.text.DecimalFormat; // debug import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.TreeSet; @@ -311,11 +313,18 @@ public class NetDbRenderer { out.flush(); } - /** sort by translated country name */ - private class CountryComparator implements Comparator { - public int compare(Object l, Object r) { - return _(_context.commSystem().getCountryName((String)l)) - .compareTo(_(_context.commSystem().getCountryName((String)r))); + /** sort by translated country name using rules for the current language setting */ + private class CountryComparator implements Comparator<String> { + Collator coll; + + public CountryComparator() { + super(); + coll = Collator.getInstance(new Locale(Messages.getLanguage(_context))); + } + + public int compare(String l, String r) { + return coll.compare(_(_context.commSystem().getCountryName(l)), + _(_context.commSystem().getCountryName(r))); } } -- GitLab