views:

54

answers:

2

XML documents can be localized by referring to an external DTD document that contains the translations. For example in Mozilla XULRunner it looks like this:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://configpanel/locale/configpanel.dtd">
<window title="&CONFIG_PANEL;">
  <label value="&WELCOME_TEXT;"/>
</window>

I've tried it in a HTML document but it didn't seem to work. Is this supposed to work for HTML documents? Or is there a similar mechanism that can be used here?

+1  A: 

I'm going to go right ahead and say that that isn't really a good way of localizing XML, and it probably won't work for HTML in most browsers.

The canonical way of localizing XML documents is using the xml:lang attribute.

Williham Totland
+1  A: 

This isn't supposed to work in HTML. I suggest you just do the localisation on the server-side.

Ms2ger
Strictly speaking, this i *supposed* to work in HTML, it just doesn't, on account of being insane.
Williham Totland
Strictly speaking, it isn't. Check the HTML5 specification.
Ms2ger
Who said anything about HTML5? It's fairly obvious that for anything to do with DTDs, it's *not* HTML5, but HTML4.01 or XHTML.
Williham Totland
Regardless of the DTD, pages sent as text/html are treated as defined in HTML5. Claiming anything else isn't productive.
Ms2ger