Localization
(Added Multi-language site structure section to this page.) |
(→Editing the default body) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== Multi-language site structure == | == 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 [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 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. | + | 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 [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 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. | 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 == | == Caveats == | ||
This section will contain a number of pitfalls related to developing or working with a multilingual site in OpenCms. | This section will contain a number of pitfalls related to developing or working with a multilingual site in OpenCms. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
==== Example body supporting multiple languages ==== | ==== 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: | An example body that has the same *body element as the "default body" provided by OpenCms but supports multiple languages would look as follows: | ||
− | + | <code lang="xml"> | |
<?xml version="1.0" encoding="UTF-8"?> | <?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"> | <pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.opencms.org/dtd/6.0/xmlpage.xsd"> | ||
Line 46: | Line 36: | ||
</page> | </page> | ||
</pages> | </pages> | ||
− | + | </code> | |
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. | 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 ==== | ==== Editing the default body ==== | ||
− | The "default body" file can be found in the folder <em>/system/modules/org.opencms. | + | The "default body" file can be found in the folder <em>/system/modules/org.opencms.workplace/default_bodies/</em> |
==== Creating a custom body ==== | ==== Creating a custom body ==== | ||
If you have created your own module, you can add custom bodies by creating the default_bodies folder in <em>/system/modules/your.module.name/</em> | If you have created your own module, you can add custom bodies by creating the default_bodies folder in <em>/system/modules/your.module.name/</em> | ||
− | == | + | |
− | + | ||
+ | |||
+ | |||
+ | == See also == | ||
+ | *[[Switch between languages]] | ||
+ | *[[Automatic detection of user's preferred language]] | ||
+ | *[[Using the Administration View tools for multi-language site creation]] | ||
+ | *[[Using ResourceBundles (without having to restart container)]] |
Latest revision as of 07:56, 10 July 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.workplace/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/