Files
timi-lang/src/main/java/com/imyeyu/lang/mapper/ResourcesLanguageMap.java
Timi 20bef9263b add comprehensive javadoc comments for all classes
- 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>
2026-01-13 15:33:25 +08:00

48 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.imyeyu.lang.mapper;
import com.imyeyu.io.IO;
import com.imyeyu.java.bean.Language;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
/**
* 资源文件语言映射
*
* @author 夜雨
* @version 2024-04-09 00:55
*/
public class ResourcesLanguageMap extends PropertiesLanguageMap {
/**
* 默认构造
*
* @param language 所属语言
*/
public ResourcesLanguageMap(Language.Enum language) {
super(language);
}
/**
* 加载资源文件,格式化 % 为 {@link Language.Enum#toString()}示例lang/app_%s.lang
*
* @param path 路径
*/
public void load(String path) {
try {
InputStream is = IO.resourceToInputStream(getClass(), path.formatted(language.toString()));
if (is != null) {
Properties properties = new Properties();
properties.load(new InputStreamReader(is));
load(properties);
} else {
throw new FileNotFoundException("not found language properties file: " + path.formatted(language.toString()));
}
} catch (Exception e) {
throw new RuntimeException("load language properties file error", e);
}
}
}