Skip to content

Commit 5fff4f5

Browse files
committed
MagicEncoding3.0.0
1 parent 2a9987a commit 5fff4f5

18 files changed

+1029
-159
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# [JavaFX 项目]神奇编码_**MagicEncoding**(中文说明)
1+
# [JavaFX Project]**MagicEncoding**(English)
22

3-
[**English**](README_EN.md)
3+
[**中文说明**](README_ZH.md)
44

55
---
66

77
Website:
88

9-
[[JavaFX 项目]神奇编码_MagicEncoding | ZZHow](https://www.zzhow.com/MagicEncoding)
9+
[[JavaFX Project]MagicEncoding_EN | ZZHow](https://www.zzhow.com/MagicEncodingEN)
1010

1111
Source Code:
1212

@@ -18,21 +18,9 @@ https://github.com/ZZHow1024/MagicEncoding/releases
1818

1919
---
2020

21-
## 使用说明
22-
23-
- 确定您使用的操作系统。
24-
- Linux:
25-
- 选择 .deb安装包 / .rpm安装包。
26-
- macOS:
27-
- 确定您使用的 Mac 的芯片(Apple Silicon / Intel)。
28-
- 选择 .dmg磁盘镜像 / .pkg安装包。
29-
- Windows:
30-
- 选择 .zip压缩包 / .exe安装包 / .msi安装包。
31-
- 下载对应的文件。
32-
- Linux 和 macOS 需要执行安装操作后再运行,Windows 可直接运行 .zip 压缩包中的 .exe 可执行程序或选择 .exe 安装包与 .msi 安装包执行安装操作。
33-
- 启动 MagicEncoding。
34-
- 拖拽文件夹获取路径,填入需要筛选的后缀名(多种后缀名用“&”分隔),单击“查找文件”。
35-
- 选择原始编码与目标编码,单击“开始转换”。
21+
## License
22+
23+
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
3624

3725
---
3826

@@ -56,25 +44,35 @@ https://github.com/ZZHow1024/MagicEncoding/releases
5644

5745
---
5846

59-
## 功能介绍
47+
## Function Introduction
6048

49+
- MagicEncoding3.0.0
50+
- Automatic encoding recognition.
51+
- Single file conversion.
52+
- Support multiple languages.
53+
- Chinese (Simplified/Traditional)
54+
- English
6155
- MagicEncoding2.0.0
62-
- 拖拽文件夹获取路径。
63-
- 查找多种后缀名。
64-
- 支持覆盖原文件。
56+
- Drag the folder to get the path.
57+
- Search for multiple suffixes.
58+
- Support overwriting original files.
6559
- MagicEncoding1.0.0
66-
- "GBK" "UTF-8" 之间的编码转换。
67-
- 根据路径查找文件。
68-
- 支持根据文件后缀名筛选文件。
60+
- Encoding conversion between "GBK" and "UTF-8”.
61+
- Find files by path.
62+
- Support filtering files based on file extensions.
6963

7064
---
7165

72-
## **效果图**
66+
## **Renderings**
67+
68+
![MagicEncoding3.0.0_EN](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2Fa48f9fb0-5ca9-4b3e-aa65-5c0b9b8f53a4%2FMagicEncoding3.0.0_EN.png?table=block&id=e473a771-1ea7-42ab-9cc2-b124f8610072&t=e473a771-1ea7-42ab-9cc2-b124f8610072&width=1624&cache=v2)
69+
70+
MagicEncoding3.0.0_EN
7371

74-
![MagicEncoding2.0.0](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2Fcea3d468-2198-4819-a5c3-cb4f3f287dfa%2FMagicEncoding2.0.0.png?table=block&id=34817b71-f9d4-42b9-91e9-a477ad85b262&t=34817b71-f9d4-42b9-91e9-a477ad85b262&width=1624&cache=v2)
72+
![MagicEncoding2.0.0](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2Fbf42de01-57d9-4f5d-bb7c-3490b0db7ee1%2FMagicEncoding2.0.0.png?table=block&id=7ce8da63-3633-47ff-848c-94492101089c&t=7ce8da63-3633-47ff-848c-94492101089c&width=1624&cache=v2)
7573

7674
MagicEncoding2.0.0
7775

78-
![MagicEncoding1.0.0](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2F94657332-79a5-4e54-b697-8979784a6da3%2FMagicEncoding1.0.0.png?table=block&id=c8dd391f-0e31-455c-8dc3-2b154b44605f&t=c8dd391f-0e31-455c-8dc3-2b154b44605f&width=529&cache=v2)
76+
![MagicEncoding1.0.0](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F4b165318-6383-451c-8845-110b786c9f0a%2Fa91b3a7d-672f-4ea2-b167-4657fef038dc%2FMagicEncoding1.0.0.png?table=block&id=ed5e4ef9-7816-4961-9740-d423c5681168&t=ed5e4ef9-7816-4961-9740-d423c5681168&width=1624&cache=v2)
7977

8078
MagicEncoding1.0.0

README_EN.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
</properties>
1616

1717
<dependencies>
18+
<!-- https://mvnrepository.com/artifact/com.github.albfernandez/juniversalchardet -->
19+
<dependency>
20+
<groupId>com.github.albfernandez</groupId>
21+
<artifactId>juniversalchardet</artifactId>
22+
<version>2.5.0</version>
23+
</dependency>
24+
1825
<dependency>
1926
<groupId>org.openjfx</groupId>
2027
<artifactId>javafx-controls</artifactId>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.zzhow.magicencoding.controller;
2+
3+
import com.zzhow.magicencoding.ui.Application;
4+
import javafx.fxml.FXML;
5+
import javafx.scene.control.Label;
6+
7+
import java.util.ResourceBundle;
8+
9+
/**
10+
* @author ZZHow
11+
* @date 2024/9/8
12+
*/
13+
public class AboutController {
14+
15+
@FXML
16+
private Label Label1;
17+
@FXML
18+
private Label Label2;
19+
@FXML
20+
private Label Label3;
21+
22+
@FXML
23+
public void initialize() {
24+
switchLanguage();
25+
}
26+
27+
private void switchLanguage() {
28+
ResourceBundle bundle = Application.bundle;
29+
30+
Label1.setText(bundle.getString("MagicEncoding"));
31+
Label2.setText(bundle.getString("features"));
32+
Label3.setText(bundle.getString("features_content"));
33+
}
34+
}

src/main/java/com/zzhow/magicencoding/controller/MainController.java

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import com.zzhow.magicencoding.service.FileService;
44
import com.zzhow.magicencoding.service.impl.FileServiceImpl;
55
import com.zzhow.magicencoding.ui.About;
6+
import com.zzhow.magicencoding.ui.Application;
67
import com.zzhow.magicencoding.utils.MessageBox;
78
import javafx.fxml.FXML;
89
import javafx.scene.control.*;
10+
import javafx.scene.control.Label;
11+
import javafx.scene.control.TextField;
912
import javafx.scene.input.DragEvent;
1013
import javafx.scene.input.TransferMode;
1114

12-
import java.io.File;
15+
import java.io.*;
16+
import java.nio.charset.Charset;
1317
import java.util.List;
1418
import java.util.Locale;
1519
import java.util.ResourceBundle;
@@ -20,19 +24,41 @@ public class MainController {
2024
// 文件服务类
2125
private final FileService fileService = FileServiceImpl.getInstance();
2226

27+
@FXML
28+
private Label Label1;
29+
@FXML
30+
private Label Label2;
31+
@FXML
32+
private Label Label3;
33+
@FXML
34+
private Label Label4;
35+
@FXML
36+
private Label Label5;
37+
@FXML
38+
private Label Label6;
39+
@FXML
40+
private Label Label7;
41+
@FXML
42+
private Button Button1;
43+
@FXML
44+
private Button Button2;
45+
@FXML
46+
private Button Button3;
47+
@FXML
48+
private Button Button4;
2349
@FXML
2450
private ChoiceBox<String> originChoiceBox;
2551
@FXML
2652
private ChoiceBox<String> targetChoiceBox;
2753
@FXML
54+
private ChoiceBox<String> languageSelector;
55+
@FXML
2856
private TextField pathTextField;
2957
@FXML
3058
private TextField endWithTextField;
3159
@FXML
3260
private ListView<String> filesListView;
3361
@FXML
34-
private Label fileNumber;
35-
@FXML
3662
private CheckBox isOverwriteCheckBox;
3763

3864
public void clearFilesPath() {
@@ -42,9 +68,13 @@ public void clearFilesPath() {
4268

4369
@FXML
4470
private void initialize() {
45-
originChoiceBox.getItems().addAll("GBK", "UTF-8");
46-
originChoiceBox.setValue("GBK");
47-
targetChoiceBox.getItems().addAll("UTF-8", "GBK");
71+
SortedMap<String, Charset> stringCharsetSortedMap = Charset.availableCharsets();
72+
originChoiceBox.getItems().add("Auto");
73+
for (String charset : stringCharsetSortedMap.keySet()) {
74+
originChoiceBox.getItems().add(charset);
75+
targetChoiceBox.getItems().add(charset);
76+
}
77+
originChoiceBox.setValue("Auto");
4878
targetChoiceBox.setValue("UTF-8");
4979
languageSelector.getItems().addAll("简体中文", "繁體中文", "English");
5080

@@ -96,7 +126,7 @@ private void onReset() {
96126
this.clearFilesPath();
97127
pathTextField.setText("");
98128
endWithTextField.setText("");
99-
fileNumber.setText("文件数目:0");
129+
Label7.setText(Application.bundle.getString("Label7") + "0");
100130
}
101131

102132
@FXML
@@ -106,7 +136,8 @@ private void onFindFiles() {
106136
String endWith = endWithTextField.getText();
107137

108138
filesListView.setItems(fileService.findFiles(absolutePath, endWith));
109-
fileNumber.setText("文件数目:" + fileService.getTargetFileList().size());
139+
Label7.setText(Application.bundle.getString("Label7")
140+
+ fileService.getTargetFileList().size());
110141
}
111142

112143
@FXML
@@ -117,10 +148,14 @@ private void onTransform() {
117148
boolean isOverwrite = this.isOverwriteCheckBox.isSelected();
118149

119150
if (fileService.transform(absolutePath, originCharset, targetCharset, isOverwrite)) {
120-
MessageBox.success("执行成功", "已将" + fileService.getTargetFileList().size()
121-
+ "个文件从 \"" + originCharset + "\" 转为 \"" + targetCharset + "\"");
151+
MessageBox.success(Application.bundle.getString("success1_headerText"),
152+
"\"" + originCharset + "\"\"" + targetCharset + "\""
153+
+ Application.bundle.getString("success1_contentText")
154+
+ fileService.getTargetFileList().size());
155+
this.onFindFiles();
122156
} else {
123-
MessageBox.error("执行失败", "请重试");
157+
MessageBox.error(Application.bundle.getString("error3_headerText")
158+
, Application.bundle.getString("error3_contentText"));
124159
}
125160
}
126161

0 commit comments

Comments
 (0)