在php网站中放置翻译系统的最佳方法是什么? [英] What is the best way to put a translation system in php website?

查看:64
本文介绍了在php网站中放置翻译系统的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP开发网站,我希望为用户提供从德语到英语的轻松切换.

I'm developing a website in PHP and I'd like to give the user to switch from German to English easily.

因此,必须考虑翻译政策:

So, a translation politic must be considered:

我是否应该将数据及其翻译存储在数据库表中((1,"Hello","hallo"),(2,"Good morning","Guten Tag"))等等.

Should I store the data and its translation in a database table ((1, "Hello", "hallo"), (2, "Good morning", "Guten Tag") etc .. ?

还是应该使用".mo"文件进行存储?
哪种方法最好?
优点和缺点是什么?

Or should I use the ".mo" Files to store it?
Which way is the best?
What are the pros and the cons?

推荐答案

您应该考虑一些因素.

There are some factors you should consider.

网站会经常更新吗?如果是,是谁?您还是老板?您要处理多少数据/信息?而且...您是否经常这样做(对于许多客户而言)?

Will the website be updated frequenytly? if yes, by whom? you or the owner? how much data / information are you dealing with? and also... are you doing this frequently (for many clients) ?

除非您的流量非常高(每天有数十万次页面访问),否则我很难认为使用关系数据库会严重影响速度.

I can hardly think that using a relational database can couse any serious speed impacts unless you are having VERY high traffic (several hundreds of thousands of pageviews per day).

您应该经常这样做(对于许多客户)不要再想了:建立CMS(或使用现有的CMS).如果确实需要考虑速度影响,则可以对其进行自定义,以便在完成网站操作后可以导出静态HTML页面.

Should you be doing this frequently (for lots of clients) think no further: build up a CMS (or use an existing one). If you really need to consider speed impact, you can customize it so that when you are done with the website you can export static HTML pages where possible.

如果您要经常更新,则与上述相同. 如果客户端必须更新(而不是您),则再次需要CMS. 如果您要处理大量信息(大量文章),则需要CMS.

If you are updating frequently, the same as above applies. If the client has to update (and not you), again, you need a CMS. If you are dealing with lots of infomration (big and lots of articles), you need a CMS.

总而言之,CMS将帮助您快速建立网站结构,快速添加内容,并且不必担心代码,因为它可重复使用.

All in all, a CMS will help you build up your website structure fast, add content fast and not worry that much about code since it will be reusable.

现在,如果您只需要快速创建一个小型网站,则可以使用硬编码的数组和数据文件轻松地做到这一点.

Now, if you just need to create a small website fast, you can easily do this with hardcoded arrays and datafiles.

这篇关于在php网站中放置翻译系统的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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