Rewrite i18n implementation
This commit is contained in:
parent
a094d4fc9d
commit
f332083e27
17 changed files with 182 additions and 23 deletions
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
<name>NS-USBloader</name>
|
<name>NS-USBloader</name>
|
||||||
|
|
||||||
<artifactId>ns-usbloader</artifactId>
|
<artifactId>ns-usbloader</artifactId>
|
||||||
<version>4.1-SNAPSHOT</version>
|
<version>4.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<url>https://github.com/developersu/ns-usbloader/</url>
|
<url>https://github.com/developersu/ns-usbloader/</url>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -27,9 +27,14 @@ public class AppPreferences {
|
||||||
private static final AppPreferences INSTANCE = new AppPreferences();
|
private static final AppPreferences INSTANCE = new AppPreferences();
|
||||||
public static AppPreferences getInstance() { return INSTANCE; }
|
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(){
|
public String getTheme(){
|
||||||
String theme = preferences.get("THEME", "/res/app_dark.css"); // Don't let user to change settings manually
|
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 String getRecent(){ return preferences.get("RECENT", System.getProperty("user.home")); }
|
||||||
public void setRecent(String path){ preferences.put("RECENT", path); }
|
public void setRecent(String path){ preferences.put("RECENT", path); }
|
||||||
//------------ SETTINGS ------------------//
|
//------------ 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 boolean getNsIpValidationNeeded() {return preferences.getBoolean("NSIPVALIDATION", true);}
|
||||||
public void setNsIpValidationNeeded(boolean need){preferences.putBoolean("NSIPVALIDATION", need);}
|
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 boolean getTfXCI(){return preferences.getBoolean("TF_XCI", true);}
|
||||||
public void setTfXCI(boolean prop){ preferences.putBoolean("TF_XCI", prop); }
|
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 boolean getNspFileFilterGL(){return preferences.getBoolean("GL_NSP_FILTER", false); }
|
||||||
public void setNspFileFilterGL(boolean prop){preferences.putBoolean("GL_NSP_FILTER", prop);}
|
public void setNspFileFilterGL(boolean prop){preferences.putBoolean("GL_NSP_FILTER", prop);}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import javafx.scene.layout.VBox;
|
||||||
import nsusbloader.AppPreferences;
|
import nsusbloader.AppPreferences;
|
||||||
import nsusbloader.ServiceWindow;
|
import nsusbloader.ServiceWindow;
|
||||||
import nsusbloader.ModelControllers.UpdatesChecker;
|
import nsusbloader.ModelControllers.UpdatesChecker;
|
||||||
|
import nsusbloader.UI.LocaleUiStringHolder;
|
||||||
import nsusbloader.Utilities.WindowsDrivers.DriversInstall;
|
import nsusbloader.Utilities.WindowsDrivers.DriversInstall;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -73,7 +74,7 @@ public class SettingsController implements Initializable {
|
||||||
checkForUpdBtn,
|
checkForUpdBtn,
|
||||||
drvInstBtn;
|
drvInstBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private ChoiceBox<String> langCB;
|
private ChoiceBox<LocaleUiStringHolder> langCB;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ChoiceBox<String> glVersionChoiceBox;
|
private ChoiceBox<String> glVersionChoiceBox;
|
||||||
|
@ -220,8 +221,8 @@ public class SettingsController implements Initializable {
|
||||||
tfXciSpprtCb.setSelected(AppPreferences.getInstance().getTfXCI());
|
tfXciSpprtCb.setSelected(AppPreferences.getInstance().getTfXCI());
|
||||||
|
|
||||||
// Language settings area
|
// Language settings area
|
||||||
ObservableList<String> langCBObsList = FXCollections.observableArrayList();
|
ObservableList<LocaleUiStringHolder> langCBObsList = FXCollections.observableArrayList();
|
||||||
langCBObsList.add("eng");
|
//langCBObsList.add(new LocaleUiStringHolder(new Locale("en", "US")));
|
||||||
|
|
||||||
File jarFile;
|
File jarFile;
|
||||||
try{
|
try{
|
||||||
|
@ -239,8 +240,14 @@ public class SettingsController implements Initializable {
|
||||||
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
|
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
String name = entries.nextElement().getName();
|
String name = entries.nextElement().getName();
|
||||||
if (name.startsWith("locale_"))
|
if (name.startsWith("locale_")){
|
||||||
langCBObsList.add(name.substring(7, 10));
|
try{
|
||||||
|
langCBObsList.add(new LocaleUiStringHolder(name));
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
jar.close();
|
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
|
String[] filesList = new File(resourceURL.getFile()).list(); // Screw it. This WON'T produce NullPointerException
|
||||||
|
|
||||||
for (String jarFileName : filesList)
|
for (String jarFileName : filesList)
|
||||||
if (jarFileName.startsWith("locale_"))
|
if (jarFileName.startsWith("locale_")){
|
||||||
langCBObsList.add(jarFileName.substring(7, 10));
|
try{
|
||||||
|
langCBObsList.add(new LocaleUiStringHolder(jarFileName));
|
||||||
}
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
langCBObsList.sort(Comparator.comparing(LocaleUiStringHolder::toString));
|
||||||
|
|
||||||
langCB.setItems(langCBObsList);
|
langCB.setItems(langCBObsList);
|
||||||
if (langCBObsList.contains(AppPreferences.getInstance().getLanguage()))
|
// TODO: REFACTOR THIS SHIT; INCAPSULATE AND MOVE OUT FROM HERE
|
||||||
langCB.getSelectionModel().select(AppPreferences.getInstance().getLanguage());
|
Locale localeFromPrefs = AppPreferences.getInstance().getLocale();
|
||||||
else
|
boolean notExists = true;
|
||||||
langCB.getSelectionModel().select("eng");
|
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->{
|
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("",
|
ServiceWindow.getInfoNotification("",
|
||||||
ResourceBundle.getBundle("locale", new Locale(langCB.getSelectionModel().getSelectedItem()))
|
ResourceBundle.getBundle("locale", newLocale).getString("windowBodyRestartToApplyLang"));
|
||||||
.getString("windowBodyRestartToApplyLang"));
|
|
||||||
});
|
});
|
||||||
// Set supported old versions
|
// Set supported old versions
|
||||||
glVersionChoiceBox.getItems().addAll(glSupportedVersions);
|
glVersionChoiceBox.getItems().addAll(glSupportedVersions);
|
||||||
|
|
|
@ -32,14 +32,14 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class NSLMain extends Application {
|
public class NSLMain extends Application {
|
||||||
|
|
||||||
public static final String appVersion = "v4.1";
|
public static final String appVersion = "v4.2";
|
||||||
public static boolean isCli;
|
public static boolean isCli;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml"));
|
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);
|
ResourceBundle rb = ResourceBundle.getBundle("locale", userLocale);
|
||||||
|
|
||||||
loader.setResources(rb);
|
loader.setResources(rb);
|
||||||
|
|
59
src/main/java/nsusbloader/UI/LocaleUiStringHolder.java
Normal file
59
src/main/java/nsusbloader/UI/LocaleUiStringHolder.java
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
<HBox alignment="CENTER_LEFT" spacing="5.0">
|
<HBox alignment="CENTER_LEFT" spacing="5.0">
|
||||||
<children>
|
<children>
|
||||||
<Label text="%tab2_Lbl_Language" />
|
<Label text="%tab2_Lbl_Language" />
|
||||||
<ChoiceBox fx:id="langCB" prefWidth="100.0" />
|
<ChoiceBox fx:id="langCB" prefWidth="180.0" />
|
||||||
<Button fx:id="langBtn" mnemonicParsing="false" text="OK" />
|
<Button fx:id="langBtn" mnemonicParsing="false" text="OK" />
|
||||||
<VBox alignment="CENTER_RIGHT" HBox.hgrow="ALWAYS">
|
<VBox alignment="CENTER_RIGHT" HBox.hgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
||||||
|
|
71
src/main/resources/locale_en_US.properties
Normal file
71
src/main/resources/locale_en_US.properties
Normal file
|
@ -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.
|
Loading…
Reference in a new issue