feat(language): 添加多语言支持和文件关联管理器

- 新增 FileAssociationManager 类,用于管理文件扩展名与程序的关联
- 添加多语言支持,包括中文(简体、繁体)、英文、日文等
- 新增语言配置文件,定义了各种界面文本和提示信息
- 实现了在不同操作系统(Windows、macOS、Linux)上的文件关联功能
This commit is contained in:
tzdwindows 7
2025-03-02 20:54:15 +08:00
parent 0310d046aa
commit 452e6709a1
8 changed files with 1599 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package com.axis.innovators.box.util;
import java.io.IOException;
/**
* 文件扩展名管理器
* @author tzdwindows 7
*/
public class FileAssociationManager {
/**
* 将指定的文件扩展名与程序关联
* @param extension 文件扩展名,例如 ".txt"
*/
public static void associateFileExtension(String extension) throws IOException {
associateProgramWithExtension(extension, System.getProperty("user.dir") + "\\toolbox.exe");
}
/**
* 将指定的程序与文件扩展名关联
*
* @param extension 文件扩展名,例如 ".txt"
* @param programPath 程序的完整路径,例如 "C:\\Program Files\\Notepad++\\notepad++.exe"
* @throws IOException 如果关联失败时抛出异常
*/
private static void associateProgramWithExtension(String extension, String programPath) throws IOException {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
String command = "assoc " + extension + "=MyFileType";
Runtime.getRuntime().exec(command);
command = "ftype MyFileType=\"" + programPath + "\" \"%1\"";
Runtime.getRuntime().exec(command);
} else if (os.contains("mac")) {
String command = "duti -s " + programPath + " " + extension + " all";
Runtime.getRuntime().exec(command);
} else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
String command = "xdg-mime default " + programPath + " " + extension;
Runtime.getRuntime().exec(command);
} else {
throw new UnsupportedOperationException("Unsupported operating system: " + os);
}
}
}