v2.5.3: fixed number formatting not respecting language locale
This commit is contained in:
@@ -76,6 +76,7 @@ public class Messages {
|
||||
};
|
||||
|
||||
static{
|
||||
formatters = new HashMap<>();
|
||||
setup(SPDSettings.language());
|
||||
}
|
||||
|
||||
@@ -90,6 +91,7 @@ public class Messages {
|
||||
} else {
|
||||
locale = new Locale(lang.code());
|
||||
}
|
||||
formatters.clear();
|
||||
|
||||
//strictly match the language code when fetching bundles however
|
||||
bundles = new ArrayList<>();
|
||||
@@ -157,18 +159,18 @@ public class Messages {
|
||||
|
||||
public static String format( String format, Object...args ) {
|
||||
try {
|
||||
return String.format(Locale.ENGLISH, format, args);
|
||||
return String.format(locale(), format, args);
|
||||
} catch (IllegalFormatException e) {
|
||||
ShatteredPixelDungeon.reportException( new Exception("formatting error for the string: " + format, e) );
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, DecimalFormat> formatters = new HashMap<>();
|
||||
private static HashMap<String, DecimalFormat> formatters;
|
||||
|
||||
public static String decimalFormat( String format, double number ){
|
||||
if (!formatters.containsKey(format)){
|
||||
formatters.put(format, new DecimalFormat(format, DecimalFormatSymbols.getInstance(Locale.ENGLISH)));
|
||||
formatters.put(format, new DecimalFormat(format, DecimalFormatSymbols.getInstance(locale())));
|
||||
}
|
||||
return formatters.get(format).format(number);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class WndDailies extends Window {
|
||||
|
||||
top = (int) score.bottom() + 6;
|
||||
|
||||
NumberFormat num = NumberFormat.getInstance(Locale.US);
|
||||
NumberFormat num = NumberFormat.getInstance(Messages.locale());
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Date date = new Date();
|
||||
|
||||
@@ -190,7 +190,7 @@ public class WndRanking extends WndTabbed {
|
||||
|
||||
pos = date.bottom()+5;
|
||||
|
||||
NumberFormat num = NumberFormat.getInstance(Locale.US);
|
||||
NumberFormat num = NumberFormat.getInstance(Messages.locale());
|
||||
|
||||
if (Dungeon.hero == null){
|
||||
pos = statSlot( this, Messages.get(this, "score"), num.format( record.score ), pos );
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.Group;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WndScoreBreakdown extends Window {
|
||||
|
||||
@@ -48,7 +47,7 @@ public class WndScoreBreakdown extends Window {
|
||||
|
||||
float pos = title.bottom()+2;
|
||||
|
||||
NumberFormat num = NumberFormat.getInstance(Locale.US);
|
||||
NumberFormat num = NumberFormat.getInstance(Messages.locale());
|
||||
if (Dungeon.initialVersion > ShatteredPixelDungeon.v1_2_3) {
|
||||
pos = statSlot(this, Messages.get(this, "progress_title"),
|
||||
num.format(Statistics.progressScore), pos, Statistics.progressScore >= 50_000);
|
||||
|
||||
Reference in New Issue
Block a user