如何为开发者和最终用户提供国际化服务
许多 Android 应用程序的 i18n 支持都很差,这是一个可以理解的原因,因为它为开发人员增加了很多工作。
从直观和文化的角度来看,如果最终用户可以自己翻译应用程序,并且 OTA 共享翻译,而无需重新安装应用程序本身,那将是一件好事。
在概念上;就像维基百科一样,有些可以轻松添加内容,有些则只使用现有内容。
当然,对于应用程序开发人员和愿意转录的人来说,该服务尽可能易于使用非常重要。
为了简单起见,这是我正在考虑的解决方案;
开发人员视角:
开发人员在打开活动/布局时使用自定义的 setContentView 来搜索 xml 条目的翻译。 (如下)
定制版本作为免费下载的库/类提供...,将 i18n 功能或多或少地变成一个行。
用户视角:
用户下载不带任何翻译的应用
应用启动时,它会检查手机上运行的区域设置,并查找翻译后的 xml -SD 共享空间中的文件。
如果没有或旧的转录 xml(上面),请尝试从互联网服务下载新的(异步)。这都是由上面的库完成的,不需要意图。
翻译者视角:
- 单独的应用程序可为使用上述 i18n 服务的任何应用程序提供翻译。 (可能只是一个网络应用程序),对翻译器/输入进行某种形式的质量检查。
问题: 现在,为了使其高效工作,开发人员必须使用 AeasyAP,而最流畅的解决方案是 setContentView 的自定义版本,它只需从外部 xml 加载翻译后的值,而不是 apk 中的值。
这是否可能,如果不可能,您建议的解决方案是什么?
(当然,新年快乐,feliz ano novo,blwyddyn newydd dda,Gott Nytt År,kontan ane nouvo,szczęśliwego nowego roku ...)
问候, /T
Many android applications have quite poor i18n-support, and for an understandable reason, as it adds much work for the developer.
From a both intuitive and cultural point of view it would be a good thing if end-users could translate the apps themself, and OTA share the translation, without reinstalling the app itself.
In concept; as wikipedia, some add content easily, others only use what's there.
It's of course important that the service is as easy as possible to use, both for app-developers, and people willing to transcribe.
To keep it simple, this is the solution I'm concidering;
Developer perspective:
Developer uses a customized setContentView when open activities/layouts that will seach for thanslations of xml-entries. (below)
The customized version is provided as a free downloadable library/class..., turning the i18n feature to more or less a one liner.
User perspective:
User downloads app without any translation
As app launches, it checks locale running at phone, and will look for a translated xml-file at shared space in SD.
If no or old transcribed xml (above), try to download new from internet-service (ansync). This is all done by library above, no need for intents.
Translator perspective:
- Separate app to provide translations for any app using the i18n service above. (Could be just a webapp), with some form of QA on translators/input.
QUESTION:
Now, for this to work efficiently, it has to be AeasyAP for the developer to even bother, and the most fluent solution would be a customized version of setContentView, that simply loads the translated values from external xml, instead of the ones in the apk.
Is this possible at all, and if not, what's your suggested solutions?
(And of course, Happy New Year, feliz ano novo, blwyddyn newydd dda, Gott Nytt År, kontan ane nouvo, szczęśliwego nowego roku ...)
Regards,
/T
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,只有当有人(可能是你或我或其他人)重写
setContentView()
时才有可能 - 因为我只在那里看到问题的根源。让我解释一下:如何做到这一点? 2 个选项:
OwnActivity
类,该类将重新定义setContentView(int id )
。例如:OwnActivity.setContentView()
在 SQLite 内部查找具有当前语言环境的已知 XML id,如果没有找到,它会从 res/layout 中扩充 XMLEDIT1:
您可以像这样覆盖它:
Yes, it's possible only if someone (probably you or me or others) will rewrite
setContentView()
- since I see root of a problem only there. Let me explain:setContentView
How to do that? 2 options:
OwnActivity
class which will redefinesetContentView(int id)
. For instance:OwnActivity.setContentView()
looks inside SQLite for known XML id with current locale, if not found it inflates XML from res/layoutEDIT1:
You can override it like:
关于问题的第二部分,可以使用现有的翻译服务,例如 Launchpad,它在 < gettext 的 em>.po 文件。
不过,还有 android2po,它可以在 Android 的 XML 和 gettext .po 格式之间进行转换。
Launchpad 上已经有一些 Android 翻译,例如 ConnectBot,但是该服务需要登录才能贡献。或者,您应该查看可用的基于 gettext 的网络翻译套件,您也可以自己运行,例如 Pootle。
抱歉,我不允许发布多个 URL。请用谷歌搜索其余部分:(
Regarding the second part of the question, it is possible to use an existing translation service like Launchpad, which operates on .po files for gettext.
There is however android2po, which can transform between Android's XML and the gettext .po format.
There are already some Android translations on Launchpad, e.g. ConnectBot, however the service requires a login to be able to contribute. Alternatively, you should look at the available gettext-based web translator suites you can run yourself as well, like Pootle.
Sorry, I am not allowed to post more than one URL. Please google the rest up :(
layoutinflator.factory 是我一直在寻找的......
layoutinflator.factory is what I was looking for...