wiki:TranslatedPagesMacro

Version 21 (modified by Dirk Stöcker, 13 years ago) (diff)

Prevent wrong link.

Show translated versions of wiki page

Description

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

english example

to direct to translated versions of wiki pages.

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 an 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.

Get the Plugin

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

You can also obtain the code from the Trac Subversion repository:

svn co http://trac-hacks.org/svn/translatedpagesmacro

or download [download:translatedpagesmacro zipped source].

See TracPlugins for instructions on building and installing plugins.

You can browse the source in Trac.

This is a link for setuptools to find the SVN download

Upgrading from older version 0.3

The macro enhanced a lot since version 0.3. A major change is the layout of the pages. Version 0.3 hardcoded the format page/<lang>. The new version has <lang>:page as default which is used more ofthen for wikis.

For existing installations using the old schema following settings must be used:

[translatedpages]
template = {page}/{lang}
regexp = ([a-z]{2})

also the layout of the language specification page changed (more entries required tables style design).

Example

An example of the required language specification page can be found at TranslatedPagesMacro/TracLanguages (note that this wiki installation does not yet display the table heads correctly).

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 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) (generally location is wiki/TracLanguages, content can copy from TracLanguages. page will show normal table what's different with TracLanguages) must provide the language codes as a table with following entries:

||<language code>||<language name>||<english name>||<description>|| 

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 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
  • lang=<code> to restrict output of show outdated, status or missing to a specific language

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 told above. If not installation is broken.
  • Check if TracLanguages pages is available and in 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.

Known Issues

No results

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: ftofficer
Contributors: dottedmag, stoecker

Attachments (5)

Download all attachments as: .zip