android/res/values 下的strings.xml可以添加翻译
如果字符串写在android/res/raw,按如下,手动翻译,
代码片段
String info = "";
InputStream stream = null;
try {
// 翻译android/res/raw/newtork_privacy_policy.txt 20240619 begin
// 增加翻译文件newtork_privacy_policy_fr.txt newtork_privacy_policy_es.txt 等等
LocaleList Lanvar0 = LocalePicker.getLocales();
Map<String, InputStream> map = new HashMap<String, InputStream>();
map.put("fr_FR", mResources.openRawResource(R.raw.newtork_privacy_policy_fr));
map.put("es_ES", mResources.openRawResource(R.raw.newtork_privacy_policy_es));
map.put("de_DE", mResources.openRawResource(R.raw.newtork_privacy_policy_de));
map.put("el_GR", mResources.openRawResource(R.raw.newtork_privacy_policy_el));
map.put("it_IT", mResources.openRawResource(R.raw.newtork_privacy_policy_it));
map.put("nl_NL", mResources.openRawResource(R.raw.newtork_privacy_policy_nl));
map.put("pl_PL", mResources.openRawResource(R.raw.newtork_privacy_policy_pl));
map.put("pt_PT", mResources.openRawResource(R.raw.newtork_privacy_policy_po));
map.put("zh_TW", mResources.openRawResource(R.raw.newtork_privacy_policy_zho));
map.put("ko_KR", mResources.openRawResource(R.raw.newtork_privacy_policy_ko));
map.put("ja_JP", mResources.openRawResource(R.raw.newtork_privacy_policy_ja));
map.put("tr_TR", mResources.openRawResource(R.raw.newtork_privacy_policy_tr));
stream=map.get(Lanvar0.toString().replace("[","").replace("]",""));
if(stream == null) {
stream = mResources.openRawResource(R.raw.newtork_privacy_policy);
}
// 翻译android/res/raw/newtork_privacy_policy.txt 20240619 end
byte[] buffer = new byte[8192];
while (stream.read(buffer) != -1) {
info += new String(buffer);
Log.d("D", "[info] :" + info);
}
} catch (Exception ex) {
ex.printStackTrace();
}finally {
if (stream != null) {
try {
stream.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
content.setText(info);