两个单独的英语strings.xml android [英] Two separate english strings.xml android

查看:48
本文介绍了两个单独的英语strings.xml android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发自己的应用程序,以合并两个英语字符串.假设一个是英式英语,另一个是美式英语.请注意,我要使用相同的语言,但是要使用两个 strings.xml 文件.有没有办法做到这一点?

I am developing my app to incorporate two english language strings. Let's say one for British English other for US English. Please mind that I want to have same language but two strings.xml files. Is there a way to achieve this?

如何使用两个英文文件以编程方式更改应用语言?

Edit : How can I change app language programmatically with two english files ?

推荐答案

是的,您可以这样做.来自此处:

Yes, you can do that. From here:

该语言由两个字母的ISO 639-1语言代码定义,可以选择后面跟两个字母

The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r")

例如,对于英式英语字符串,应使用 res/values-en-rGB

For example, for British English strings, you should use res/values-en-rGB

编辑:要以编程方式更改语言,可以使用:

Edit: To change the language programatically, you can use:

locale = new Locale(Locale.ENGLISH, Locale.UK);

有关详情,请参见此处

请注意,由于两种语言都是英语,因此您只能根据用户选择来更新 Locale()构造函数的第二个参数

Please note that since both languages are English, you would only update the second parameter of the Locale() constructor based on user selection

这篇关于两个单独的英语strings.xml android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆