Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different Language In Website

I'm trying to write a website in Slovak language (central Europe). What I have done is put these two meta tags into the header:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Language" content="sk" />

The problem is all characters with diacritique are substituted with garbage characters (so the encoding I not working obviously). What to do?

Here is the whole beginning of the page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="sk" />
like image 407
Richard Knop Avatar asked Aug 08 '26 20:08

Richard Knop


2 Answers

When you save the file you have to make sure that it's created with the same encoding that you have specified in the meta tag.

I recommend that you use utf-8 instead of iso-8859-2. The unicode character set supports all characters in practically every language that exists (and even some that don't...).

like image 74
Guffa Avatar answered Aug 10 '26 10:08

Guffa


There are two issues at work here.

  1. Language
  2. Character encoding

Language

The Content-Language HTTP header describes the natural language of the intended audience. This may not be the same as the language the document is actually written in. Use the lang attribute to describe that.

Character encoding

This allows you to represent the letters that you wish to use. You need to make sure that your text really does use the selected encoding and that the browser is informed that that is the encoding you are using.

  • Select a character encoding (UTF-8 is generally the best choice, it covers just about every character you could possibly want to use and saves you having to switch encodings for different languages), see http://www.w3.org/International/tutorials/tutorial-char-enc/
  • Ensure your editor saves using that encoding
  • Ensure your server specifies that it is using that encoding
  • Ensure that nothing mangles the encoding between the editor and server (such as by being inserted into a database that is configured to use a different encoding)

HTTP headers

NB: Your question mentions <meta http-equiv>. Real HTTP headers are the better place to specify this information, and they will override whatever your document claims. Make sure your server is configured correctly.

XHTML

XHTML complicates matters…

  • Use xml:lang in addition to lang
  • Don't use anything except UTF-8. If you do, then you must specify this in the XML declaration (and adding an XML declaration will trigger Quirks mode in some browsers).
like image 43
Quentin Avatar answered Aug 10 '26 12:08

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!