如何处理动态站点本地化?

发布于 2024-09-02 14:57:31 字数 215 浏览 5 评论 0原文

我有一个目前全英文的网站。这是一款在线游戏,因此它有一堆带有静态文本的不同页面,以及数据库中的大量内容。

我正在努力向全球扩展,并准备发布该网站的一些本地化版本。但是,我不确定设置此功能的最佳方法,以便它对我来说是最容易管理的,也是对用户来说最容易使用的。

我应该将翻译后的文本存储在数据库中,还是应该以完全不同的方式完成?如果重要的话,该网站是用 PHP 编写的并使用 MySQL。

I've got a website that is currently all in English. It is an online game, so it has a bunch of different pages with static text, as well as a lot of content in a database.

I am trying to expand more globally and am gearing up to release some localizations of the site. However, I'm not sure about the best way to go about setting this up so that it'll be the easiest for me to manage and the easiest for users to use as well.

Should I be storing the translated texts in a database, or should this be done in a completely different way? If it matters at all, the site is written in PHP and uses MySQL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

把回忆走一遍 2024-09-09 14:57:32

我们使用 Zend 框架的混合方法。页面内容(所见即所得页面)存储在数据库中(每种语言一条记录,非本地化数据与本地化数据分离并存储在链接的不同表中),但字段标签和标准错误/反馈消息存储在 XML 或gettext 文件(每种语言一个文件)。

We use a mixed approach with the Zend framework. Page content (WYSIWYG pages) is stored in the DB (one record per language, non-localized data is separated from localized data and stored in different tables that are linked), but field labels and standard error/feedback messages are stored in XML or gettext files (one file per language).

多孤肩上扛 2024-09-09 14:57:32

我们使用混合方法:

  • CMS 页面翻译的数据库
  • 用于单词/句子翻译的 XML(静态文本、标签、错误消息等)

对于数据库,我们通常使用 2 个表:1 个用于主要内容,其他形式翻译,因此我们可以选择什么如果翻译不可用,请执行以下操作:以原始语言显示内容,或隐藏它。

对于XML,我们使用XLIFF格式,它可以很容易地被许多框架和软件支持

We use a mixed approach :

  • Database for CMS pages translations
  • XML for word/sentence translations (static texts, labels, error messages, etc)

For database we generaly use 2 tables : 1 for main content, other form translations, so we can choose what to do if translation is not available : display content in its original language, or hide it.

For XML, we use XLIFF format, which can be easily is supported by many frameworks and softwares

暮凉 2024-09-09 14:57:31

根据我的经验,手动完成所有翻译可能是一场真正的噩梦! %-)

我认为您必须将翻译重点放在仪表板命令站点上,例如导航菜单和所有其他用户配置文件设置以及站点周围的按钮等等!

通过将其包含到您的页面文件中来完成此操作,如下所示:

  include "./includes/languages/english.php";

在名为 ex.: english.php 的文件中放入这样的 ex

define('LAN_USER_LOGIN' , 'User Logged In');
define('LAN_USER_LOGOUT' , 'User Logged Out');
.....

等等
italian.php、spanish.php、french.php 等...并且在每个文件中都有相同的定义变量,但已翻译!

那么您可以让用户从国家列表中进行选择!顺便说一句,有很多方法可以做到这一点!

一种方法是

// if the user haven't selected a language before!!
if (empty($_SESSION['language'])) {
 $_SESSION['language'] = "EN";
} else {
$_SESSION['language'] = YOUR_LANG ;
}

对所有其他内容使用会话,我建议使用

等工具http://code.google.com/intl/it-IT/apis/ajaxlanguage/


注意:我建议您不要使用自动识别系统,因为它可以会导致非常烦人的体验,特别是如果您正在从另一个国家/地区观看该网站!或者只是你想从中选择,简单地让用户最终选择! ;-)

使用自动识别功能来自动完成注册! ;-)

希望这有帮助!

In my experience doing all the translations manually can be a real nightmare! %-)

i think you must focus your translation to the dashboard command site like the navigation menu and all other user profile settings, and buttons around the site and things like that!

do this by including into your pages file like this:

  include "./includes/languages/english.php";

in a file called ex.: english.php put like this ex

define('LAN_USER_LOGIN' , 'User Logged In');
define('LAN_USER_LOGOUT' , 'User Logged Out');
.....

and so on
italian.php, spanish.php, french.php ect... and in each of this files have the same defined variables but translated!

then you can let user chose from a list of Countries! many way of doing this btw!

one way can be by using session

// if the user haven't selected a language before!!
if (empty($_SESSION['language'])) {
 $_SESSION['language'] = "EN";
} else {
$_SESSION['language'] = YOUR_LANG ;
}

for all other content i recommend to use tools like

http://code.google.com/intl/it-IT/apis/ajaxlanguage/


NOTE: i recommend to you of don't use an auto recognition system, cause it can result in a very annoying experience expecially if you are watching the site from another country!! or just you want chose from, briefly let the user final choice! ;-)

use the auto recognition for autocompletation registration purpose! ;-)

hope this help!

旧伤慢歌 2024-09-09 14:57:31

我建议使用集中存储(这可能是一个 MySQL 数据库表,其中的“语言”列存储翻译所用的语言)。这也可以是 XML 文件,每种语言一个文件。

如果您正在寻找更多可能的文件格式,请查看 Zend Framework 的此文档页面: http://framework.zend.com/manual/en/zend.translate.adapter.html

对于翻译,如果您不使用框架,我会创建一个自定义函数或自定义类其中已经包括翻译。

另一种选择是使用标准 PHP 函数。只需寻找“_()”函数即可。我还没有使用过这些功能,只是刚刚发现它们,不确定它们的工作效果如何。

I'd suggest to use a centralized storage (this could be a MySQL database table, with a column "language" which stores what language the translation is in). This could also be XML files, one file per language.

If you are looking for even more possible file formats, look at this documentation page from Zend Framework: http://framework.zend.com/manual/en/zend.translate.adapter.html

For the translation I would either create a custom function or custom class, if you are not using a framework that already includes translation.

Another option is to use standard PHP functions. Just look for the "_()" function. I haven't worked with these functions though and only just found them, not sure how well they work.

丑丑阿 2024-09-09 14:57:31

我建议使用 gettext 与集成(例如 Zend)并存储在.po 文件格式。 .po 格式的编辑器可以使翻译工作更加公平。它也非常便携(因此得名),可以随身携带到其他游戏中。

I'd recommend using gettext with a framework that integrates (e.g. Zend) and storing in the .po file format. The .po format has editors that make the translation work fairly. It's also quite portable (thus the name) and could move with you onto other games.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文