来自服务器的Android string.xml资源文件 [英] Android string.xml resource file from server

查看:115
本文介绍了来自服务器的Android string.xml资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经知道,例如我们无法在运行时更改res文件夹的值和文件,

As we know already e.g. we cannot change res folder values and files at runtime,

我正在开发一个应用程序,其中我们支持25种以上的语言,由于这些字符串文件,APK的大小急剧增加,我们非常关注APK的大小,因此我们不想保留所有内容这些string.xml文件在项目本地(apk内).

I am working on an app, in which we are supporting more than 25 language, hance APK size is increased drastically due to these string files, we are very concerned about the APK size, so we don't want to keep all these string.xml files locally in the project(inside apk).

我们在想的是,我们将仅在res中保留英语string.xml,并且应根据需要在应用程序启动时从服务器下载所有其他语言环境string.xml.

What we are thinking is we will keep only English string.xml inside res, and all others locale string.xml should be downloaded from the server on application launch on the need basis.

因此,我们计划创建自己的getResource( key, currentLocale),然后从将从服务器下载的XML(或文本)文件中读取该文件.

So we are planning to create our own getResource( key, currentLocale), and then this will read from an XML(or text) file which will downloaded from the server.

请提出任何更好的主意或解决方法,

Please suggest any better ideas or some ways around it,

感谢支持

推荐答案

您了解

Do you know about Android App Bundle? it is a new way to publish your app to Google Play, and you don't need to refactor your code to use it, and you downloaded apk from Play Store will be more small?

来自Google Developers:

新的应用发布格式Android App Bundle更加实用 构建和发布您的应用的有效方法. Android应用程式套件 让您更轻松地在较小的应用程序尺寸中提供出色的体验, 允许当今可用的各种Android设备.它是 易于切换.您无需重构代码即可启动 受益于更小的应用程序.

The new app publishing format, the Android App Bundle, is a more efficient way to build and release your app. The Android App Bundle lets you more easily deliver a great experience in a smaller app size, allowing for the huge variety of Android devices available today. It's easy to switch. You don’t need to refactor your code to start benefiting from a smaller app.

在Android Studio 3.2或更高版本以及Unity 2018.3 beta版本中可用.

Available in Android Studio 3.2 or later and the Unity 2018.3 beta release.

因此,如果您的项目有25种语言,并且我的设备已将英语配置为设备语言,那么当我下载您的APP时,它将仅获得strings.xml文件,而其他strings.xml文件仍保留在Google Play中,并且将您的设备语言更改为葡萄牙语,Google Play应用将尝试获取新的葡萄牙语strings.xml并删除带有英文文本的旧文件.

So if your project have 25 languages and my device have configured English as the device language, when I go to download your APP it will get only the strings.xml file the others strings.xml remain in Google Play, and if you change your device language to Portuguese, Google Play App will try to get the new strings.xml for Portuguese and delete the old file with English text.

请先尝试以下方法,然后再尝试其他方法,因为这是推荐的方法,您无需执行其他任何操作,只需将应用程序作为应用程序捆绑包生成并发送到Play商店,如果您要进行测试,请下载您的应用,然后更改设备语言,您会看到Google Play再次下载该应用的新语言.

Please before you try another option try this first as it is the recommended way and you do not need to do anything else, just generate your app as App Bundle and send to Play Store and if you want to test, download your app then change the device language you will see Google Play downloading the app's new language again.

希望我仍然可以帮助您.

Hope I helped you anyway.

这篇关于来自服务器的Android string.xml资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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