问题描述
我正在开发自己的应用程序,以合并两个英语字符串.假设一个是英式英语,另一个是美式英语.请注意,我要使用相同的语言,但是要使用两个 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:
例如,对于英式英语字符串,应使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!