1.修复IDEA中无法加载resources文件夹的Bug;2.修改多语言Demo
This commit is contained in:
@@ -936,7 +936,7 @@ When an FXController needs to be internationalized and localized, you need to ad
|
||||
|
||||
```java
|
||||
@FXWindow(mainStage = true, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
public class ChineseController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToOtherLanguage() {
|
||||
@@ -952,7 +952,7 @@ public class ChineseController extends FXBaseController {
|
||||
|
||||
```java
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
public class EnglishController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToOtherLanguage() {
|
||||
@@ -1024,7 +1024,7 @@ register.email=\u90ae\u7bb1
|
||||
|
||||
#### Example
|
||||
|
||||
The sample code is in `cn.edu.scau.biubiusuisui.example.languageDemo`, the running result as follows:
|
||||
The sample code is in `cn.edu.scau.biubiusuisui.example.langDemo`, the running result as follows:
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -962,7 +962,7 @@ public enum FXPlusLocale {
|
||||
|
||||
```java
|
||||
@FXWindow(mainStage = true, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
public class ChineseController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToOtherLanguage() {
|
||||
@@ -978,7 +978,7 @@ public class ChineseController extends FXBaseController {
|
||||
|
||||
```java
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
public class EnglishController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToOtherLanguage() {
|
||||
@@ -1050,7 +1050,7 @@ register.email=\u90ae\u7bb1
|
||||
|
||||
#### 示例演示
|
||||
|
||||
示例代码在`cn.edu.scau.biubiusuisui.example.languageDemo`中,运行可得:
|
||||
示例代码在`cn.edu.scau.biubiusuisui.example.langDemo`中,运行可得:
|
||||
|
||||

|
||||
|
||||
|
||||
26
pom.xml
26
pom.xml
@@ -8,8 +8,8 @@
|
||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||
<artifactId>javafx-plus</artifactId>
|
||||
<version>1.2.0-RELEASE</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||
<!-- <packaging>pom</packaging>-->
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
@@ -31,13 +31,14 @@
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- 第三方动态代理库-->
|
||||
<!-- 第三方动态代理库 -->
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Junit单元测试 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@@ -45,7 +46,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- log4j 日志-->
|
||||
<!-- log4j 日志 -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
@@ -56,10 +57,24 @@
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>9.0.29</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!--配置Maven 对resource文件 过滤 -->
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.fxml</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -67,6 +82,7 @@
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<!-- 过期的方法的警告-->
|
||||
<arg>-Xlint:deprecation</arg>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -15,7 +15,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = true, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
public class ChineseController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||
public class EnglishController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXWindow(mainStage = false, title = "languageDemo")
|
||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.KOREAN)
|
||||
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.KOREAN)
|
||||
public class KoreanController extends FXBaseController {
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
@@ -11,7 +11,7 @@ import javafx.stage.Stage;
|
||||
* @date 2020/5/3 09:57
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.languageDemo")
|
||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.langDemo")
|
||||
public class LanguageDemo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
@@ -34,8 +34,12 @@ public class FileUtil {
|
||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||
*/
|
||||
public static String readFileFromResources(String filePath) {
|
||||
String path = StringUtil.getRootPath(FileUtil.class.getClassLoader().getResource(filePath));
|
||||
return readFile(path);
|
||||
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
||||
if (url != null) {
|
||||
String path = StringUtil.getRootPath(url);
|
||||
return readFile(path);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,7 +119,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> fxml/languageDemo/languageDemo.fxml
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> fxml/languageDemo/langDemo.fxml
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
@@ -135,7 +135,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> languageDemo
|
||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> languageDemo
|
||||
*
|
||||
* @param name 文件名
|
||||
* @return
|
||||
@@ -144,7 +144,7 @@ public class StringUtil {
|
||||
public static String getFileBaseName(String name) {
|
||||
String result = "";
|
||||
String[] tempStrs = name.split("/");
|
||||
if (1 == tempStrs.length) { //只有文件名,即name: languageDemo.fxml
|
||||
if (1 == tempStrs.length) { //只有文件名,即name: langDemo.fxml
|
||||
result = StringUtil.trimExtension(name);
|
||||
} else {
|
||||
result = StringUtil.trimExtension(tempStrs[tempStrs.length - 1]);
|
||||
|
||||
@@ -1 +1 @@
|
||||
dialog=弹窗
|
||||
dialog=\u5f39\u7a97
|
||||
@@ -1 +1 @@
|
||||
childrenController=子组件
|
||||
childrenController=\u5b50\u7ec4\u4ef6
|
||||
Reference in New Issue
Block a user