Android:资产目录和多语言 [英] Android : assets dir and multi language
问题描述
早上好.到我的android应用程序中,我在资产目录中有一个文件changelog.我还有creato目录资产-它,并且已经用意大利语输入了文件changelog,但是当我启动该应用程序时,即使设备语言设置为意大利语,它也总是将文件显示到资产目录中.为什么?
Good morning. Into my android application I have in assets directory a file changelog. I have creato also the directory assets-it and I have put into the file changelog in italian language but when I start the application it always display the file into assets directory also if the device language is set to italian. Why ?
推荐答案
这是预期的行为.可以用这种方式本地化res/
中的资源,但是assets/
目录不能.
That is the expected behavior. Resources in res/
can be localized in that manner, but the assets/
directory cannot.
由于它只是一个变更日志,因此建议将其作为本地化的字符串资源存储在res/values-LOCALE/
中.如果您确实想要资产的本地化,则可以通过获取当前的语言环境和加载来手动重新创建资产,例如assets/changelog-en
和assets/changelog-it
,但是我认为通常这不是一个好主意,对于您的情况当然不是必需的.
Since it's just a changelog, I'd recommend storing it as a localized string resource in res/values-LOCALE/
. If you really want localization of assets, you could manually recreate it by getting the current locale and loading, e.g. assets/changelog-en
, vs. assets/changelog-it
, but I think that would generally not be a good idea, and it certainly isn't necessary in your case.
这篇关于Android:资产目录和多语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!