Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malthe/translationrecorder
Utility to record gettext translations based on calls to a wrapped translation function.
https://github.com/malthe/translationrecorder
Last synced: 15 days ago
JSON representation
Utility to record gettext translations based on calls to a wrapped translation function.
- Host: GitHub
- URL: https://github.com/malthe/translationrecorder
- Owner: malthe
- Created: 2011-11-24T13:41:27.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-26T12:52:05.000Z (over 11 years ago)
- Last Synced: 2024-10-22T20:22:43.642Z (2 months ago)
- Language: Python
- Homepage:
- Size: 154 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
Awesome Lists containing this project
README
Overview
--------The recorder is attached to an existing translation function keeps
track of the inputs and outputs.The result is a *locales* directory structure::
.pot
/
/LC_MESSAGES
/LC_MESSAGES/.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