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

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

问题描述

我将在一个项目中工作,该项目需要调整一个相当大的Web应用程序以处理几种语言.这东西是用手工制作的PHP代码运行的,但是很干净.

我想知道什么是最好的方法?

  1. 自己做点什么,尝试适应实际的体系结构.

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

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

我想到了一个替代方案:仅将Symfony用于翻译,但是将控制器设置为按原样加载网站.很快,但是很脏.另一方面,它使我们可以进行下一个修改,并逐渐过渡到完整的Symfony:此网站确实是一个不错的选择.

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

解决方案

有多种解决方法.它们都不是最佳方法",并且它们都短期或长期都存在问题. 首先要说的是,多语言站点并不容易,翻译人员和可爱的人却很难与他们合作,并且大多数程序员都认为该问题只是技术上的问题.关于您正在翻译还是本地化,还有另一个维度,超出了此答案的范围.这包括查看目标受众的文化习俗,然后针对该文化定制语言,样式,布局,颜色,字体等.最后,不要将MT(机器翻译)用于任何严重的问题或需要准确的事情,并且在获取翻译人员时,请确保将他们从外语翻译成母语,这意味着他们了解目标语言的所有细微差别. /p>

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

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

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

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

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. Making something on my own, trying to fit the actual architecture.

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

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

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.

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.

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.

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天全站免登陆