What is the best way to put a translation system in php website?(在 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.
这篇关于在 php 网站中放置翻译系统的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 php 网站中放置翻译系统的最佳方法是什么?
基础教程推荐
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01