Multilingual wiki
|
This howto was tested with moinmoin 1.7.1 and 1.9.2.
This pages explain how to setup multilangual wikis, using the SisterSites features. It is suitable for wiki in a few languages (in this example: English, French, Spanish)
- There is a link on each pages to easily switch to another language
- The pages names are identical for all languages, for example:
Limitation:
You have to manually poll (synchronize) the wikis, when a page is added (of course, you can schedule a daily task)
- It doesn't scale with lots of languages (above 5?) because the the links are at the top of the page.
The search feature doesn't search in other language. Actually, it is sometime a feature.(see feature request SearchWikiFarm).
RecentChanges are separated (but you can setup an RSS aggregator)
1. Screenshot
2. Foreword
From a technical point of view, we are going to setup 1 wiki per language.
3. Copy the files
(We assume you are using Linux, YMMV)
# set a variable, pointing to moin distribution
# (for Debian and Ubuntu packages, this is /usr/share/moin/)
MOINDIST=/path/to/moinuntaredfiles
# First, copy the shared stuffs
mkdir -p /srv/mywiki/data-shared/
cp -r $MOINDIST/data/* /srv/mywiki/data-shared/
cp -r $MOINDIST/underlay /srv/mywiki/
# The copy files for each wiki
mkdir -p /srv/mywiki/data-fr
cp -r $MOINDIST/data/* /srv/mywiki/data-fr/
mv /srv/mywiki/data-fr/user/ /srv/mywiki/data-fr/user.DISABLE
mkdir -p /srv/mywiki/data-es
cp -r $MOINDIST/data/* /srv/mywiki/data-es/
mv /srv/mywiki/data-es/user/ /srv/mywiki/data-es/user.DISABLE
mkdir -p /srv/mywiki/data-en
cp -r $MOINDIST/data/* /srv/mywiki/data-en/
mv /srv/mywiki/data-en/user/ /srv/mywiki/data-en/user.DISABLE
# The webserver but be able to read/write files
chown -R www-data:www-data /srv/mywiki/
4. Configure the web server
As we mentioned above, we setup 3 wikis. There is nothing special here. (This example is for Apache).
### Serve static contents (images, javascript, css...) ###
# The path to static contents changes (named after moinmoin version).
AliasMatch "^/moin_static[0-9]*/(.*)" "/usr/share/moin/htdocs/$1"
<Directory "/usr/share/moin/htdocs/">
Options -Indexes -FollowSymlinks
AllowOverride None
</Directory>
### Serve the wiki as /wiki ###
WSGIScriptAlias /en "/usr/share/moin/server/moin.wsgi"
WSGIScriptAlias /fr "/usr/share/moin/server/moin.wsgi"
WSGIScriptAlias /es "/usr/share/moin/server/moin.wsgi"
<Directory "/usr/share/moin/server/">
Options -Indexes -FollowSymlinks
AllowOverride None
</Directory>
5. Configure the wikifarm
5.1. Configure Interwiki map
Each wiki is has two InterWiki name, like MyWikiEn and English. The first one is the real one, the second is used to nicely display the page header
/srv/mywiki/data-shared/intermap.txt should look like:
MyWikiEn http://example.com/en/ MyWikiFr http://example.com/fr/ MyWikiEs http://example.com/es/ English http://example.com/en/ Francais http://example.com/fr/ Espanol http://example.com/es/
5.2. farmconfig.py
Let's declare the wikis we are going to use. Let's modify wiki=[] in your farmconfig.py
wikis = [
# wikiname, url regular expression
# ---------------------------------------------------------------
("mywiki-en", r"^http://example\.com/en.*$"), # MyWiki - English
("mywiki-fr", r"^http://example\.com/fr.*$"), # MyWiki - French
("mywiki-es", r"^http://example\.com/es.*$"), # MyWiki - Spanish
#("mywiki", r".*"), # this is ok for a single wiki
# for multiple wikis, do something like this:
#("wiki1", r"^http://wiki1\.example\.org/.*$"),
#("wiki2", r"^https?://wiki2\.example\.org/.*$"),
]
Full example: farmconfig.py
5.3. wiki setup
Let's create one wiki for each language (/etc/moin/mywiki-en.py, /etc/moin/mywiki-fr.py, /etc/moin/mywiki-es.py). the configuration files are almost identical for all languages, except interwikiname, data_dir, language_default and sistersites.
We are using quite a few tips here:
The SisterSites feature is used to update the links to other pages.
Frontpage name is force (because all pages must have the same name, for the links to work)
Language negotiation is disabled.
Informations related to the users are shared.
All user homepage are stored in a single wiki, the English wiki in this case (but you could setup another wiki, just for the homepages.
Some elements are shared, like the underlay, the interwiki map, etc
The website name, at the top of the page, is unified for all wikis.
This is the example for /etc/moin/mywiki-en.py:
# -*- coding: iso-8859-1 -*- # IMPORTANT! This encoding (charset) setting MUST be correct! If you live in a # western country and you don't know that you use utf-8, you probably want to # use iso-8859-1 (or some other iso charset). If you use utf-8 (a Unicode # encoding) you MUST use: coding: utf-8 # That setting must match the encoding your editor uses when you modify the # settings below. If it does not, special non-ASCII chars will be wrong. """ This is a sample config for a wiki that is part of a wiki farm and uses farmconfig for common stuff. Here we define what has to be different from the farm's common settings. """ # we import the FarmConfig class for common defaults of our wikis: from farmconfig import FarmConfig # now we subclass that config (inherit from it) and change what's different: class Config(FarmConfig): # basic options (you normally need to change these) sitename = u'MyWiki' # [Unicode] show_interwiki = 0 logo_string = sitename interwikiname = u'MyWikiEn' # [Unicode] # name of entry page / front page [Unicode], choose one of those: # a) if most wiki content is in a single language #page_front_page = u"MyStartingPage" # b) if wiki content is maintained in many languages #page_front_page = u"FrontPage" page_front_page = u"MyFrontPage" data_dir = '/srv/mywiki/data-en/' data_underlay_dir = '/srv/mywiki/underlay/' # Share user informations, see MoinMoin:CommonUserAccounts cache_dir = '/srv/mywiki/data/cache/' # share sessions user_dir = '/srv/mywiki/data/user/' #All homepages are stored on the English wiki user_homewiki = u'English' language_default = 'en' #language_ignore_browser = True sistersites = [ ('Francais', 'http://127.0.0.1/fr/?action=sisterpages'), ('Espanol', 'http://127.0.0.1/es/?action=sisterpages'), #Don't synchronisze with myself! # ('English', 'http://127.0.0.1/en/?action=sisterpages') ] # list of (sistersitename, sisterpagelistfetchurl)
and also mywiki-en.py, mywiki-fr.py, mywiki-es.py.
5.4. Usual configuration
Now, you can do the usual configuration (create a user account, grant superuser rights, visit http://example.com/en/LanguageSetup ...)
6. Synchronise content
The wiki won't magically know that a page appeared on the other wikis. For each language, you have to tell moinmoin to poll the sister sites. in our example, using:
You can create a cron job (or a windows task) to automate this.
7. Beyond ...
For the user homepages, you could create another wiki, and publish it under http://example.com/Users/ (it doesn't have to be listed in sistersite).
Single-sign-on in all wiki should be possible. (Using http://example.com/Users/ as an OpenID server)