Initial project
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user