Welcome to WebmasterWorld Guest from 23.20.230.24

Forum Moderators: phranque

Message Too Old, No Replies

DocType alteration for different site langugages

Is it necessary?

     
1:22 am on Sep 1, 2008 (gmt 0)

10+ Year Member



Hello All

Im beginning to step into projects that require the display of various languages.

So far, to accommodate this, Ive got the http-equiv meta tag set to:

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

But what about the language attributes of the DOCTYPE? Previously before the possibility of multi-language projects, it was set as follows:

<!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="en" lang="en">

Now that Im going to have to be dealing with Japanese and German text, should these be dynamically altered depending upon the langugage chosen?

I.e.: xml:lang="ja" lang="ja" if the site language is Japanese, or xml:lang="de" lang="de" if the site language is German?

All insight greatly appreciated!

Neophyte

4:00 am on Sep 1, 2008 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



You've got the right idea. Here are a few older threads that dealt with this topic:
  • indicating LANG to Search Engines [webmasterworld.com]
  • character encoding labeling [webmasterworld.com]
  • 9:44 am on Sep 1, 2008 (gmt 0)

    10+ Year Member



    Thanks Bill - Appreciate the links! Very informative.

    From those links I'm going with simply the following for Japanese:

    <!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="ja" lang="ja">

    This for English:

    <!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="en" lang="en">

    ...and so on.

    Meta/Content-Type will always reflect:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    I am BRAND NEW at this multi-language stuff, so if anyone sees that I'm not being comprehensive enough, please DO sound off.

    Neophyte

    7:19 am on Sep 3, 2008 (gmt 0)

    WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



    I've heard it said that the ideal way of setting the charset is to send it as an HTTP header before the page is served. However, I've always relied on setting the language in the <html> tag and setting the charset via the <meta>. That covers all modern browsers I've tested.
    9:19 am on Sep 3, 2008 (gmt 0)

    10+ Year Member



    Bill -

    Thanks for the add-on; I've read the same things in different locations (sending the language as a header) as well but haven't investigated it as of yet.

    Strange though: when testing the output of Japanese text from a database I'm getting these darn question marks instead of the correct Japanese characters. I've done EVERYTHING as indicated above and check and re-checked when rendering as Japanese but the question marks remain.

    Hummm... really got me scratching my head!

    Maybe it's a php issue so I've posted the follow on in that forum.

    Thank YOU though for following up!

    Neophyte

    9:28 am on Sep 3, 2008 (gmt 0)

    WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



    Sounds like you may be serving Japanese that's not UTF-8 encoded. Your database has to have the content encoded correctly. Simply changing the language in the HTML won't be enough. As you said, you may need another thread for that topic though. ;)
     

    Featured Threads

    Hot Threads This Week

    Hot Threads This Month