- Add class-level documentation for all mapper and multilingual classes - Add complete javadoc for all public methods with @param and @return tags - Add field-level comments for better code readability - Improve documentation for initialization blocks and constructors Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
43 lines
945 B
Java
43 lines
945 B
Java
package com.imyeyu.lang.mapper;
|
|
|
|
import com.imyeyu.io.IO;
|
|
import com.imyeyu.java.bean.Language;
|
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.util.Properties;
|
|
|
|
/**
|
|
* 文件语言映射
|
|
*
|
|
* @author 夜雨
|
|
* @version 2024-04-09 01:00
|
|
*/
|
|
public class FileLanguageMap extends PropertiesLanguageMap {
|
|
|
|
/**
|
|
* 默认构造
|
|
*
|
|
* @param language 所属语言
|
|
*/
|
|
public FileLanguageMap(Language.Enum language) {
|
|
super(language);
|
|
}
|
|
|
|
/**
|
|
* 加载资源文件,格式化 % 为 {@link Language.Enum#toString()},示例:lang/app_%s.lang
|
|
*
|
|
* @param path 路径
|
|
*/
|
|
public void load(String path) {
|
|
try {
|
|
InputStream is = IO.getInputStream(path.formatted(language.toString()));
|
|
Properties properties = new Properties();
|
|
properties.load(new InputStreamReader(is));
|
|
load(properties);
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("load language properties file error", e);
|
|
}
|
|
}
|
|
}
|