MultiLanguagePages

Summary: Show language specific pages according to user choice
Version: 1.0
Prerequisites: PMWiki 2.x
Status: new
Maintainer: HaraldC?
Users: +1 (View / Edit)

Questions answered by this recipe

How can I show language specific pages according to user choice when I would prefer to have one page per language?

Description

This recipe has a different approach compared to the recipes MultiLanguage and MultiLanguageViews to show language-specific content as it is based on a one-page-per-language principle.
This is particularly useful if one has not mainly text but also several pictures with (language-specific) captions on the pages etc.

Setup

  • The basic file structure should be providing for one group per language.
  • It further requires that the page name of a page is identical for all the languages, e.g. they are all in English.
    So you might have De/HomePage, En/HomePage, Bg/HomePage etc.
  • Pages are created as normal paying attention that they are grouped by language. For ease-of-use it is recommended but not necessary to name the groups according to the international two-letter language code.
  • The use of a skin where one has special "pages" for the header, the navigation menu and the footer is recommended and those files should be created too, also grouped according to their language, e.g. De/NavBar, En/NavBar etc.
    One could of course modify any preferred skin accordingly.

Site|Group/PageHeader

This file should contain the language switching.
If one wants to use flags for that, one could download flags.zipΔ.

Here is an example for the contents of that file:

%lfloat% [[{*$Group}/ | Path:path-to-your/logo.jpg"your-title"]]
! your site title
%right% 
(:if ! equal {*$Group} En :)(:if2 exists En.{*$Name}:)
[[En.{*$Name}|Path:path-to-flags/en.png"English"]]
(:if2end:)(:ifend:)
(:if ! equal {*$Group} De :)(:if2 exists De.{*$Name}:)
[[De.{*$Name}|Path:path-to-flags/de.png"Deutsch"]]
(:if2end:)(:ifend:)
...

This will show the flags for the existing pages in all other languages only.
When clicking on the flag, the same page in the other language is shown.

Group/NavBar

For the navigation menu one needs one file per language.
This file operates similar to the language switching in the PageHeader above, i.e. only the menu items for existing pages in that language are shown.

This file could look like this (example for the English menu as an unordered list):

(:if exists en.HomePage:)
* [[en.HomePage | Home()]]
(:if:)
(:if exists en.Service:)
* [[en.Service | Services (Services offered)]]
(:if:)
(:if exists en.About:)
* [[en.About | About us (Our Story)]]
(:if:)
...

Site|Group/PageFooter

As this file normally contains language-specific copyright notices etc. one file per language will be necessary in most cases.
Regarding multilingualism there is no special markup contained in this file.

Notes

ToDo

  • Automatically show start page according to setting of first language in user's browser.

Release notes

  • 2010-02-22: initial release..

See also

MultiLanguage and MultiLanguageViews

Contributors

Comments

See discussion at MultiLanguagePages-Talk?

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.