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
|
```java
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@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 {
|
public class ChineseController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -952,7 +952,7 @@ public class ChineseController extends FXBaseController {
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@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 {
|
public class EnglishController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -1024,7 +1024,7 @@ register.email=\u90ae\u7bb1
|
|||||||
|
|
||||||
#### Example
|
#### 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
|
```java
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@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 {
|
public class ChineseController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -978,7 +978,7 @@ public class ChineseController extends FXBaseController {
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@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 {
|
public class EnglishController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
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>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.2.0-RELEASE</version>
|
<version>1.2.0-RELEASE</version>
|
||||||
<packaging>pom</packaging>
|
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||||
|
<!-- <packaging>pom</packaging>-->
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -31,13 +31,14 @@
|
|||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 第三方动态代理库-->
|
<!-- 第三方动态代理库 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Junit单元测试 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- log4j 日志-->
|
<!-- log4j 日志 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
@@ -56,10 +57,24 @@
|
|||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>9.0.29</version>
|
<version>9.0.29</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<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>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -67,6 +82,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<!-- 过期的方法的警告-->
|
<!-- 过期的方法的警告-->
|
||||||
<arg>-Xlint:deprecation</arg>
|
<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.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -15,7 +15,7 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@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 {
|
public class ChineseController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
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.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@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 {
|
public class EnglishController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
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.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -14,7 +14,7 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@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 {
|
public class KoreanController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
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.annotation.FXScan;
|
||||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
@@ -11,7 +11,7 @@ import javafx.stage.Stage;
|
|||||||
* @date 2020/5/3 09:57
|
* @date 2020/5/3 09:57
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.languageDemo")
|
@FXScan(base = "cn.edu.scau.biubiusuisui.example.langDemo")
|
||||||
public class LanguageDemo extends Application {
|
public class LanguageDemo extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
@@ -34,8 +34,12 @@ public class FileUtil {
|
|||||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||||
*/
|
*/
|
||||||
public static String readFileFromResources(String filePath) {
|
public static String readFileFromResources(String filePath) {
|
||||||
String path = StringUtil.getRootPath(FileUtil.class.getClassLoader().getResource(filePath));
|
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
||||||
return readFile(path);
|
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
|
* @param name
|
||||||
* @return
|
* @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 文件名
|
* @param name 文件名
|
||||||
* @return
|
* @return
|
||||||
@@ -144,7 +144,7 @@ public class StringUtil {
|
|||||||
public static String getFileBaseName(String name) {
|
public static String getFileBaseName(String name) {
|
||||||
String result = "";
|
String result = "";
|
||||||
String[] tempStrs = name.split("/");
|
String[] tempStrs = name.split("/");
|
||||||
if (1 == tempStrs.length) { //只有文件名,即name: languageDemo.fxml
|
if (1 == tempStrs.length) { //只有文件名,即name: langDemo.fxml
|
||||||
result = StringUtil.trimExtension(name);
|
result = StringUtil.trimExtension(name);
|
||||||
} else {
|
} else {
|
||||||
result = StringUtil.trimExtension(tempStrs[tempStrs.length - 1]);
|
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