如何使用 php 高效翻译网站内容,保持 SEO 友好? [英] How to efficiently translate website content with php, keeping it SEO friendly?

查看:49
本文介绍了如何使用 php 高效翻译网站内容,保持 SEO 友好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是场景:

我有一个网站,我将对其进行翻译并最终在其上应用良好的 SEO.哪种方法最适合翻译内容(菜单链接、大约 10 篇文章、alt 标签、标题标签、元标签、html lang 等),同时又容易被 Google、Bing、Yandex 和其他搜索引擎索引?

I have a website that I'll translate and eventually apply a good SEO on it. Which method is best for translate the content (menu links, about 10 articles, alt tags, title tags, meta tags, html lang, etc) while being easely indexed by Google, Bing, Yandex and other search engines?

我的第一个想法是使用由我自己制作的数组组成的翻译 php 函数(我已经有了它的原型),该函数获取内容并以用户语言显示.

My first idea is to use a translate php function that consists of arrays made by myself (I have a prototyope of it already) that takes the content and displays it in the user's language.

这是正确的道路吗?这里的问题是我想确保有一个动态系统,允许我在未来添加新语言.

Is this the right path? the problem here is that I wanted to be sure to have a dynamic system that allows me to add a new language in the future.

也许 MySql 是正确的选择?

Maybe MySql is the right choice?

该网站不使用 cms,我用 php 自己制作的,尽管我可以在需要时依赖 MySql.

The website doesn't use a cms, I made it by myself with php though I have no problem to rely on MySql if I need to.

先谢谢你:)

推荐答案

将所有文本存储在一个数据库中并应用另一个语言字段:

Store all texts inside a db and apply another field for language:

+----+---------+---------+
| id | text_en | text_de |
+----+---------+---------+
|  1 | English | Deutch  |
+----+---------+---------+

现在,当用户切换语言时,只需使用该语言的字段:

Now, when user switches languages, just use the field for that language:

$lang = 'en';
$query = "SELECT text_".$lang." FROM texts WHERE id = 1";

类似的东西.因此,您的所有客户端文本都将始终存储在数据库中.所以你的输出会是这样的:

Something like that. So, all your client side texts will be stored inside the db at all times. So your output will be like:

<div id="header"><?=get_db_text_for_id(1)?></div>

当然,你需要预防措施和更多的领域,但这是一般的想法.

Of course, you need precautions and some more field, but thats the general idea.

这篇关于如何使用 php 高效翻译网站内容,保持 SEO 友好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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