fix: some more language tweaks

This commit is contained in:
Ryan Dowling 2019-07-13 23:42:25 +10:00
parent c3853c2b1e
commit e428eda22b
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
13 changed files with 69 additions and 1961 deletions

View file

@ -10,10 +10,10 @@ ModPacks easily and quickly.
## Links
- [ATLauncher Website](https://www.atlauncher.com)
- [ATLauncher Facebook](http://www.facebook.com/ATLauncher)
- [ATLauncher Reddit](http://www.reddit.com/r/ATLauncher)
- [ATLauncher Twitter](http://twitter.com/ATLauncher)
- [ATLauncher Website](https://www.atlauncher.com)
- [ATLauncher Facebook](http://www.facebook.com/ATLauncher)
- [ATLauncher Reddit](http://www.reddit.com/r/ATLauncher)
- [ATLauncher Twitter](http://twitter.com/ATLauncher)
## Coding Standards & Styling Guidelines

View file

@ -1,3 +0,0 @@
files:
- source: /translations.pot
translation: /src/main/resources/assets/lang/%locale_with_underscore%.po

View file

@ -37,7 +37,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -197,10 +196,6 @@ public class App {
public static Theme THEME = Theme.DEFAULT_THEME;
static {
// Set English as the default locale. CodeChickenLib(?) has some issues when not
// using this on some systems.
Locale.setDefault(Locale.ENGLISH);
// Prefer to use IPv4
System.setProperty("java.net.preferIPv4Stack", "true");

View file

@ -18,23 +18,40 @@
package com.atlauncher.data;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.atlauncher.App;
import com.atlauncher.LogManager;
import org.mini2Dx.gettext.GetText;
import org.mini2Dx.gettext.PoFile;
public class Language {
public final static List<Locale> locales = new ArrayList<>();
public final static Map<String, Locale> languages = new HashMap<>();
public static String selected = "English";
public static String selected = Locale.ENGLISH.getDisplayName();
public static void init() throws IOException {
languages.put("English", Locale.ENGLISH);
// add in the languages we have support for
static {
locales.add(Locale.ENGLISH);
}
public static void setLanguage(String language) throws IOException {
public static void init() throws IOException {
for (Locale locale : locales) {
if (App.class.getResourceAsStream("/assets/lang/" + locale.toString() + ".po") != null) {
languages.put(locale.getDisplayName(), locale);
GetText.add(
new PoFile(locale, App.class.getResourceAsStream("/assets/lang/" + locale.toString() + ".po")));
LogManager.debug("Loaded language " + locale.getDisplayName() + " with key of " + locale);
}
}
}
public static void setLanguage(String language) {
Locale locale;
if (isLanguageByName(language)) {
@ -42,9 +59,9 @@ public class Language {
locale = languages.get(language);
selected = language;
} else {
LogManager.info("Unknown language " + language + ". Defaulting to English");
LogManager.info("Unknown language " + language + ". Defaulting to " + Locale.ENGLISH.getDisplayName());
locale = Locale.ENGLISH;
selected = "English";
selected = Locale.ENGLISH.getDisplayName();
}
GetText.setLocale(locale);

View file

@ -154,7 +154,7 @@ public class Settings {
private List<MinecraftServer> checkingServers = new ArrayList<>();
// Directories and Files for the Launcher
private File baseDir, configsDir, themesDir, jsonDir, versionsDir, imagesDir, skinsDir, toolsDir, commonConfigsDir,
librariesDir, languagesDir, usersDownloadsFolder;
librariesDir, usersDownloadsFolder;
// Launcher Settings
private JFrame parent; // Parent JFrame of the actual Launcher
private Properties properties = new Properties(); // Properties to store everything in
@ -198,7 +198,6 @@ public class Settings {
toolsDir = new File(configsDir, "Tools");
commonConfigsDir = new File(configsDir, "Common");
librariesDir = new File(configsDir, "Libraries");
languagesDir = new File(configsDir, "Languages");
}
public void loadEverything() {
@ -234,8 +233,6 @@ public class Settings {
checkForValidJavaPath(true); // Checks for a valid Java path
}
console.setupLanguage(); // Setup language on the console
clearOldLogs(); // Clear all the old logs out
checkAccountsForNameChanges(); // Check account for username changes
@ -632,8 +629,8 @@ public class Settings {
* Checks the directory to make sure all the necessary folders are there
*/
private void checkFolders() {
File[] files = { configsDir, themesDir, jsonDir, commonConfigsDir, imagesDir, skinsDir, toolsDir, librariesDir,
languagesDir };
File[] files = { configsDir, themesDir, jsonDir, commonConfigsDir, imagesDir, skinsDir, toolsDir,
librariesDir };
for (File file : files) {
if (!file.exists()) {
file.mkdir();
@ -737,15 +734,6 @@ public class Settings {
return this.librariesDir;
}
/**
* Returns the languages directory
*
* @return File object for the languages directory
*/
public File getLanguagesDir() {
return this.languagesDir;
}
/**
* Returns the downloads directory for the user
*
@ -806,11 +794,6 @@ public class Settings {
}
String lang = properties.getProperty("language", "English");
if (!isLanguageByName(lang)) {
LogManager.warn("Invalid language " + lang + ". Defaulting to English!");
lang = "English";
}
Language.setLanguage(lang);
this.enableProxy = Boolean.parseBoolean(properties.getProperty("enableproxy", "false"));
@ -872,14 +855,6 @@ public class Settings {
this.hideJava9Warning = Boolean.parseBoolean(properties.getProperty("hideJava9Warning", "false"));
String lang = properties.getProperty("language", "English");
if (!isLanguageByName(lang)) {
LogManager.warn("Invalid language " + lang + ". Defaulting to English!");
lang = "English";
}
Language.setLanguage(lang);
this.forgeLoggingLevel = properties.getProperty("forgelogginglevel", "INFO");
if (!this.forgeLoggingLevel.equalsIgnoreCase("SEVERE")
&& !this.forgeLoggingLevel.equalsIgnoreCase("WARNING")
@ -1785,19 +1760,6 @@ public class Settings {
return news;
}
/**
* Get the Languages available in the Launcher
*
* @return The Languages available in the Launcher
*/
public List<String> getLanguages() {
List<String> langs = new LinkedList<>();
for (File file : this.getLanguagesDir().listFiles((dir, name) -> name.endsWith(".lang"))) {
langs.add(file.getName().substring(0, file.getName().lastIndexOf(".")));
}
return langs;
}
/**
* Determines if offline mode is enabled or not
*
@ -2118,16 +2080,6 @@ public class Settings {
return null;
}
/**
* Finds if a language is available
*
* @param name The name of the Language
* @return true if found, false if not
*/
public boolean isLanguageByName(String name) {
return this.getLanguages().contains(name.toLowerCase());
}
/**
* Finds if an Account is available
*
@ -2197,19 +2149,6 @@ public class Settings {
}
}
/**
* Sets the users current active Language
*
* @param language The language to set to
*/
public void setLanguage(String language) {
try {
Language.setLanguage(language);
} catch (IOException ex) {
LogManager.logStackTrace("Failed to load language", ex);
}
}
/**
* Gets the users setting for Forge Logging Level
*

View file

@ -84,11 +84,11 @@ public final class TrayMenu extends JPopupMenu implements ConsoleCloseListener,
@Override
public void onConsoleClose() {
this.tcButton.setText(GetText.tr("Show console"));
this.tcButton.setText(GetText.tr("Show Console"));
}
@Override
public void onConsoleOpen() {
this.tcButton.setText(GetText.tr("Hide console"));
this.tcButton.setText(GetText.tr("Hide Console"));
}
}

View file

@ -118,8 +118,8 @@ public class LauncherBottomBar extends BottomBar implements RelocalizationListen
}
}
});
ConsoleCloseManager.addListener(() -> toggleConsole.setText(GetText.tr("Show")));
ConsoleOpenManager.addListener(() -> toggleConsole.setText(GetText.tr("Hide")));
ConsoleCloseManager.addListener(() -> toggleConsole.setText(GetText.tr("Show Console")));
ConsoleOpenManager.addListener(() -> toggleConsole.setText(GetText.tr("Hide Console")));
}
/**
@ -127,9 +127,9 @@ public class LauncherBottomBar extends BottomBar implements RelocalizationListen
*/
private void createButtons() {
if (App.settings.isConsoleVisible()) {
toggleConsole = new JButton(GetText.tr("Hide"));
toggleConsole = new JButton(GetText.tr("Hide Console"));
} else {
toggleConsole = new JButton(GetText.tr("Show"));
toggleConsole = new JButton(GetText.tr("Show Console"));
}
openFolder = new JButton(GetText.tr("Open Folder"));
@ -207,9 +207,9 @@ public class LauncherBottomBar extends BottomBar implements RelocalizationListen
@Override
public void onRelocalization() {
if (App.settings.getConsole().isVisible()) {
toggleConsole.setText(GetText.tr("Hide"));
toggleConsole.setText(GetText.tr("Hide Console"));
} else {
toggleConsole.setText(GetText.tr("Show"));
toggleConsole.setText(GetText.tr("Show Console"));
}
this.updateData.setText(GetText.tr("Update Data"));
this.openFolder.setText(GetText.tr("Open Folder"));

View file

@ -137,8 +137,8 @@ public class InstanceInstallerDialog extends JDialog {
setResizable(false);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
install = new JButton(((isReinstall) ? (isUpdate ? GetText.tr("Update") : GetText.tr("common.reinstall"))
: GetText.tr("common.install")));
install = new JButton(((isReinstall) ? (isUpdate ? GetText.tr("Update") : GetText.tr("Reinstall"))
: GetText.tr("Install")));
// Top Panel Stuff
top = new JPanel();

View file

@ -127,7 +127,7 @@ public class SetupDialog extends JDialog {
bottom.setLayout(new FlowLayout());
saveButton = new JButton(GetText.tr("Save"));
saveButton.addActionListener(e -> {
App.settings.setLanguage((String) language.getSelectedItem());
Language.setLanguage((String) language.getSelectedItem());
App.settings.setEnableLeaderboards(enableLeaderboards.isSelected());
App.settings.setEnableAnalytics(enableAnalytics.isSelected());
App.settings.saveProperties();

View file

@ -43,7 +43,6 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public class SettingsTab extends JPanel implements Tab, RelocalizationListener {
private final GeneralSettingsTab generalSettingsTab = new GeneralSettingsTab();
private final JavaSettingsTab javaSettingsTab = new JavaSettingsTab();
private final NetworkSettingsTab networkSettingsTab = new NetworkSettingsTab();

View file

@ -79,7 +79,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab {
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
language = new JComboBox<>(Language.languages.keySet().toArray(new String[Language.languages.size()]));
language = new JComboBox<>(Language.locales.stream().map(l -> l.getDisplayName()).toArray(String[]::new));
language.setSelectedItem(Language.selected);
add(language, gbc);
@ -262,7 +262,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab {
}
public void save() {
App.settings.setLanguage((String) language.getSelectedItem());
Language.setLanguage((String) language.getSelectedItem());
App.settings.setTheme((String) theme.getSelectedItem());
App.settings.setDateFormat((String) dateFormat.getSelectedItem());
App.settings.setSortPacksAlphabetically(sortPacksAlphabetically.isSelected());

File diff suppressed because it is too large Load diff

View file

@ -148,9 +148,9 @@ msgstr ""
#: src\main\java\com\atlauncher\data\InstanceV2.java:573
#: src\main\java\com\atlauncher\data\json\Messages.java:52
#: src\main\java\com\atlauncher\data\json\Messages.java:73
#: src\main\java\com\atlauncher\data\Settings.java:264
#: src\main\java\com\atlauncher\data\Settings.java:282
#: src\main\java\com\atlauncher\data\Settings.java:300
#: src\main\java\com\atlauncher\data\Settings.java:261
#: src\main\java\com\atlauncher\data\Settings.java:279
#: src\main\java\com\atlauncher\data\Settings.java:297
#: src\main\java\com\atlauncher\managers\DialogManager.java:77
#: src\main\java\com\atlauncher\managers\DialogManager.java:85
msgid "Ok"
@ -281,37 +281,37 @@ msgstr ""
msgid "There is no note attached to this crash."
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:246
#: src\main\java\com\atlauncher\data\Settings.java:243
msgid "Running 32 Bit Java on 64 Bit Windows"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:247
#: src\main\java\com\atlauncher\data\Settings.java:244
msgid ""
"We have detected that you're running 64 bit Windows but not 64 bit Java.<br/"
"><br/>This will cause severe issues playing all packs if not fixed.<br/><br/"
">Do you want to close the launcher and learn how to fix this issue now?"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:261
#: src\main\java\com\atlauncher\data\Settings.java:258
msgid "Warning! You may not be able to play Minecraft"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:262
#: src\main\java\com\atlauncher\data\Settings.java:259
msgid ""
"You're using Java 9 or newer! Older modpacks may not work.<br/><br/>If you "
"have issues playing some packs, you may need to install Java 8 and set it to "
"be used in the launchers java settings"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:264
#: src\main\java\com\atlauncher\data\Settings.java:282
#: src\main\java\com\atlauncher\data\Settings.java:300
#: src\main\java\com\atlauncher\data\Settings.java:261
#: src\main\java\com\atlauncher\data\Settings.java:279
#: src\main\java\com\atlauncher\data\Settings.java:297
msgid "Download"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:265
#: src\main\java\com\atlauncher\data\Settings.java:283
#: src\main\java\com\atlauncher\data\Settings.java:301
#: src\main\java\com\atlauncher\data\Settings.java:262
#: src\main\java\com\atlauncher\data\Settings.java:280
#: src\main\java\com\atlauncher\data\Settings.java:298
#: src\main\java\com\atlauncher\gui\card\InstanceCard.java:209
#: src\main\java\com\atlauncher\gui\card\InstanceCard.java:398
#: src\main\java\com\atlauncher\gui\card\InstanceCard.java:476
@ -321,12 +321,12 @@ msgstr ""
msgid "Don't Remind Me Again"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:279
#: src\main\java\com\atlauncher\data\Settings.java:297
#: src\main\java\com\atlauncher\data\Settings.java:276
#: src\main\java\com\atlauncher\data\Settings.java:294
msgid "Unsupported Java Version"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:280
#: src\main\java\com\atlauncher\data\Settings.java:277
msgid ""
"You're using an unsupported version of Java. You should upgrade your Java to "
"at minimum Java 8 version 101.<br/><br/>Without doing this, some packs may "
@ -334,7 +334,7 @@ msgid ""
"install the latest Java"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:298
#: src\main\java\com\atlauncher\data\Settings.java:295
msgid ""
"You're using an unsupported version of Java. You should upgrade your Java to "
"at minimum Java 7.<br/><br/>Without Java 7 some mods will refuse to load "
@ -342,8 +342,8 @@ msgid ""
"page"
msgstr ""
#: src\main\java\com\atlauncher\data\Settings.java:521
#: src\main\java\com\atlauncher\data\Settings.java:522
#: src\main\java\com\atlauncher\data\Settings.java:518
#: src\main\java\com\atlauncher\data\Settings.java:519
msgid "Downloading Updates"
msgstr ""
@ -441,7 +441,7 @@ msgstr ""
#: src\main\java\com\atlauncher\gui\card\InstanceCard.java:564
#: src\main\java\com\atlauncher\gui\card\InstanceV2Card.java:97
#: src\main\java\com\atlauncher\gui\card\InstanceV2Card.java:531
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:115
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:114
msgid "Settings"
msgstr ""
@ -750,13 +750,15 @@ msgstr ""
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:121
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:132
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:212
msgid "Show"
#: src\main\java\com\atlauncher\gui\TrayMenu.java:87
msgid "Show Console"
msgstr ""
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:122
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:130
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:210
msgid "Hide"
#: src\main\java\com\atlauncher\gui\TrayMenu.java:92
msgid "Hide Console"
msgstr ""
#: src\main\java\com\atlauncher\gui\components\LauncherBottomBar.java:136
@ -994,8 +996,8 @@ msgstr ""
#: src\main\java\com\atlauncher\gui\dialogs\SetupDialog.java:128
#: src\main\java\com\atlauncher\gui\tabs\AccountsTab.java:142
#: src\main\java\com\atlauncher\gui\tabs\AccountsTab.java:379
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:56
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:123
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:55
#: src\main\java\com\atlauncher\gui\tabs\SettingsTab.java:122
msgid "Save"
msgstr ""
@ -1944,14 +1946,6 @@ msgid ""
"corruption of your saves"
msgstr ""
#: src\main\java\com\atlauncher\gui\TrayMenu.java:87
msgid "Show console"
msgstr ""
#: src\main\java\com\atlauncher\gui\TrayMenu.java:92
msgid "Hide console"
msgstr ""
#: src\main\java\com\atlauncher\workers\InstanceInstaller.java:198
msgid "Downloading Pack Version Definition"
msgstr ""