在 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,早上好",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?
推荐答案
您应该考虑一些因素.
网站会经常更新吗?如果是,由谁?你还是业主?您正在处理多少数据/信息?还有...您是否经常这样做(针对许多客户)?
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(或使用现有的).如果您确实需要考虑速度影响,您可以对其进行自定义,以便在完成网站后,您可以在可能的情况下导出静态 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.
相关文章