Skip to main content

Records gettext translation messages and synchronizes to message catalogs.

Project description

Overview

The recorder is attached to an existing translation function keeps track of the inputs and outputs.

The result is a locales directory structure:

<domain>.pot
<lang>/
<lang>/LC_MESSAGES
<lang>/LC_MESSAGES/<domain>.po
...

This structure is written on process exit.

Note that when the recorder is initialized, it imports any existing message catalog. That is, it’s robust to process startup/shutdown and can operate continuously.

Usage

In Python-code, enable the translation recorder by wrapping an existing translation function.

The easiest way to wire this up is by patching the module that holds the function (if possible):

import zope.i18n
import translationrecorder

# Patch Zope's translation function
zope.i18n.translate = translationrecorder.Recorder(
    zope.i18n.translate, './locales'
    )

Framework Integration

There’s integration included for the Pyramid and Zope/Plone frameworks.

Set the environment variable RECORD_TRANSLATIONS to an existing locales directory and run your server process:

$ mkdir ./locales
$ RECORD_TRANSLATIONS=./locales bin/paster serve ...

This requires that the translationrecorder module is imported. This is handled automatically on Plone. For other systems:

import translationrecorder

Technically, the package applies patches against the global translation functions of the applicable frameworks.

Author

Malthe Borch <mborch@gmail.com>

Changes

1.0 (2011-11-28)

  • Initial public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

translationrecorder-1.0.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file translationrecorder-1.0.tar.gz.

File metadata

File hashes

Hashes for translationrecorder-1.0.tar.gz
Algorithm Hash digest
SHA256 019fa38db946e75d4b754445026f3da979f7f9eeccac1a8a1e47c67bba52b210
MD5 5a7f59db5c5823fd2bb4c8069c83612e
BLAKE2b-256 d4a7ac531094de2fd7f20ff64808ca5351bd9e3f5fb7f9bd5db123b48a65558d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page