<> == Other languages links == ## Tell your story here. ## What is the problem you are trying to solve? I moderatly use the MultiLang features of MoinMoin. One of the things that are dearly missing is a GUI for telling us which pages are translations of the current page, yes, the way MediaWiki does (them again!). ## Is this features useful to most users or just to specific users? I think there could be a way to fixup a theme to do just that, i'll think of something. -- TheAnarcat <> == Solution == === Summary === I have successfully modified a rightsidebar-based theme to add an "other languages" box. The way the box works is that it relies on the `i18n` engine (which includes LangDict pages) to find if there's a translation of the current page. It iterates over all known dictionnaries and tries to find the current page in there. For every match, it will list a link to the related page with the language name as the text of the link. === Usage === Apply the patch provided below (it simply patches the theme). To link pages together, you need to edit the LangDicts. So for example, if you want to link FrontPage to StartSeite, you'll want to edit the GermandDict to have an entry like: StartSeite:: FrontPage This creates a one way link. To link StartSeite to FrontPage, you'll need to edit the EnglishDict to have this line: FrontPage:: StartSeite Of course, this is not necessary since FrontPage and StartSeite are already in the builtin translations, but it serves as a good example. === Panel code === This is the code that generates the panel in the theme. {{{#!python def langpanel(self, d): """ Create language panel """ from MoinMoin import i18n from MoinMoin.i18n import _unformatted_text_cache from types import * _ = self.request.getText page_title = d['page_name'] lang_links = [] request = self.request for l in i18n.languages: trans = i18n.getText(page_title, self.request, l, False) if trans == page_title: lang = Page(self.request, page_title).language if lang is None: # this is a hack: the page should always have a lang, and the default should not be .fr lang = 'fr' ## costly hideous operation to find the root page name in english global _unformatted_text_cache if not lang in _unformatted_text_cache: (texts, unformatted) = i18n.loadLanguage(request, lang) # XXX add error handling _unformatted_text_cache[lang] = unformatted for k, v in _unformatted_text_cache[lang].iteritems(): if v == page_title: trans = i18n.getText(k, self.request, l, False) en = i18n.getText(k, self.request, 'en', False) if trans == en and l != 'en': trans = page_title # false translation else: en = i18n.getText(page_title, self.request, 'en', False) if trans == en and l != 'en': trans = page_title # false translation if trans != page_title: translated_page = Page(self.request, trans) if translated_page.exists(): lang_links.append(translated_page.link_to(request, l)) if lang_links: html = [ u'
', u'

%s

' % _("Other languages"), u'\n'.join(lang_links), u'
' ] return u'\n'.join(html) else: return u'' }}} `langpanel` must obviously be called somewhere in the theme for this to work, generally in the `header` function: {{{ --- alex.py.orig Sat Jan 21 18:09:37 2006 +++ alex.py Sat Jan 21 18:09:39 2006 @@ -107,6 +107,7 @@ self.wikipanel(d), self.pagepanel(d), self.userpanel(d), + self.langpanel(d), self.credits(d), u'', }}} I have updated the above code to use the builtin translation system instead of looking manually through the dicts so that we benefit from the builtin translations for (e.g.) the system pages. -- TheAnarcat <> There is a simpler patch below which dispenses with translated page name and just searches for pages with a locale prefix. For example, `FrontPage` will look for translations in `br/FrontPage`, `fr/FrontPage`, `zh/FrontPage`, etc. Translated pages will link back to the default version plus other translations, ie: `fr/FrontPage` will offer a link to `FrontPage` in addition to other translated pages. -- <> === Samples === To see an example, head for http://wiki.koumbit.net/WikiKoumbit or http://rocococamp.info. === Credits === Thanks to DasSheep for python and MoinMoin support in creating this patch. -- TheAnarcat <> === Patches === Here is a patch for the modern theme: [[attachment:modern.patch]] -- TheAnarcat <> ''Update'': as the above snippet, i've updated the patch to deal with system pages, see [[attachment:modern_v2.patch]]. I kept the original patch for future reference. -- TheAnarcat <> ''Updates'': [[attachment:simpler.patch]] looks only for pages with locale prefix. -- <> == Related material == * MultiLang * [[Creating multilingual wikis and wiki engines]] * ../InterLanguageLinks * ../LanguageCategoriesForTemplates == Current issues == I don't think this method scales to the level we need (interconnecting a wiki farm of a dozend wikis with some thousand pages each and more). Hmm.. is there plans on how to do better? Something that would involve another method than WikiDict``s? -- TheAnarcat <> How could I create a "translate this page button"? I guess it would have to lead to a form like this: {{{
}}} I think I can figure out how to do that, but the issue for me is to redirect this to another page that will then, itself, redirect to the new page (to create it) with `?action=edit&template=%current-page%` appended... Any ideas? -- TheAnarcat <> == Discussion == I think this is a nice feature. I would like to suggest to add this to the header of a page: {{{ }}} ---- CategoryFeatureRequest CategoryMoinMoinPatch