Various fixes / Placement visual improvements
This commit is contained in:
@@ -32,7 +32,6 @@ public class LanguageDialog extends FloatingDialog{
|
||||
|
||||
for(Locale loc : locales){
|
||||
TextButton button = new TextButton(Platform.instance.getLocaleName(loc), "toggle");
|
||||
button.setChecked(getLocale().equals(loc));
|
||||
button.clicked(() -> {
|
||||
if(getLocale().equals(loc)) return;
|
||||
Settings.putString("locale", loc.toString());
|
||||
@@ -40,9 +39,7 @@ public class LanguageDialog extends FloatingDialog{
|
||||
Log.info("Setting locale: {0}", loc.toString());
|
||||
ui.showInfo("$text.language.restart");
|
||||
});
|
||||
langs.add(button).group(group).update(t -> {
|
||||
t.setChecked(loc.equals(getLocale()));
|
||||
}).size(400f, 60f).row();
|
||||
langs.add(button).group(group).update(t -> t.setChecked(loc.equals(getLocale()))).size(400f, 60f).row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
@@ -50,19 +47,40 @@ public class LanguageDialog extends FloatingDialog{
|
||||
|
||||
public Locale getLocale(){
|
||||
String loc = Settings.getString("locale");
|
||||
if(loc.equals("default")){
|
||||
return Locale.getDefault();
|
||||
}else{
|
||||
if(lastLocale == null || !lastLocale.toString().equals(loc)){
|
||||
if(loc.contains("_")){
|
||||
String[] split = loc.split("_");
|
||||
lastLocale = new Locale(split[0], split[1]);
|
||||
}else{
|
||||
lastLocale = new Locale(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return lastLocale;
|
||||
if(loc.equals("default")){
|
||||
findClosestLocale();
|
||||
}
|
||||
|
||||
if(lastLocale == null || !lastLocale.toString().equals(loc)){
|
||||
if(loc.contains("_")){
|
||||
String[] split = loc.split("_");
|
||||
lastLocale = new Locale(split[0], split[1]);
|
||||
}else{
|
||||
lastLocale = new Locale(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return lastLocale;
|
||||
}
|
||||
|
||||
void findClosestLocale(){
|
||||
//check exact locale
|
||||
for(Locale l : locales){
|
||||
if(l.equals(Locale.getDefault())){
|
||||
Settings.putString("locale", l.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//find by language
|
||||
for(Locale l : locales){
|
||||
if(l.getLanguage().equals(Locale.getDefault().getLanguage())){
|
||||
Settings.putString("locale", l.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Settings.putString("locale", new Locale("en").toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user