本地化Web应用程序的选项 [英] Options for localizing web app

查看:112
本文介绍了本地化Web应用程序的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个国际网站(PHP,自定义轻量级MVC框架),该网站需要以用户的母语显示内容.内容主要是文本,但也可能是图像.

I'm working on an international website (PHP, custom lightweight MVC framework) which needs to show content in the user's native language. Content will primarily be text, but may be images as well.

我们当前的解决方案是一个巨大的文件,为每个要翻译的文本提供单独的功能,并在每个功能中使用切换大小写.这变得很难维护,也没有特别的可扩展性.

Our current solution is one giant file, with separate functions for every piece of text to be translated, and a switch case in each function. This has become terrible to maintain and ins't particularly scalable either.

我们的首要任务是性能,可维护性(如果需要修复错误或进行更改,应在尽可能少的地方发生)和可扩展性(允许翻译者添加更多语言).我们希望至少可以使用10-12种语言.我们还需要考虑文本内的HTML内容,例如<p></p>和链接.当前,我们在返回的文本中包含HTML内联(显然,它不是特别可维护的).我们考虑过的一些选项:

Our priorities are performance, maintainability (if we need to fix a bug or make a change, should happen in as few places as possible), and extensibility (allowing translators to add more languages). We expect to be working with at least 10–12 languages. We also need to consider HTML content inside text, such as <p></p> and links. Currently, we have the HTML inline in the returned text (which, obviously, isn't particularly maintainable). Some of the options we've considered:

用于翻译的数据库表,每种语言都有列
+可扩展到大量内容
-翻译人员不容易添加/更改内容
-大量的数据库事务,性能降低

Database table for translations, with columns for each language
+ Scalable to lots of content
- Not easy for translators to add/change content
- Lots of DB transactions, slow performance

一个纯文本文件(CSV)
+转换为电子表格,翻译人员可以轻松使用
-将巨大的文件加载到内存中可能会影响性能(不确定会产生多大的影响)
-可能难以维护

One flat text file (CSV)
+ Converts to spreadsheets, easy for translators to work with
- Loading a giant file into memory may impact performance (not sure how much of an impact this will actually make)
- May be hard to maintain

每种语言一个纯文本文件
+易于翻译人员使用
?性能更好(也许)

One flat text file per language
+ Easy for translators to work with
? Better for performance (maybe)

持续集成系统,可为每个(MVC)视图创建具有嵌入式本地化内容的多个版本
+最适合表现
+可以与CSV或其他易于翻译的格式结合使用
-设置复杂
-可能难以维护

Continuous integration system that creates multiple versions of each (MVC) view with embedded, localized content
+ Best for performance
+ Can be combined with CSV or other format that is easy for translators to use
- Complex to set up
- May be difficult to maintain

我们一直在寻找有关如何在Web应用程序中交付翻译内容的指南,但没有发现任何有用的信息.这些选项中哪一个是最好的,我们还没有考虑其他哪些实现?

We've been looking for guides on how to deliver translated content in web apps, but haven't come across anything useful. Which one of these options is the best, and what other implementations have we not considered?

推荐答案

可以使用php的 gettext 扩展名和 .po 文件类型来实现本地化. Po文件类型与FNU gettext关联.使用POEdit,我们可以创建.po和.mo文件 .po文件包含文本消息,您的转换如下所示

Localization can be achieved using gettext extension of php and .po file type. Po file type is associated with FNU gettext. Using POEdit we can create .po and .mo file .po file contains text messages with your conversion as below

eng.po

msgid"

msgstr"

ch.po

msgid"

msgstr"

有关详细信息,请在此处阅读 http://php.net/manual/zh/book .gettext.php

For detail please read here http://php.net/manual/en/book.gettext.php

这篇关于本地化Web应用程序的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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