Recent Changes - Search:

PmWiki

pmwiki.org

Internationalizations

PmWiki supports internationalization (internationalisation) of web pages, allowing accented characters to appear in page names and almost complete customization of PmWiki's prompts. Most customization is provided via the XLPage() function in PmWiki, which loads a set of translation variables from a wiki page (typically named XLPage, but it can be named anything you wish).

PmWikiCa Català ~ XLPage
PmWikiZhCn Chinese ~ XLPage
PmWikiDa Dansk ~ XLPage
PmWikiEn English ~ XLPage
PmWikiEs Español ~ XLPage
PmWikiEo Esperanto ~ XLPage
PmWikiFr Français ~ XLPage
PmWikiEl Greek ~ XLPage
PmWikiIt Italiano ~ XLPage
PmWikiJa Japanese ~ XLPage
PmWikiLt Lietuvių ~ XLPage
PmWikiMk Macedonian ~ XLPage
PmWikiHu Magyar (hungarian) ~ XLPage
PmWikiNl Nederlands ~ XLPage
PmWikiNo Norsk ~ XLPage
PmWikiFa Persian ~ XLPage
PmWikiPl Polski ~ XLPage
PmWikiPt Portuguese ~ XLPage
PmWikiPtBr Portuguese (Br) ~ XLPage
PmWikiRo Românã ~ XLPage
PmWikiRu Russian ~ XLPage
PmWikiSk Slovenčina ~ XLPage
PmWikiSi Slovenščina ~ XLPage
PmWikiFi Suomi ~ XLPage
PmWikiSv Svenska ~ XLPage
PmWikiTr Türkçe ~ XLPage
PmWikiTa Tamil ~ XLPage
PmWikiVi Việt ngữ ~ XLPage

Loading Translation Pages

Pages for many other languages have already been created and maintained at the pmichaud.com site. You can download an archive of these translations from http://pmichaud.com/pub/pmwiki/i18n/ . Simply download the appropriate language archive(s), and unpack the archive(s) into the directory containing your pmwiki.php installation. Each archive contains a number of page files that are placed in your wikilib.d/ directory, and some special scripts for translations that use a character set other than iso-8859-1 (PmWiki's default).

Once the translation pages are installed, you enable a language by adding a call to XLPage() in your config.php file. For example, to select French language prompts, one would specify

XLPage('fr','PmWikiFr.XLPage');

which says to load the translations for French ('fr') from the page PmWikiFr.XLPage. It's perfectly okay to load multiple pages; so if you want to create your own local translations without changing the ones you got from from an i18n archive, just create another page (see below) and load it on top. Be sure that you load first the page with your local changes:

XLPage('fr','PmWikiFr.XLPageLocal');  # my local translations
XLPage('fr','PmWikiFr.XLPage');       # from i18n.tgz

If your intention is to offer multiple languages on your site, and use Wiki Groups as language selectors, you may want to place this code in local customizations files (see PerGroup Customizations). For example, if your site is published in French and English, and the French pages are in a group called Fr, you could create a file named Fr.php in the local/ directory which contains:

<?php if (!defined('PmWiki')) exit();
##change to French language
XLPage('fr','PmWikiFr.XLPage');

You may wish to create a page called PmwikiFr.php with the same content to access the French documentation in the PmwikiFr group. En.php is not necessary in this case since English is the default language.

An alternative to the above would be to add to config.php the following, which tests if there is an XLPage in a group, and if it finds one it gets loaded:

    
$xlpage = FmtPageName('$Group.XLPage', $pagename);
if (PageExists($xlpage)) XLPage($xlpage, $xlpage);

With this method you would need to copy any relevant XLPage into any group which needs the different language support.

See also Cookbook:MultiLanguage Display content in different languages on a a page by user's choice

Creating New Translations

If language pages don't exist for your desired language, it's easy to create one! An XLPage translation file simply contains lines of the form

'phrase' => 'translated phrase',

where "phrase" is an internationalized phrase (denoted by $[phrase]) in PmWiki's $...Fmt variables, and "translated phrase" is what should be printed in your particular language. For example, the line (in PmWikiFr.XLPage)

'Search' => 'Rechercher',

converts "$[Search]" to "Rechercher" on output. The file PmWiki:XLPageTemplate is a good starting point for creating a new XLPage and has most of PmWiki's key phrases already listed in it.

If you create new versions of PmWiki pages in other languages, please consider adding them to the main PmWiki site so that they can be made available to others in the i18n archives!

The term "i18n" is commonly used as an abbreviation for the English word "internationalization". The abbreviation is derived from the fact that there are 18 letters between the "i" and the final "n" and few people want to type them all out.

Notes

If my wiki is internationalized by config.php, how do I revert a specific group to English?

Use $XLLangs = array('en'); in the group's per group customization file.

If my wiki is in English and I want just one page, or group, in Spanish do I say XLPage('es','PmWikiEs.XLPage'); in the group or page configuration file?

Yes, that is usually the best method. If you were doing this with many scattered pages, or with several languages, you might find it easier to maintain if you load the translations all in config.php like this:

   XLPage('es','PmWikiEs.XLPage');
   XLPage('fr','PmWikiFr.XLPage');
   XLPage('ru','PmWikiRu.XLPage');
   $XLLangs = array('en');

Then in each group or page configuration file, you'd just use $XLLangs = array('es'); to set the language to use (in this case, Spanish). Note that though this method is easier to maintain, its somewhat slower because it loads all the dictionaries for each page view, even if they won't be used.

What does the first parameter of this function stand for? How can it be used?

The XLPage mechanism allows multiple sets of translations to be loaded, and the first parameter is used to distinguish them.

For example, suppose I want to have translations for both normal French and "Canadian" French. Rather than maintain two entirely separate sets of pages, I could do:

    XLPage('fr', 'PmWikiFr.XLPage');
    XLPage('fr-ca', 'PmWikiFrCa.XLPage');

PmWikiFr.XLPage would contain all of the standard French translations, while PmWikiFrCA.XLPage would only need to contain "Canada-specific" translations -- i.e., those that are different from the ones in the French page.

The first parameter distinguishes the two sets of translations. In addition, a config.php script can use the $XLLangs variable to adjust the order of translation, so if there was a group or page where I only wanted the standard French translation, I can set

    $XLLangs = array('fr', 'en');

and PmWiki will use only the 'fr' and 'en' translations (in that order), no matter how many translations have been loaded with XLPage().

Tools for PmWiki Localization

You can help to localize PmWiki in your language in the original site:

Translation Portal I think it may be of some use to have a central page devoted to translation (aimed to translators) - the present page is for i18n by users. the translation portal is a central hub for translators as starting point jdd Unfortunately, an anonymous contributor have deleted on march,16 the link to the localization page, so it have disappeared in space. It was intended to be the resource you are searching for. I think these two pages shall be merged somewhat. The same contributor also have made an energic cleaning of the Internationalization page and the pertinence of all that erasing shall be carefully checked.PRZ

feel free to restore it!

The creation of a "localization" group is a very good idea (I'm too new here to take such decision :-), but I think keeping at least one page aimed to translators in the PmWiki group is a good idea, must simpler to find, I guess. the other translator pages should be moved to the new group. jdd

Multilingual pmWiki-based website, is it possible? Would it be possible to set pmwiki in a way that allows to maintain a multilingual website? I realize when you discuss i10n and l18n you refer to the wiki system itself, but on the content level it may be more than desirable, especially if the user may select his/her desired language for the content. VirtualFlavius?

Might be possible and actually sort of a common feature. (A heavy-weight CMS I know offers several language instances of the same page "seamlessly" - which is different from the Wikipedia, where you have to actively change the Wikipedia instance.) Have you had a look at the PITS yet to see if someone already made a feature request for this? --Henning June 25, 2007, at 09:55 AM
I've had some success using (and extending) the SubgroupMarkup recipe for multilingual websites. This allows me to create different language instances of a page by appending a language code as a subgroup. For example, "Main/Homepage,EN" would refer to the English version of "Main/Homepage", "Main/Homepage,FR" would contain the French version, and so on. --gh? December 3, 2007

Edit - History - Print - Recent Changes - Search
Page last modified on August 30, 2008, at 11:07 PM