One of the main advantages of separating out the Content from the View is that it is easy to implement multiple languages while sharing the same look-and-feel. You may use the xml:lang to label which languages tags are in.
The preferred language of the user is determined as follows.
The default language preference is set to the Accept-Language incoming HTTP header.
This default value can be overridden by setting the pkit_lang request parameter.
HTML::Template::XPath supports language localization through the use of the xml:lang attribute. In PageKit 1.01 and above, the algorithm for selecting the node(s) for the selected languages is as follows:
First it attempts to use the XPath function lang to return the node or the set of nodes whose xml:lang attribute(s) are the same as the preferred language. If the node has no xml:lang, then the value of the xml:lang attribute on the nearest ancestor is used. If the node and the its ancestors have no xml:lang attribute, then the default_lang language is used.
If no nodes are found in the preferred language, then it returns the node(s) which are in the default_lang language.
The algorithm in PageKit 1.00 is slightly different from the above, but follows the same basic idea.
As of release 1.00 there is no support for Language Localization using XSLT. However I plan to offer support in one of the two following ways:
Comments, suggestions, and patches welcome!
To use the language settings from the Model, simply use the pkit_lang method.
This can be useful for selecting content from the database based on language.
By default, PageKit attempts to output using default_output_charset. PageKit will attempt to translate the PageKit Templates and output passed to output_convert from default_input_charset to default_output_charset.
Note: This also applies also to the message catalog if any. So write your message catalog files in default_input_charset.
In addition, if the client's browser doesn't support default_output_charset, then PageKit attempts to translate the output from default_output_charset to a character set that is specified in the Accept-Charset header and supported by your system's iconv library.