在网站上使用多种语言的最佳方式是什么? [英] Whats the best way to use multiple languages on a website?

查看:30
本文介绍了在网站上使用多种语言的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道实现基于多语言模板的网站的最佳方法是什么.所以说我想用英语和德语提供我的网站,有一些不同的方法.我的兴趣主要是关于 SEO,所以这对搜索引擎来说是最好的方式.

I was wondering what would be the best way to achieve a multi-language template based website. So say I want to offer my website in Englisch and German there are some different methods. My interest is mainly about SEO, so which would be the best way for search engines.

我经常看到的第一种方式是为每种语言使用不同的目录,例如 www.example.com 用于英语,www.example.com/de/用于德语翻译.这样做的缺点是:更改文件时,必须手动更改每个目录中的ist.对于搜索引擎来说,这两个目录会被视为重复内容,不是吗?

The first way that I often see is using different directories for each language, for example www.example.com for English and www.example.com/de/ for the German translation. The disadvantage of this is: when changing a file, ist has to be changed in every directory manually. And for search engines the two directories would be concerned as duplicate content, wouldnt they?

我知道的第二种方法是使用一些 GET 值,例如 www.example.com?lang=de,然后设置一个 cookie.但是这样搜索引擎甚至可能找不到不同的语言.

The second way I know is just using some GET value like www.example.com?lang=de and then setting a cookie. But this way search engines probably wont even find the different languages.

那么有没有其他方法或者哪种方法最好?

So is there another way or which one is the best?

推荐答案

我在国际化网站上工作直到今年.我们一直从 SEO 专家那里得到的建议是根据 URL 区分语言 - 因此,www.example.com/en 和 www.example.com/de.

I worked on internationalised websites until this year. The advice we always had from SEO gurus was to discriminate language based on URL - so, www.example.com/en and www.example.com/de.

我认为这对用户来说也更好;如果我用德语为一个页面添加书签,那么当我回到它时,即使我的 cookie 已经过期,我也会得到一个德语页面.同样,我可以做一些事情,比如在 Facebook 上发布 URL,让我说德语的朋友点击它并获得一个德语网站.

I think this is also better for users; if i bookmark a page in German, then when i come back to it, i get a page in German even if my cookies have expired. Similarly, i can do things like post the URL on Facebook, and have my German-speaking friends click on it and get a site in German.

请注意,如果您的网站服务于多个国家/地区,您应该将这些与语言一起处理 - 因此,您可能有 example.com/de-DE、example.com/en-GB、example.com/en-IE 等.

Note that if your site serves multiple countries, you should handle those along with language - so, you might have example.com/de-DE, example.com/en-GB, example.com/en-IE, etc.

但是,这不应该涉及重复.相反,您应该将应用程序设置为处理 URL,提取区域设置信息,然后在内部将请求转发到与区域设置无关的页面.因此,对 example.com/de-DE/info 的请求和对 example.com/en-IE/info 的请求都应该传递给/info.jsp(或者我猜你的情况是 info.php).然后应该使用页面级本地化机制对该页面进行编码,以使用适当的语言发出文本.

However, this should not involve duplication. Instead, you should set your application up to process the URL, extract the locale information, and then forward the request internally to a locale-independent page. So, a request for example.com/de-DE/info and a request for example.com/en-IE/info should both be passed to /info.jsp (or i'm guessing info.php in your case). That page should then be coded to emit text in the appropriate language, using a page-level localisation mechanism.

如果您希望 URL 本身被本地化,事情会有点棘手(例如 example.org/de-DE/anmelden 与 example.org/en-IE/sign-in).但是,同样的原则适用:提取区域设置,然后转发到公共页面.不同之处在于,从 URL 确定页面是什么时必须更加复杂;您需要将 URL 中的自然语言映射到页面文件名.

Things are a bit trickier if you want the URLs themselves to be localised (eg example.org/de-DE/anmelden vs example.org/en-IE/sign-in). However, the same principle applies: extract the locale, then forward to a common page. The difference is that there must be more sophistication in figuring out what the page is from the URL; you will need a mapping from natural language in the URL to the page filename.

这篇关于在网站上使用多种语言的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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