多语言应用程序:最好的方法? [英] multilanguage app: best way?

查看:23
本文介绍了多语言应用程序:最好的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有多语言应用程序的最佳方式是什么?我应该创建一组用我的语言编写的字符串,然后使用即时在线翻译的谷歌 api 吗?任何代码示例?还有,如何获取用户的语言以及如何将这些信息传递给api?

Which is the best way to have a multilanguage app? Should I create a set of strings written in my language and then use an google api that translates online on-the-fly? Any code example? And, how to get the language of the user and how to pass this information to the api?

推荐答案

我不相信你的字符串的即时翻译;即使是最好的自动翻译器也会产生不准确的输出.此外,以这种方式处理翻译会增加相当多的复杂性、开销和依赖性(例如,拥有网络连接).

I wouldn't trust on-the-fly translation of your strings; even the best automatic translators can produce inaccurate output. Additionally, you add a fair amount of complexity, overhead, and dependency (e.g., having a network connection) by handling translation this way.

拥有多语言应用程序"(如您所说)的问题是众所周知的,解决它的过程称为 国际化和本地化.一般来说,当您使用框架或编程语言时,您可以查找与该主题相关的现有包/库——几乎可以肯定的是,其他人已经花费了大量时间来构建一个好的机制来促进这一点.

The problem of having a "multilangauge app" (as you called it) is well-known, and the process of solving it is called internationalization and localization. In general, when you're working with a framework or programming language, you can look for existing packages/libraries relating to this topic -- it's almost a given that others have spent significant time building a good mechanism(s) to facilitate this.

Android 也不例外;它是在内置本地化支持的情况下开发的.Android 开发者文档有一个关于本地化的综合指南,您应该看看.您仍然需要以某种方式翻译您的文本,但是如何为用户提供特定于语言环境的消息的许多基础工作"已经为您准备好了.

Android is no exception; it's been developed with localization support built-in. The Android Developer Documentation has a comprehensive guide on Localization that you should take a look at. You'll still need to translate your text somehow, but a lot of the "groundwork" of how you can serve up locale-specific messages to the user has already been laid out for you.

最后一点——Android 文档还提供了一个名为Hello, L10n 的教程",它将引导您了解创建本地化应用程序的基础知识.希望这会有所帮助!

One last note -- the Android docs also provide a tutorial called "Hello, L10n", which walks you through the basics of creating a localized app. Hope this helps!

这篇关于多语言应用程序:最好的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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