您如何将现有的 Web 应用程序转换为多语言应用程序? [英] How would you transform a pre-existing web app into a multilingual one?

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

问题描述

我将从事一个项目,其中一个相当大的网络应用程序需要调整以处理多种语言.这个东西使用手工编写的 PHP 代码运行,但它非常干净.

I am going to work on a project where a fairly large web app needs to tweaked to handle several languages. The thing runs with a hand crafted PHP code but it's pretty clean.

我想知道这样做的最佳方法是什么?

I was wondering what would be the best way to do that?

  1. 自己制作一些东西,尝试适应实际的架构.

  1. Making something on my own, trying to fit the actual architecture.

使用可以为我管理 i18n 的框架(例如 Symfony)重写其中的很大一部分?

Rewriting a good part of it using a framework (e.g., Symfony) that will manage i18n for me?

对于选项 1,我应该在哪里存储 i18n 数据?*.po、xliff、纯数据库?

For option 1, where should I store the i18n data? *.po, xliff, pure DB?

我想到了一个替代方案:仅将 Symfony 用于翻译,但将控制器设置为按原样加载网站.很快,但很脏.另一方面,它允许我们进行下一个修改,慢慢地移动到完整的 Symfony:这个网站真的是一个很好的候选者.

I thought about an alternative: using Symfony only for the translation, but setting the controller to load the website as it already is. Quick, but dirty. On the other hand, it allows us to make the next modification, moving slowly to full Symfony: this web site is really a good candidate for that.

但也许有一些独立的翻译引擎会比整个网络框架做得更好.有点像用火箭筒杀死苍蝇……

But maybe there are some standalone translation engines that would do the job better than an entire web framework. It's a bit like using a bazooka to kill a fly...

推荐答案

有很多方法可以解决这个问题.它们都不是最好的方法",而且在短期或长期内都存在问题.首先要说的是,多语言站点并不容易,翻译人员和可爱的人很难与之合作,大多数程序员只将问题视为技术问题.关于您是翻译还是本地化,还有另一个维度,超出了本答案的范围.这涉及查看目标受众的文化习俗,然后根据该文化定制语言、风格、布局、颜色、字体等.最后,不要使用机器翻译,机器翻译,任何严肃的事情或者如果它需要准确,并且在获取翻译时确保他们从外语翻译成他们的母语,这意味着他们理解目标语言的所有细微差别.

There are a number of ways of tackling this. None of them "the best way" and all of them with problems in the short term or the long term. The very first thing to say is that multi lingual sites are not easy, translators and lovely people but hard to work with and most programmers see the problem as a technical one only. There is also another dimension, outside the scope of this answer, as to whether you are translating or localising. This involves looking at the target audiences cultural mores and then tailoring language, style, layout, colour, typeface etc., to that culture. Finally do not use MT, Machine Translation, for anything serious or if it needs to be accurate and when acquiring translators ensure that they are translating from a foreign language into their native language which means that they understand all the nuances of the target language.

没错.解决方案.在您不想重写站点的基础上,只需克隆您拥有的站点并将副本翻译成目标语言.假设代码库稳定,您可以使用 VCS 来管理任何代码更改.您可以调整站点的各个部分以适应目标语言,例如法语文本平均比等效的英语文本大 30%,因此使用一个站点来交付这意味着您可能(将)遇到格式问题并且需要交换根据语言输入和输出不同的 css 文件.这似乎是一种笨拙的方法,但这些网站还能存在多久?这样做的管理开销很可能低于其他选项.

Right. Solutions. On the basis that you do not want to rewrite the site then simply clone the site you have and translate the copies to the target language. Assuming the code base is stable you can use a VCS to manage any code changes. You can tweak individual parts of the site to fit the target language, for example French text is on average 30% larger than the equivalent English text so using one site to deliver this means you may (will) have formatting problems and need to swap a different css file in and out depending on the language. It might seem a clunky way to do it but then how long are the sites going to exist? The management overhead of doing it this way may well be less than other options.

无需重建的第二种方式.用标签替换当前站点中的所有内容,然后将不同的语言放在文件或数据库表中,嗅探用户所需的语言(您是否有注册用户可以进行首选项或您想获得浏览器语言标签,还是它将是 URL dot-com dot-fr, dot-de 做出选择),然后用目标语言替换标签.然后,您需要分别解决尺寸问题和图像问题.当Symfony 和Zend 等框架实现l10n 时,此解决方案有效.

Second way without rebuilding. Replace all content in the current site with tags and then put the different language in file or db tables, sniff the users desired language (do you have registered users who can make a preference or do you want to get the browser language tag, or is it going to be URL dot-com dot-fr, dot-de that make the choice) and then replace the tags with the target language. Then you need to address the sizing issues and the image issues separately. This solution is in effect when frameworks like Symfony and Zend do to implement l10n.

然后您可以使用框架或 gettext 进行重建,并且可能有一个更清晰的解决方案,但请记住,框架旨在解决其他问题,而不是翻译,并且翻译组件已作为部分解决方案而非完整解决方案进入框架.

Then you could rebuild with a framework or with gettext and possibly have a cleaner solution but remember frameworks were designed to solve other problems, not translation and the translation component has come into the framework as partial solution not the full one.

所有解决方案的最大问题是持续维护.因为您不仅要维护代码库,还要维护多种语言库.除非你们所有的解决方案都非常聪明有效,否则正在进行的任务将是困难的.

The big problem with all the solutions is ongoing maintenance. Because not only do you have a code base but also multiple language bases to maintain. Unless you all in one solution is really clever and effective then to ongoing task will be difficult.

这篇关于您如何将现有的 Web 应用程序转换为多语言应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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