Initial project

This commit is contained in:
Timi
2025-07-14 14:27:01 +08:00
parent 0adde06b54
commit 49d88e13e6
15 changed files with 767 additions and 94 deletions

View File

@@ -0,0 +1,39 @@
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 language) {
super(language);
}
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);
}
}
}