wiki:TranslatedPagesMacro

Version 39 (modified by Dirk Stöcker, 6 years ago) (diff)

Add text

Show translated versions of wiki page

Description

This is a macro to output a list of translated versions of a current page. The base language page should use the wiki name without language code, and the translated wiki pages use a configurable version including language code. The [[TranslatedPages]] macro generates a list of languages as follows:

english example

Each translated page has the same macro, but containing the revision of the base page. When the revision of the base page is newer than the translated revision (someone updated English page), then below the language links in menu a new menu point appears showing the translated revisions and newest one. When clicking on that link, the differences between that revision are displayed. These can then be used to update the translation. During updating the revision in the translated page needs to be increased to the newest one and the additional links disappears.

Bugs/Feature Requests

Existing bugs and feature requests for TranslatedPagesMacro are here.

If you have any issues, create a new ticket.

defect

2 / 2

enhancement

4 / 4

Download

Download the zipped source from here.

Source

You can check out TranslatedPagesMacro from from here using Subversion, or browse the source in Trac.

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

See the Trac plugin requirements for instructions on installing setuptools. Setuptools includes the easy_install application which you can use to install the TranslatedPagesMacro:

easy_install TranslatedPagesMacro

There is also this link for setuptools to find the SVN download.

Example

An example of the required language specification page can be found in the directory default-pages/TracLanguages (it will not be installed automatically!).

For example, the page WikiStart was translated to Chinese version Zh_CN:WikiStart, Russian version Ru:WikiStart and Spanish version Es:WikiStart. Insert [[TranslatedPages]] to WikiStart will generate the following list:

english example

And in Zh_CN:WikiStart will generate:

chinese example

When translated page is outdated, Es:WikiStart will generate:

espanol example with update

An example of an actively used installation can be found at http://josm.openstreetmap.de/wiki/Translations.

Macro help text

Following chapter contains the help text found at [WikiMacros#TranslatedPages-macro] on systems with the macro installed.

Macro to show the translated pages list.

Simply calling that macro in a page adds a menu linking to all available translations of a page.

A language page (usually TracLanguages) must provide the language codes as a table with following entries:

||<language code>||<language name>||<english name>||<description>||<base language link indication>||

The description contains the text displayed above language links in that language (usually a variant of 'Other languages'). A table title line starting with ||= is not parsed.

The base language link indication is the default value for wikitr: links (see below) and describes how links to base language should be formatted. It must contain one {t} which is replaced by the label (e.g. {t} (en) to append a note in brackets). Other parameters are {b} for the base language code, {c} for the base language code in lowercase letters and {n} for the base language name.

The Macro accepts arguments as well:

  • revision=<num> to specify the version of the base page when last translated, a negative revision indicates that a page needs updating in the status overview table
  • outdated=<text> !mark the page as outdated with given comment
  • silent don't output empty chapter for show options when nothing is shown
  • showoutdated to show all pages, where revision does not match base revision
  • showmissing to show all pages, where translation is missing
  • showproblems to show all pages which have problems
  • showuntranslated to show all untranslated pages
  • showstatus to show one big status table
  • skipmissing skip links to missing pages in status table (speed up display a lot)
  • lang=<code> to restrict output of show outdated, status or missing to a specific language
  • label_outdated label to display when using the showoutdated option

Use wikitr:[basetext:] in links to reference the translated form of a page when it exists, the original otherwise. In case the optional part basetext: is used this text is used to indicate links to the base language (see above for format). When using these links translators do not need to update links when they step by step add translated pages. Using this macro on the base langue pages does no harm, but may help in translation when doing copy and paste.

Links can look like [[wikitr:Link|Label]], [wikitr::{t} ({n}):Link|Label]], [[wikitr::Link|Label]], [wikitr:Link], [wikitr:Link Label] and so on (see TracLinks).

Additional descriptions and comments

  • The status table uses following colors (note status table may require a lot of calculation time depending on number of pages and languages).
    • Red: There is an error with this page (shown in error list)
    • Yellow: Page needs update
    • Green: Everything up-to-date
    • Grey: Page is missing
  • The outdated parameter is useful when a page is known to be outdated, but there is no time to fix it immediately. The page is marked yellow in the status table and the text argument is displayed on the page itself.
  • The macro also works without the revision parameter on the translated pages, but it is a very helpful tool to keep original and translations in sync.
  • When using the show... parameters, no translation message link box is created. You need to add another instance of the macro if you want to have these texts and the page links.

Troubleshooting

When you setup the macro and it does not work:

  • Check if the macro text is in the WikiMacros page as explained above. If it is not, then the installation is broken.
  • Check if TracLanguages pages is available and in the correct format.
  • If you created pages with language code and macro inserted, adding [[TranslatedPages(showproblems)]] to any page and then previewing (no need to save) should tell you existing problems.

Recent Changes

18588 by stoecker on 2023-11-08 17:40:31
TranslatedPagesMacro: handle totally empty pages
18584 by stoecker on 2023-11-04 20:10:14
automated 2to3 conversion
17677 by stoecker on 2020-02-14 07:19:42
fix default for empty code spec
(more)

Author/Contributors

Author: ftofficer
Maintainer: Dirk Stöcker
Contributors: dottedmag

Attachments (5)

Download all attachments as: .zip