语言格式问题 - 元标记 [英] Language Format issue - Meta tag

查看:78
本文介绍了语言格式问题 - 元标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用法语和英语。我有两个链接,例如Française| English,当用户选择Française时,我将以下内容放在标题中:

 < meta content =text / html; charset = ISO-8859-1http-equiv =Content-Type> 
< meta content =frhttp-equiv =Content-Language>

当用户选择English时,我将以下内容放在标题中显示相应的语言

 < meta content =text / html; charset = utf-8http-equiv =Content-Type> 
< meta content =enhttp-equiv =Content-Language>

问题是,当我从法语切换到英语时,链接Française| English变得像 Fran aise| English。我做错了什么?任何建议?



谢谢

解决方案

听起来像你还在使用UTF-8(用于编码文本的现代标准),而不是对法文文件使用ISO-8859-1(用于编码文本的传统标准,您不应该再使用它)。

由于您声称您使用的是ISO-8859-1,因此浏览器会尝试将该文档解释为使用该编码并获取一些不可打印的字符。解决方案是要求UTF-8无处不在

由于UTF-8包含ISO-8859-1中的所有内容(还有更多),因此无论如何都不会改变。



另外,Content-Language仅指定文档的目标受众。要指定一个文件确实是用法文写的,你应该:

 < html lang =fr> 

然后您应该指定链接使用不同的语言,并指向其他版本不同语言的相同文档:

 < ul> 
< li>< a href =/ fr /lang =frhreflang =fr =alternate>Française< / a>< / li>
< li>< a href =/ en /lang =enhreflang =en =alternate> English< / a>< / li>
< / ul>


I am using French and English in my website. I have two links like "Française | English" and when user selects "Française" i place the following in header

<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<meta content="fr" http-equiv="Content-Language">

and when user selects "English" i place the following in header to show respective languages

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="en" http-equiv="Content-Language">

The problem is when i switch to English from french, the links "Française | English" becomes like "Fran�aise | English".What i am doing wrong? any suggestions?

Thanks

解决方案

It sounds like you are still using UTF-8 (modern standard for encoding text) and not using ISO-8859-1 (legacy standard for encoding text that you shouldn't use any more) for the French documents.

Since you claim you are using ISO-8859-1, the browser then tries to interpret the document as using that encoding and gets some unprintable characters. The solution is to claim UTF-8 everywhere.

Since UTF-8 contains everything (and more) that is in ISO-8859-1 it wouldn't make sense to change anyway.

As an aside, Content-Language only specifies the intended audience for a document. To specify that a document really is written in French you should:

<html lang="fr">

And then you should specify that the links are in a different language, and point to alternative versions of the same document in a different language:

<ul>
    <li><a href="/fr/" lang="fr" hreflang="fr" rel="alternate">Française</a></li>
    <li><a href="/en/" lang="en" hreflang="en" rel="alternate">English</a></li>
</ul>

这篇关于语言格式问题 - 元标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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