Localization

(Difference between revisions)
Jump to: navigation, search
(Is this a bug)
m (Nullpointer while saving from HTML-Editor)
Line 47: Line 47:
  
  
=== Nullpointer while saving from HTML-Editor ===
+
 
When you get Nullpointer while saving from HTML-Editor, you are probably missing the definition for that language in the controll-code e.g.:
+
<code lang="xml">
+
    <page language="de">
+
      <element name="body">
+
        <links/>
+
        <content><![CDATA[]]></content>
+
      </element>
+
    </page>
+
</code>
+
  
 
== See also ==
 
== See also ==

Revision as of 17:00, 19 May 2009

Contents

Multi-language site structure

To achieve a multi-language site in opencms it's a good idea to create one top-level folder per language. These top-level folders are usually named after their two-letter lowercase code as identified by the ISO 639-1 list, although you can name them however you want. On each of these folders, the locale property should be defined. This can be done by left-clicking the folder icon and selecting properties > advanced. In the advanced properties the locale property should be listed. All the child folders and pages will then inherit the locale of their parent folder. If you would like a page to be available in several locales, you start out by creating the page in one of the locale folders, after which you create a sibling to this page in the folders of the other locales for which you want this page to be available.

Caveats

This section will contain a number of pitfalls related to developing or working with a multilingual site in OpenCms.

Example body supporting multiple languages

An example body that has the same *body element as the "default body" provided by OpenCms but supports multiple languages would look as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.opencms.org/dtd/6.0/xmlpage.xsd">
      <page language="nl">
        <element name="body">
          <links/>
          <content><![CDATA[]]></content>
        </element>
      </page>
      <page language="fr">
        <element name="body">
          <links/>
          <content><![CDATA[]]></content>
        </element>
      </page>
      <page language="en">
        <element name="body">
          <links/>
          <content><![CDATA[]]></content>
        </element>
      </page>
      <page language="de">
        <element name="body">
          <links/>
          <content><![CDATA[]]></content>
        </element>
      </page>
    </pages>

This example would create a body element for the dutch, english, french and german versions of the Page. You can either edit the existing "default body" provided by OpenCms, or create your own body if you are working on a custom module.

Editing the default body

The "default body" file can be found in the folder /system/modules/org.opencms.welcome/default_bodies/

Creating a custom body

If you have created your own module, you can add custom bodies by creating the default_bodies folder in /system/modules/your.module.name/



See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox