forked from I2P_Developers/i2p.i2p
sort countries using collator for locale for current language
This commit is contained in:
@@ -11,12 +11,14 @@ package net.i2p.router.web;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.math.BigInteger; // debug
|
import java.math.BigInteger; // debug
|
||||||
|
import java.text.Collator;
|
||||||
import java.text.DecimalFormat; // debug
|
import java.text.DecimalFormat; // debug
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
@@ -311,11 +313,18 @@ public class NetDbRenderer {
|
|||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** sort by translated country name */
|
/** sort by translated country name using rules for the current language setting */
|
||||||
private class CountryComparator implements Comparator {
|
private class CountryComparator implements Comparator<String> {
|
||||||
public int compare(Object l, Object r) {
|
Collator coll;
|
||||||
return _(_context.commSystem().getCountryName((String)l))
|
|
||||||
.compareTo(_(_context.commSystem().getCountryName((String)r)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user