增加多语言配置文件
This commit is contained in:
parent
362e63d781
commit
2efb7d33a7
2
.gitignore
vendored
2
.gitignore
vendored
@ -38,3 +38,5 @@ build/
|
|||||||
/.idea/
|
/.idea/
|
||||||
/project.txt
|
/project.txt
|
||||||
logs/
|
logs/
|
||||||
|
/ch_language_pack.txt
|
||||||
|
/en_language_pack.txt
|
||||||
|
|||||||
@ -53,10 +53,20 @@ public class LunchApp extends Application {
|
|||||||
double length = AppConstants.SCREEN_LENGTH;
|
double length = AppConstants.SCREEN_LENGTH;
|
||||||
String icon = AppConstants.APP_ICON;
|
String icon = AppConstants.APP_ICON;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scene = new Scene(root, width, length);
|
scene = new Scene(root, width, length);
|
||||||
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
|
||||||
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/styles.css")).toExternalForm());
|
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.setTitle(title);
|
||||||
primaryStage.setWidth(width);
|
primaryStage.setWidth(width);
|
||||||
primaryStage.setHeight(length);
|
primaryStage.setHeight(length);
|
||||||
@ -68,14 +78,7 @@ public class LunchApp extends Application {
|
|||||||
// 初始化快捷键
|
// 初始化快捷键
|
||||||
view.initShortcutKey();
|
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
|
@Override
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class NewFile implements EventHandler<ActionEvent> {
|
|||||||
|
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
Properties properties = config.readPropertiesFromFile();
|
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新建、绑定监听器入口
|
// TODO: refactor:统一TextArea新建、绑定监听器入口
|
||||||
ViewManager viewManager = ViewManager.getInstance();
|
ViewManager viewManager = ViewManager.getInstance();
|
||||||
// 将Tab页添加到TabPane中
|
// 将Tab页添加到TabPane中
|
||||||
JNotepadTabPane.getInstance().addNewTab(new JNotepadTab(NEW_TEXT
|
JNotepadTabPane.getInstance().addNewTab(new JNotepadTab(NEW_FILE
|
||||||
+ viewManager.selfIncreaseAndGetTabIndex(),
|
+ viewManager.selfIncreaseAndGetTabIndex(),
|
||||||
textArea));
|
textArea));
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,7 @@ public class Controller implements ControllerInterface {
|
|||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
Properties properties = config.readPropertiesFromFile();
|
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 static final Controller INSTANCE = new Controller();
|
||||||
|
|
||||||
private Controller() {
|
private Controller() {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import static org.jcnc.jnotepad.constants.AppConstants.EN_LANGUAGE_PACK_NAME;
|
|||||||
* @author 许轲
|
* @author 许轲
|
||||||
* 该类负责配置文件的读取和初始化操作。
|
* 该类负责配置文件的读取和初始化操作。
|
||||||
*/
|
*/
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
String LANGUAGE_PACK_NAME;
|
String LANGUAGE_PACK_NAME;
|
||||||
|
|
||||||
@ -60,8 +60,9 @@ public class Config {
|
|||||||
|
|
||||||
private static Properties getCHLanguagePack() {
|
private static Properties getCHLanguagePack() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
||||||
properties.setProperty("TITLE", "JNotepad"); // 设置默认属性
|
properties.setProperty("TITLE", "JNotepad"); // 设置默认属性
|
||||||
properties.setProperty("NEW_TEXT", "新建文件");
|
properties.setProperty("NEW_FILE", "新建文件");
|
||||||
properties.setProperty("SAVA", "保存");
|
properties.setProperty("SAVA", "保存");
|
||||||
properties.setProperty("FILE", "文件");
|
properties.setProperty("FILE", "文件");
|
||||||
properties.setProperty("NEW", "新建");
|
properties.setProperty("NEW", "新建");
|
||||||
@ -76,7 +77,6 @@ public class Config {
|
|||||||
properties.setProperty("COLUMN", "列数");
|
properties.setProperty("COLUMN", "列数");
|
||||||
properties.setProperty("WORD_COUNT", "字数");
|
properties.setProperty("WORD_COUNT", "字数");
|
||||||
properties.setProperty("ENCODE", "编码");
|
properties.setProperty("ENCODE", "编码");
|
||||||
properties.setProperty("NEW_FILE", "新建文件");
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class Config {
|
|||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
||||||
properties.setProperty("TITLE", "JNotepad");
|
properties.setProperty("TITLE", "JNotepad");
|
||||||
properties.setProperty("NEW_TEXT", "New File");
|
properties.setProperty("NEW_FILE", "New File");
|
||||||
properties.setProperty("SAVA", "Save");
|
properties.setProperty("SAVA", "Save");
|
||||||
properties.setProperty("FILE", "File");
|
properties.setProperty("FILE", "File");
|
||||||
properties.setProperty("NEW", "New");
|
properties.setProperty("NEW", "New");
|
||||||
@ -99,7 +99,6 @@ public class Config {
|
|||||||
properties.setProperty("COLUMN", "Column");
|
properties.setProperty("COLUMN", "Column");
|
||||||
properties.setProperty("WORD_COUNT", "Word Count");
|
properties.setProperty("WORD_COUNT", "Word Count");
|
||||||
properties.setProperty("ENCODE", "Encoding");
|
properties.setProperty("ENCODE", "Encoding");
|
||||||
properties.setProperty("NEW_FILE", "New File");
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user