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