lang Internationalization

an article added by: Albert Lichtblau at 06022007


In: Categories » » HTML XHTML and CSS » lang Internationalization

Internationalization: xml:lang and lang Internationalization (often abbreviated i18n because 18 characters appear between the i and the n) gets a significant boost with the shift to XML primarily because of XML's use of Unicode as the underlying character model. While not every document needs to encode Chinese, Cyrillic, Arabic, and Indian characters, Unicode makes it possible for all of these forms to exist within a single document. In addition, XML and XHTML allow for the possibility of other encodings. In order to make this support more useful to programs that may need to know what language they are processing, XML and XHTML provide a tool for identifying the language used for content in a particular element. While XML and HTML both use the same mech-anism for identifying languages, they have slightly differently names for the mechanism. Therefore, XHTML 1.0 recommends using both. If for some reason the values aren't the same, XHTML processors should use the value given by xml:lang. Like namespace declarations, xml:lang and lang attributes apply to the children of the elements that use them. This makes it easy to mark an entire document as being of a particular language, while still allowing pieces of documents in different languages to override the language choice. For example, this document is marked as appearing in U.S. English:

   <?xml version="1.0"?>
   <html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"  lang="en-US">
   <head>
   <title>Languages test</title>
   </head>
   <body>
   <h1>Languages!</h1>
   <p>All of the elements in this document  are in U.S. English.</p>
   </body>
 </html>

To override a language identifier for a particular piece of text, just put new xml:lang and lang attributes on that portion:

   <?xml version="1.0"?>
   <html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"  lang="en-US">
   <head>
   <title>Languages  test</title>
   </head>
   <body>
   <h1>Languages!</h1>
   <p>All  of the elements in this document are in U.S. English except the
   following  bit from Cicero.</p>
   <p  xml:lang="la" lang="la">O tempora, o mores! Senatus haec  intellegit.
   consul  videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit
   publici  consilii particeps, notat et designat oculis ad caedem unum quemque
   nostrum.  Nos autem fortes viri satis facere rei publicae videmur, si istius
   furorem  ac tela vitemus. </p>
   <p>This  is in English again, since it isn't contained by the paragraph in
   Latin.</p>
   </body>
   </html>

XHTML doesn't require the use of language identifiers. However, it's excellent practice and it makes it easier for you to style your documents for different languages and for users to apply automated tools like machine translators.

Rules for vocabulary extensions XHTML 1.0 describes a core vocabulary and set of structures, but it leaves room for future vocabularies. XHTML 1.0 is a foundation that gives the W3C a start for further development that can be fragmented and rebuilt as needed.

legal notice

Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.

Useful tools and features

Link to this article from your page    Send this article to you or to a friend
If you like this article (tutorial), please link to it from your web page using the information above.

related articles

1. Anatomy of an XHTML Document
The transition from HTML to XHTML will come with a fair number of bumps. While later chapters introduce tools to help you get past those bumps – and figure out where they come from – this chapter examines what's going to change and demonstrates a few strategies for handling those changes. Along the way, we visit the ghosts of browsers past and explore problems that exist in current browsers. In turn, you discover how prepared and unprepared various tools are for XHTML. Note Som...

2. Converting to strict HTML and XHTML
Converting to strict HTML You start out by declaring your intentions to use the strict HTML 4.01 DTD by putting the appropriate DOCTYPE declaration at the head of the document: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Now the first section of the document, including the HTML opening tag and the HEAD element and its contents, is fine except for one line. The SCRIPT element no longer supports a LANGUAGE at...

3. Reading the XHTML DTDs A Guide to XML Declarations
Reading the XHTML DTDs: A Guide to XML Declarations Although the W3C has long had document type definitions (DTDs) for HTML, few developers actually use those DTDs as a foundation for learning HTML. XHTML 1.0 simplifies those DTDs with the slightly friendlier XML syntax – they previously used SGML's more complex syntax – and the increased emphasis on validation may lead developers to explore them more closely. Making good use of XHTML 1.1 requires some level of ...

4. Defaulting attribute values XHTML DTDs
XML 1.0 also provides a set of tools for specifying what happens if an attribute isn't declared within an element. Four different possibilities exist, including "the attribute just isn't there"; "the attribute must be there, period"; and "the attribute has this value, period." You already have seen a few uses of these choices in the preceding declarations. In the img element, for instance, the src and alt attributes are required (#REQUIRED); meanwhile, most of the rest of its attribute content is optio...

5. Exploring the XHTML DTDs
Exploring the XHTML DTDs Choosing Your DTD XHTML 1.0 provides three DTDs that describe different sets of XHTML elements and reflect the three choices provided in HTML 4.0: strict, transitional, and frameset. The probably the one that the W3C would like to see developers adhere to, but transitional DTDs reflect the reality of HTML usage much more accurately. Appendix A lists the in the three different DTDs, along with notes regarding attributes. To identify the DTD for a ...

6. Building XHTML DTD Structure Element and Attribute Declarations
Building Structure: Element and Attribute Declarations After all of these preliminaries, it's finally time to make some real declarations, creating the elements and attributes partly described by the entities established so far. This portion of the DTD is broken down into segments that reflect groupings of element types, foreshadowing to some extent the modularization process that XHTML 1.1 will perform. If you have trouble getting your XHTML documents to validate, you need to explore this portion of the ...

7. Style Sheets and XHTML
Cascading Style Sheets (CSS) is an enormously powerful tool that has been slow to catch on in the HTML development world. Whether or not you use (or like) CSS, the continuing evolution of CSS is deeply intertwined with the work moving forward on XHTML so learning about CSS can help you understand XHTML as well as implement it. Fortunately, CSS isn't very difficult once you master a few key structures and learn to apply its vocabulary. There are some real problems with existing CSS implementations that I cover later...

8. Formatting Content with CSS Properties
While selectors do a great job of picking out content that needs formatting, designers (as opposed to Web site managers) like CSS mostly because of the large number of available formatting properties. CSS offers properties that support nearly any presentation of a document desired, and yet more properties are in development as part of the CSS3 activity. CSS properties enable you to describe precisely how you want the pieces of your document formatted and to override the rules by which HTML is presented normally. <...

9. Using XHTML in Traditional HTML Applications
Before moving into the much more complicated terrain of converting older HTML content to the newer XHTML rules, let's take a look at how the shift to XHTML affects day-to-day Web development and the construction of new content. Web development has been in nearly constant flux since its beginnings, and developers are accustomed to (if perhaps tired of) the challenges that come with every new standard and every new browser. Some of the challenges XHTML presents are familiar, although a few new twists brought on by XH...