android/res/raw/xxx.txt 手动添加翻译

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);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值