开发者

Android - Translating language codes

开发者 https://www.devze.com 2023-04-08 15:00 出处:网络
I get a response from a webservice that will return several language codes (ISO 639-2) as options. I now want to translate those into a human understandable word.

I get a response from a webservice that will return several language codes (ISO 639-2) as options. I now want to translate those into a human understandable word. For example:

eng-> English
ger -> 开发者_JS百科German
fre -> French

How would you translate those words. Should I be using the strings.xml? But how will I get the Resource ID of those words?

Thanks a lot


You can convert 639-2 codes to 639-1 code using answer for this question and after you get a 2 letter code construct Locale object and use getDisplayLanguage method

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号