Multilingual content

Multilingual content has been one of the primary neccessities we wanted to achieve in an early stage. As with every concept within Cloudix, the implementation is fairly straightforward. In the base every content block, being a "piece of text", has an Id and a Value.

If we take a look at the example XML data that is used for the XmlContentProvider, we can see that content in Cloudix has the following structure:

  <CloudixContent>
    <ContentBlocks>
      <!--ContentId #1, which is the title of the page, has only one interpretation, being the basic DefaultOrUnderinfed language.-->
      <Content Id="1" Language="0">XmlContentProvider</Content>

      <!--ContentId #2 has two implementations: one default, the second in the Dutch ("NL") language. -->
      <Content Id="2" Language="DefaultOrUnspecified">Demo using XmlContentProvider</Content>
      <Content Id="2" Language="NL">Demo welke gebruik maakt van de XmlContentProvider</Content>
    
    </ContentBlocks>
  </CloudixContent>

As simple as it gets. Do note that in the sample above you see that an Id does not have to be unique. Content Id number 2 has two specific implementations, where the discriminator in this is a combination between the Id and Language parameter.

The Language parameter is a value from the fixed list (enumeration) which can be found in Cloudix.Common.Languages namespace. This list is based on the ISO 639-1 international standard for two digit language codes.

One important thing you should keep in mind is that there all languages are optional, but there always needs to be one Language="DefaultOrUnspecified" definition per content block.

Note: This behaviour will probably change during further development.

Codesample - Defining a specific language

As seen in other codesamples, the CloudixScriptManager is by preference registered in the Html document's <head> tag. Use the overload on the RegisterScriptManager() method to define a specific language:
		var provider = new XmlContentProvider(xmlFilePath);
		CloudixScriptManager.RegisterScriptManager(provider, ContentEditMode.Editable, Languages.NL);

In this sample you can clearly see the last parameter which specifies the Languages.NL culture. This is all there is to it to switch languages. What you should know is that this parameter is optional. Meaning that if you do not provide a specific language it will revert to the default Languages.DefaultOrUndefined.
Note: Each ContentProvider decides for itself what happens when a block of content for a specific language cannot be found. In this case some ContentProviders will revert to the default language, while others will throw an exception. We are currently contemplating on the desired behaviour. 



Back to Codesamples

Last edited Aug 11, 2010 at 2:36 PM by Securancy, version 1

Comments

No comments yet.