简体   繁体   English

Android应用程序中的“社交”国际化-动态加载资源

[英]“Social” internationalization in Android application - loading resources dynamically

I have an idea to let users translate my application to their own languages. 我有一个让用户将我的应用程序翻译成自己的语言的想法。 I imagine this in this way: 我以这种方式想象:

If application is not translated to user's system language, English version of UI is displayed and user is asked for help in translation (it's obvious) Next, user is asked for translate some phrases from English to his mother tongue. 如果应用程序没有被翻译到用户的系统语言,则显示UI的英文版本,并要求用户在翻译的帮助(很明显)接下来,用户被要求从英语短语的一些翻译成自己的母语。 And asked to check some others translations. 并要求检查其他一些翻译。 (it's a bit of work, but nothing sophisticated) Hard part of my idea is: User presses "update translation" and text resources for this application are update to latest editions. (这需要一些工作,但是没有什么复杂的内容) 我的想法的难点是:用户按下“更新翻译”,并且此应用程序的文本资源更新为最新版本。 Of course it's possible to make frequent updates, but this approach has some disadvantages: 1. I have to make all of those updates frequently, and not all of users will be happy with it. 当然,可以进行频繁的更新,但是这种方法有一些缺点:1.我必须经常进行所有这些更新,并不是所有的用户都会对此感到满意。 2 Even if updates will be done weekly, time from make effort to get results will be too long form most of users, and probably, response will be not as good as it can be. 2即使每周进行一次更新,大多数用户从努力获得结果的时间也将太长,而且响应可能会不尽如人意。

Have you any idea how to load translations "on-line"? 您知道如何“在线”加载翻译吗?

I have done some internationalizations using: 我使用以下方法进行了一些国际化:

I will first check if they have some kind of api. 我将首先检查他们是否具有某种api。 If there is no API, I would check the gettext 's java implementation and handle translations with it. 如果没有API,我将检查gettext的java实现并使用它处理翻译。

Android currently doesn't support this. Android当前不支持此功能。 To accomplish what you want, you'd need to insert your own resource handling code to return strings everywhere they are used in your UI. 要完成所需的操作,您需要插入自己的资源处理代码以在用户界面中使用的所有字符串处返回字符串。 This means you couldn't let the framework load strings itself (for example no use of android:text="@string/something" in your layouts), and calling your own function to retrieve a string that wraps Resources.getString()/getText(). 这意味着您不能让框架本身加载字符串(例如,在布局中不使用android:text =“ @ string / something”),并且不能调用自己的函数来检索包装了Resources.getString()/的字符串。 getText()。

And you'll also need to deal with the fact that resource IDs are not stable and can change with every build of your app. 而且,您还需要处理以下事实:资源ID不稳定,并且可能随应用程序的每次构建而变化。

So you are looking at something quite non-trivial. 因此,您正在寻找一些非常重要的东西。

You could cache any of the current user's translations in a file on the SD/storage, and show it to that specific user. 您可以将当前用户的任何翻译内容缓存在SD /存储设备上的文件中,并将其显示给该特定用户。 Then, when it gets its weekly update, remove the cached file and start again? 然后,当它得到每周更新时,删除缓存的文件并重新开始?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM