diff --git a/pom.xml b/pom.xml
index 48cdd9f..e5c313f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
NS-USBloaderns-usbloader
- 4.1-SNAPSHOT
+ 4.2-SNAPSHOThttps://github.com/developersu/ns-usbloader/
diff --git a/src/main/java/nsusbloader/AppPreferences.java b/src/main/java/nsusbloader/AppPreferences.java
index 311e48d..a08682a 100644
--- a/src/main/java/nsusbloader/AppPreferences.java
+++ b/src/main/java/nsusbloader/AppPreferences.java
@@ -27,9 +27,14 @@ public class AppPreferences {
private static final AppPreferences INSTANCE = new AppPreferences();
public static AppPreferences getInstance() { return INSTANCE; }
- private Preferences preferences;
+ private final Preferences preferences;
+ private final Locale locale;
- private AppPreferences(){ preferences = Preferences.userRoot().node("NS-USBloader"); }
+ private AppPreferences(){
+ this.preferences = Preferences.userRoot().node("NS-USBloader");
+ String localeCode = preferences.get("locale", Locale.getDefault().toString());
+ this.locale = new Locale(localeCode.substring(0, 2), localeCode.substring(3, 5));
+ }
public String getTheme(){
String theme = preferences.get("THEME", "/res/app_dark.css"); // Don't let user to change settings manually
@@ -59,6 +64,10 @@ public class AppPreferences {
public String getRecent(){ return preferences.get("RECENT", System.getProperty("user.home")); }
public void setRecent(String path){ preferences.put("RECENT", path); }
//------------ SETTINGS ------------------//
+
+ public Locale getLocale(){ return this.locale; }
+ public void setLocale(String langStr){ preferences.put("locale", langStr); }
+
public boolean getNsIpValidationNeeded() {return preferences.getBoolean("NSIPVALIDATION", true);}
public void setNsIpValidationNeeded(boolean need){preferences.putBoolean("NSIPVALIDATION", need);}
@@ -96,9 +105,6 @@ public class AppPreferences {
public boolean getTfXCI(){return preferences.getBoolean("TF_XCI", true);}
public void setTfXCI(boolean prop){ preferences.putBoolean("TF_XCI", prop); }
- public String getLanguage(){return preferences.get("USR_LANG", Locale.getDefault().getISO3Language());}
- public void setLanguage(String langStr){preferences.put("USR_LANG", langStr);}
-
public boolean getNspFileFilterGL(){return preferences.getBoolean("GL_NSP_FILTER", false); }
public void setNspFileFilterGL(boolean prop){preferences.putBoolean("GL_NSP_FILTER", prop);}
diff --git a/src/main/java/nsusbloader/Controllers/SettingsController.java b/src/main/java/nsusbloader/Controllers/SettingsController.java
index baa542d..e67083c 100644
--- a/src/main/java/nsusbloader/Controllers/SettingsController.java
+++ b/src/main/java/nsusbloader/Controllers/SettingsController.java
@@ -30,6 +30,7 @@ import javafx.scene.layout.VBox;
import nsusbloader.AppPreferences;
import nsusbloader.ServiceWindow;
import nsusbloader.ModelControllers.UpdatesChecker;
+import nsusbloader.UI.LocaleUiStringHolder;
import nsusbloader.Utilities.WindowsDrivers.DriversInstall;
import java.io.File;
@@ -73,7 +74,7 @@ public class SettingsController implements Initializable {
checkForUpdBtn,
drvInstBtn;
@FXML
- private ChoiceBox langCB;
+ private ChoiceBox langCB;
@FXML
private ChoiceBox glVersionChoiceBox;
@@ -220,8 +221,8 @@ public class SettingsController implements Initializable {
tfXciSpprtCb.setSelected(AppPreferences.getInstance().getTfXCI());
// Language settings area
- ObservableList langCBObsList = FXCollections.observableArrayList();
- langCBObsList.add("eng");
+ ObservableList langCBObsList = FXCollections.observableArrayList();
+ //langCBObsList.add(new LocaleUiStringHolder(new Locale("en", "US")));
File jarFile;
try{
@@ -239,8 +240,14 @@ public class SettingsController implements Initializable {
Enumeration entries = jar.entries(); //gives ALL entries in jar
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
- if (name.startsWith("locale_"))
- langCBObsList.add(name.substring(7, 10));
+ if (name.startsWith("locale_")){
+ try{
+ langCBObsList.add(new LocaleUiStringHolder(name));
+ }
+ catch (Exception e){
+ e.printStackTrace();
+ }
+ }
}
jar.close();
}
@@ -253,21 +260,37 @@ public class SettingsController implements Initializable {
String[] filesList = new File(resourceURL.getFile()).list(); // Screw it. This WON'T produce NullPointerException
for (String jarFileName : filesList)
- if (jarFileName.startsWith("locale_"))
- langCBObsList.add(jarFileName.substring(7, 10));
+ if (jarFileName.startsWith("locale_")){
+ try{
+ langCBObsList.add(new LocaleUiStringHolder(jarFileName));
+ }
+ catch (Exception e){
+ e.printStackTrace();
+ }
+ }
}
+ langCBObsList.sort(Comparator.comparing(LocaleUiStringHolder::toString));
langCB.setItems(langCBObsList);
- if (langCBObsList.contains(AppPreferences.getInstance().getLanguage()))
- langCB.getSelectionModel().select(AppPreferences.getInstance().getLanguage());
- else
- langCB.getSelectionModel().select("eng");
+ // TODO: REFACTOR THIS SHIT; INCAPSULATE AND MOVE OUT FROM HERE
+ Locale localeFromPrefs = AppPreferences.getInstance().getLocale();
+ boolean notExists = true;
+ for (LocaleUiStringHolder holderItem: langCBObsList){
+ if (holderItem.getLocale().equals(localeFromPrefs)){
+ langCB.getSelectionModel().select(holderItem);
+ notExists = false;
+ break;
+ }
+ }
+ if (notExists)
+ langCB.getSelectionModel().select(0);
langBtn.setOnAction(e->{
- AppPreferences.getInstance().setLanguage(langCB.getSelectionModel().getSelectedItem());
+ LocaleUiStringHolder localeHolder = langCB.getSelectionModel().getSelectedItem();
+ AppPreferences.getInstance().setLocale(localeHolder.getLocaleCode());
+ Locale newLocale = localeHolder.getLocale();
ServiceWindow.getInfoNotification("",
- ResourceBundle.getBundle("locale", new Locale(langCB.getSelectionModel().getSelectedItem()))
- .getString("windowBodyRestartToApplyLang"));
+ ResourceBundle.getBundle("locale", newLocale).getString("windowBodyRestartToApplyLang"));
});
// Set supported old versions
glVersionChoiceBox.getItems().addAll(glSupportedVersions);
diff --git a/src/main/java/nsusbloader/NSLMain.java b/src/main/java/nsusbloader/NSLMain.java
index f18f653..f5b0f93 100644
--- a/src/main/java/nsusbloader/NSLMain.java
+++ b/src/main/java/nsusbloader/NSLMain.java
@@ -32,14 +32,14 @@ import java.util.ResourceBundle;
public class NSLMain extends Application {
- public static final String appVersion = "v4.1";
+ public static final String appVersion = "v4.2";
public static boolean isCli;
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml"));
- Locale userLocale = new Locale(AppPreferences.getInstance().getLanguage()); // NOTE: user locale based on ISO3 Language codes
+ Locale userLocale = AppPreferences.getInstance().getLocale();
ResourceBundle rb = ResourceBundle.getBundle("locale", userLocale);
loader.setResources(rb);
diff --git a/src/main/java/nsusbloader/UI/LocaleUiStringHolder.java b/src/main/java/nsusbloader/UI/LocaleUiStringHolder.java
new file mode 100644
index 0000000..b5637c7
--- /dev/null
+++ b/src/main/java/nsusbloader/UI/LocaleUiStringHolder.java
@@ -0,0 +1,59 @@
+/*
+ Copyright 2019-2020 Dmitry Isaenko
+
+ This file is part of NS-USBloader.
+
+ NS-USBloader is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ NS-USBloader is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NS-USBloader. If not, see .
+*/
+package nsusbloader.UI;
+
+import nsusbloader.cli.IncorrectSetupException;
+
+import java.util.Locale;
+
+public class LocaleUiStringHolder {
+
+ private final Locale locale;
+ private final String localeCode;
+ private final String languageName;
+
+ public LocaleUiStringHolder(Locale locale){
+ this.locale = locale;
+ this.localeCode = locale.toString();
+ this.languageName = locale.getDisplayLanguage(locale) + " (" + locale + ")";
+ }
+
+ public LocaleUiStringHolder(String localeFileName) throws Exception{
+ if (localeFileName.length() < 12)
+ throw new IncorrectSetupException("Locale filename is incorrect: "+localeFileName);
+ String country = localeFileName.substring(7, 9);
+ String language = localeFileName.substring(10, 12);
+ this.locale = new Locale(country, language);
+ this.localeCode = locale.toString();
+ this.languageName = locale.getDisplayLanguage(locale) + " (" + locale + ")";
+ }
+
+ @Override
+ public String toString(){
+ return languageName;
+ }
+
+ public String getLocaleCode(){
+ return localeCode;
+ };
+
+ public Locale getLocale() {
+ return locale;
+ }
+}
diff --git a/src/main/resources/SettingsTab.fxml b/src/main/resources/SettingsTab.fxml
index 6676a5f..d1b7e80 100644
--- a/src/main/resources/SettingsTab.fxml
+++ b/src/main/resources/SettingsTab.fxml
@@ -20,7 +20,7 @@
-
+
diff --git a/src/main/resources/locale_deu.properties b/src/main/resources/locale_de_DE.properties
similarity index 100%
rename from src/main/resources/locale_deu.properties
rename to src/main/resources/locale_de_DE.properties
diff --git a/src/main/resources/locale_en_US.properties b/src/main/resources/locale_en_US.properties
new file mode 100644
index 0000000..d1fd9ea
--- /dev/null
+++ b/src/main/resources/locale_en_US.properties
@@ -0,0 +1,71 @@
+btn_OpenFile=Select files
+btn_Upload=Upload to NS
+tab3_Txt_EnteredAsMsg1=You have been entered as:
+tab3_Txt_EnteredAsMsg2=You should be root or have configured 'udev' rules for this user to avoid any issues.
+tab3_Txt_FilesToUploadTitle=Files to upload:
+tab3_Txt_GreetingsMessage=Welcome to NS-USBloader
+tab3_Txt_NoFolderOrFileSelected=No files selected: nothing to upload.
+windowBodyConfirmExit=Data transfer is in progress and closing this application will interrupt it.\nIt's the worse thing you can do now.\nInterrupt proccess and exit?
+windowTitleConfirmExit=No, don't do this!
+btn_Stop=Interrupt
+tab3_Txt_GreetingsMessage2=--\n\
+Source: https://github.com/developersu/ns-usbloader/\n\
+Site: https://developersu.blogspot.com/search/label/NS-USBloader\n\
+Dmitry Isaenko [developer.su]
+tab1_table_Lbl_Status=Status
+tab1_table_Lbl_FileName=File name
+tab1_table_Lbl_Size=Size
+tab1_table_Lbl_Upload=Upload?
+tab1_table_contextMenu_Btn_BtnDelete=Remove
+tab1_table_contextMenu_Btn_DeleteAll=Remove all
+tab2_Lbl_HostIP=Host IP
+tab1_Lbl_NSIP=NS IP:
+tab2_Cb_ValidateNSHostName=Always validate NS IP input.
+windowBodyBadIp=Are you sure that you entered NS IP address correctly?
+windowTitleBadIp=IP address of NS most likely incorrect
+tab2_Cb_ExpertMode=Expert mode (NET setup)
+tab2_Lbl_HostPort=port
+tab2_Cb_AutoDetectIp=Auto-detect IP
+tab2_Cb_RandSelectPort=Randomly get port
+tab2_Cb_DontServeRequests=Don't serve requests
+tab2_Lbl_DontServeRequestsDesc=If selected, this computer won't reply to NSP files requests coming from NS (over the net) and use defined host settings to tell TinFoil where should it look for files.
+tab2_Lbl_HostExtra=extra
+windowTitleErrorPort=Port set incorrectly!
+windowBodyErrorPort=Port can't be 0 or greater than 65535.
+tab2_Cb_AutoCheckForUpdates=Auto check for updates
+windowTitleNewVersionAval=New version available
+windowTitleNewVersionNOTAval=No new versions available
+windowTitleNewVersionUnknown=Unable to check for new versions
+windowBodyNewVersionUnknown=Something went wrong\nMaybe internet unavailable, or GitHub is down
+windowBodyNewVersionNOTAval=You're using the latest version
+tab2_Cb_AllowXciNszXcz=Allow XCI / NSZ / XCZ files selection for Tinfoil
+tab2_Lbl_AllowXciNszXczDesc=Used by applications that support XCI/NSZ/XCZ and utilizes Tinfoil transfer protocol. Don't change if not sure. Enable for Awoo Installer.
+tab2_Lbl_Language=Language
+windowBodyRestartToApplyLang=Please restart application to apply changes.
+btn_OpenSplitFile=Select split NSP
+tab2_Lbl_ApplicationSettings=Main settings
+tabSplMrg_Lbl_SplitNMergeTitle=Split & merge files tool
+tabSplMrg_RadioBtn_Split=Split
+tabSplMrg_RadioBtn_Merge=Merge
+tabSplMrg_Txt_File=File:
+tabSplMrg_Txt_Folder=Split file (folder):
+tabSplMrg_Btn_SelectFile=Select File
+tabSplMrg_Btn_SelectFolder=Select Folder
+tabSplMrg_Lbl_SaveToLocation=Save to:
+tabSplMrg_Btn_ChangeSaveToLocation=Change
+tabSplMrg_Btn_Convert=Convert
+windowTitleError=Error
+windowBodyPleaseFinishTransfersFirst=Unable to split/merge files when application USB/Network process active. Please interrupt active transfers first.
+done_txt=Done!
+failure_txt=Failed
+btn_Select=Select
+btn_InjectPayloader=Inject payload
+tabNXDT_Btn_Start=Start!
+tab2_Btn_InstallDrivers=Download and install drivers
+windowTitleDownloadDrivers=Download and install drivers
+windowBodyDownloadDrivers=Downloading drivers (libusbK v3.0.7.0)...
+btn_Cancel=Cancel
+btn_Close=Close
+tab2_Cb_GlVersion=GoldLeaf version
+tab2_Cb_GLshowNspOnly=Show only *.nsp in GoldLeaf.
+windowBodyPleaseStopOtherProcessFirst=Please stop other active process before continuing.
\ No newline at end of file
diff --git a/src/main/resources/locale_spa.properties b/src/main/resources/locale_es_ES.properties
similarity index 100%
rename from src/main/resources/locale_spa.properties
rename to src/main/resources/locale_es_ES.properties
diff --git a/src/main/resources/locale_fra.properties b/src/main/resources/locale_fr_FR.properties
similarity index 100%
rename from src/main/resources/locale_fra.properties
rename to src/main/resources/locale_fr_FR.properties
diff --git a/src/main/resources/locale_ita.properties b/src/main/resources/locale_it_IT.properties
similarity index 100%
rename from src/main/resources/locale_ita.properties
rename to src/main/resources/locale_it_IT.properties
diff --git a/src/main/resources/locale_kor.properties b/src/main/resources/locale_ko_KR.properties
similarity index 100%
rename from src/main/resources/locale_kor.properties
rename to src/main/resources/locale_ko_KR.properties
diff --git a/src/main/resources/locale_por.properties b/src/main/resources/locale_pt_BR.properties
similarity index 100%
rename from src/main/resources/locale_por.properties
rename to src/main/resources/locale_pt_BR.properties
diff --git a/src/main/resources/locale_rus.properties b/src/main/resources/locale_ru_RU.properties
similarity index 100%
rename from src/main/resources/locale_rus.properties
rename to src/main/resources/locale_ru_RU.properties
diff --git a/src/main/resources/locale_ukr.properties b/src/main/resources/locale_uk_UA.properties
similarity index 100%
rename from src/main/resources/locale_ukr.properties
rename to src/main/resources/locale_uk_UA.properties
diff --git a/src/main/resources/locale_vie.properties b/src/main/resources/locale_vi_VN.properties
similarity index 100%
rename from src/main/resources/locale_vie.properties
rename to src/main/resources/locale_vi_VN.properties
diff --git a/src/main/resources/locale_zho.properties b/src/main/resources/locale_zh_CN.properties
similarity index 100%
rename from src/main/resources/locale_zho.properties
rename to src/main/resources/locale_zh_CN.properties