增加多语言配置文件

This commit is contained in:
许轲 2023-08-24 02:01:49 +08:00
parent 362e63d781
commit 2efb7d33a7
5 changed files with 20 additions and 17 deletions

2
.gitignore vendored
View File

@ -38,3 +38,5 @@ build/
/.idea/
/project.txt
logs/
/ch_language_pack.txt
/en_language_pack.txt

View File

@ -53,10 +53,20 @@ public class LunchApp extends Application {
double length = AppConstants.SCREEN_LENGTH;
String icon = AppConstants.APP_ICON;
scene = new Scene(root, width, length);
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/styles.css")).toExternalForm());
// 使用线程池加载关联文件并创建文本区域
List<String> rawParameters = getParameters().getRaw();
THREAD_POOL.execute(() -> {
LineNumberTextArea textArea = controller.openAssociatedFileAndCreateTextArea(rawParameters);
if (!Objects.isNull(textArea)) {
Platform.runLater(() -> controller.updateUiWithNewTextArea(textArea));
}
});
primaryStage.setTitle(title);
primaryStage.setWidth(width);
primaryStage.setHeight(length);
@ -68,14 +78,7 @@ public class LunchApp extends Application {
// 初始化快捷键
view.initShortcutKey();
// 使用线程池加载关联文件并创建文本区域
List<String> rawParameters = getParameters().getRaw();
THREAD_POOL.execute(() -> {
LineNumberTextArea textArea = controller.openAssociatedFileAndCreateTextArea(rawParameters);
if (!Objects.isNull(textArea)) {
Platform.runLater(() -> controller.updateUiWithNewTextArea(textArea));
}
});
}
@Override

View File

@ -23,7 +23,7 @@ public class NewFile implements EventHandler<ActionEvent> {
Config config = new Config();
Properties properties = config.readPropertiesFromFile();
String NEW_TEXT = properties.getProperty("NEW_TEXT");
String NEW_FILE = properties.getProperty("NEW_FILE");
/**
*
* 处理新建文件事件
@ -39,7 +39,7 @@ public class NewFile implements EventHandler<ActionEvent> {
// TODO: refactor统一TextArea新建绑定监听器入口
ViewManager viewManager = ViewManager.getInstance();
// 将Tab页添加到TabPane中
JNotepadTabPane.getInstance().addNewTab(new JNotepadTab(NEW_TEXT
JNotepadTabPane.getInstance().addNewTab(new JNotepadTab(NEW_FILE
+ viewManager.selfIncreaseAndGetTabIndex(),
textArea));

View File

@ -30,8 +30,7 @@ public class Controller implements ControllerInterface {
Config config = new Config();
Properties properties = config.readPropertiesFromFile();
String NEW_FILE = properties.getProperty("NEW_FILE","新建文件");
String NEW_FILE = properties.getProperty("NEW_FILE");
private static final Controller INSTANCE = new Controller();
private Controller() {

View File

@ -11,7 +11,7 @@ import static org.jcnc.jnotepad.constants.AppConstants.EN_LANGUAGE_PACK_NAME;
* @author 许轲
* 该类负责配置文件的读取和初始化操作
*/
public class Config {
public class Config {
String LANGUAGE_PACK_NAME;
@ -60,8 +60,9 @@ public class Config {
private static Properties getCHLanguagePack() {
Properties properties = new Properties();
properties.setProperty("TITLE", "JNotepad"); // 设置默认属性
properties.setProperty("NEW_TEXT", "新建文件");
properties.setProperty("NEW_FILE", "新建文件");
properties.setProperty("SAVA", "保存");
properties.setProperty("FILE", "文件");
properties.setProperty("NEW", "新建");
@ -76,7 +77,6 @@ public class Config {
properties.setProperty("COLUMN", "列数");
properties.setProperty("WORD_COUNT", "字数");
properties.setProperty("ENCODE", "编码");
properties.setProperty("NEW_FILE", "新建文件");
return properties;
}
@ -84,7 +84,7 @@ public class Config {
Properties properties = new Properties();
properties.setProperty("TITLE", "JNotepad");
properties.setProperty("NEW_TEXT", "New File");
properties.setProperty("NEW_FILE", "New File");
properties.setProperty("SAVA", "Save");
properties.setProperty("FILE", "File");
properties.setProperty("NEW", "New");
@ -99,7 +99,6 @@ public class Config {
properties.setProperty("COLUMN", "Column");
properties.setProperty("WORD_COUNT", "Word Count");
properties.setProperty("ENCODE", "Encoding");
properties.setProperty("NEW_FILE", "New File");
return properties;
}