================== Developing Roundup ================== .. note:: The intended audience of this document is the developers of the core Roundup code. If you just wish to alter some behaviour of your Roundup installation, see `customising roundup`_. .. contents:: Getting Started --------------- Anyone wishing to help in the development of Roundup must read `Roundup's Design Document`_ and the `implementation notes`_. All development is coordinated through two resources: - roundup-devel mailing list at http://lists.sourceforge.net/mailman/listinfo/roundup-devel - The issue tracker running at http://issues.roundup-tracker.org/ Website, wiki ------------- The website is in our repository, so is the configuration of the wiki. Please check the README.txt in the "website" subdirectory of a current checkout. Issue Tracker ------------- The tracker resides on psf.upfronthosting.co.za. (2012-07-04) 2048 c4:ad:63:92:1b:c0:4a:35:c8:c5:3e:96:51:c0:88:67 (RSA) The roundup installation belongs to the user roundup. In ~roundup, all trackers are stored and the roundup code itself. roundup is started through /etc/init.d/roundup; other parts of the installation are started through /etc/init.d/{postgresql-8-1,spambayes,postfix}. The machine is operated by Upfronthosting in South Africa. The meta tracker is http://psf.upfronthosting.co.za/roundup/meta/ In this tracker, Upfronthosting people are the users izak and roche. The Roundup tracker http://issues.roundup-tracker.org/ is in ~roundup/trackers/roundup The configuration is in the "website/issues" section of Roundup's Mercurical SCM repository and copied manually to the live tracker. A checkout of the roundup sources is in ~roundup/src/roundup-src. Small Changes ------------- Most small changes can be submitted as patches through the issue tracker or sent to `roundup-devel mailing list`_. Source Repository Access ------------------------ See http://www.roundup-tracker.org/code.html. For all other questions ask on the development mailinglist. Project Rules ------------- Mostly the project follows Guido's Style (though naming tends to be a little relaxed sometimes). In short: - 80 column width code - 4-space indentations - All modules must have an Id line near the top Other project rules: - New functionality must be documented, even briefly (so at least we know where there's missing documentation) and changes to tracker configuration must be logged in the upgrading document. - subscribe to roundup-checkins to receive checkin notifications from the other developers with write access to the source-code repository. - discuss any changes with the other developers on roundup-dev. If nothing else, this makes sure there's no rude shocks - write unit tests for changes you make (where possible), and ensure that all unit tests run before committing changes - run pychecker over changed code The administrators of the project reserve the right to boot developers who consistently check in code which is either broken or takes the codebase in directions that have not been agreed to. Debugging Aids -------------- See :doc:`debugging `. Internationalization Notes -------------------------- How stuff works: 1. Strings that may require translation (messages in human language) are marked in the source code. This step is discussed in `Marking Strings for Translation`_ section. 2. These strings are all extracted into Message Template File ``locale/roundup.pot`` (_`POT` file). See `Extracting Translatable Messages`_ below. 3. Language teams use POT file to make Message Files for national languages (_`PO` files). All PO files for Roundup are kept in the ``locale`` directory. Names of these files are target locale names, usually just 2-letter language codes. `Translating Messages`_ section of this chapter gives useful hints for message translators. 4. Translated Message Files are compiled into binary form (_`MO` files) and stored in ``locale`` directory (but not kept in the source code repository, as they may be easily made from PO files). See `Compiling Message Catalogs`_ section. 5. Roundup installer creates runtime locale structure on the file system, putting MO files in their appropriate places. 6. Runtime internationalization (_`I18N`) services use these MO files to translate program messages into language selected by current Roundup user. Roundup command line interface uses locale name set in OS environment variable ``LANGUAGE``, ``LC_ALL``, ``LC_MESSAGES``, or ``LANG`` (in that order). Roundup Web User Interface uses language selected by currently authenticated user. Additional details may be found in `GNU gettext`_ and Python `gettext module`_ documentation. `Roundup source distribution`_ includes POT and PO files for message translators, and also pre-built MO files to facilitate installations from source. Roundup binary distribution includes MO files only. .. _GNU gettext: GNU gettext package ^^^^^^^^^^^^^^^^^^^ This chapter is full of references to GNU `gettext package`_. GNU gettext is a "must have" for nearly all steps of internationalizing any program, and it's manual is definetely a recommended reading for people involved in `I18N`_. There are GNU gettext ports to all major OS platforms. Windows binaries are available from `GNU mirror sites`_. Roundup does not use GNU gettext at runtime, but it's tools are used for `extracting translatable messages`_, `compiling message catalogs`_ and, optionally, for `translating messages`_. Note that ``gettext`` package in some OS distributions means just runtime tools and libraries. In such cases gettext development tools are usually distributed in separate package named ``gettext-devel``. Marking Strings for Translation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Strings that need translation must be marked in the source code. Following subsections explain how this is done in different cases. If translatable string is used as a format string, it is recommended to always use *named* format specifiers:: _('Index of %(classname)s') % locals() This helps translators to better understand the context of the message and, with Python formatting, remove format specifier altogether (which is sometimes useful, especially in singular cases of `Plural Forms`_). When there is more than one format specifier in the translatable format string, named format specifiers **must** be used almost always, because translation may require different order of items. It is better to *not* mark for translation strings that are not locale-dependent, as this makes it more difficult to keep track of translation completeness. For example, string ```` (in ``index()`` method of the request handler in ``roundup_server`` script) has no human readable parts at all, and needs no translations. Such strings are left untranslated in PO files, and are reported as such by PO status checkers (e.g. ``msgfmt --statistics``). Command Line Interfaces ~~~~~~~~~~~~~~~~~~~~~~~ Scripts and routines run from the command line use "static" language defined by environment variables recognized by ``gettext`` module from Python library (``LANGUAGE``, ``LC_ALL``, ``LC_MESSAGES``, and ``LANG``). Primarilly, these are ``roundup-admin`` script and ``admin.py`` module, but also help texts and startup error messages in other scripts and their supporting modules. For these interfaces, Python ``gettext`` engine must be initialized to use Roundup message catalogs. This is normally done by including the following line in the module imports:: from i18n import _, ngettext Simple translations are automatically marked by calls to builtin message translation function ``_()``:: print _("This message is translated") Translations for messages whose grammatical depends on a number must be done by ``ngettext()`` function:: print ngettext("Nuked %i file", "Nuked %i files", number_of_files_nuked) Deferred Translations ~~~~~~~~~~~~~~~~~~~~~ Sometimes translatable strings appear in the source code in untranslated form [#note_admin.py]_ and must be translated elsewhere. Example:: for meal in ("spam", "egg", "beacon"): print _(meal) In such cases, strings must be marked for translation without actual call to the translating function. To mark these strings, we use Python feature of automatic concatenation of adjacent strings and different types of string quotes:: strings_to_translate = ( ''"This string will be translated", ""'me too', ''r"\raw string", ''""" multiline string""" ) .. [#note_admin.py] In current Roundup sources, this feature is extensively used in the ``admin`` module using method docstrings as help messages. Web User Interface ~~~~~~~~~~~~~~~~~~ For Web User Interface, translation services are provided by Client object. Action classes have methods ``_()`` and ``gettext()``, delegating translation to the Client instance. In HTML templates, translator object is available as context variable ``i18n``. HTML templates have special markup for translatable strings. The syntax for this markup is defined on `ZPTInternationalizationSupport`_ page. Roundup translation service currently ignores values for ``i18n:domain``, ``i18n:source`` and ``i18n:target``. Template markup examples: * simplest case::
Say no more!
this will result in msgid ``"Say no more!"``, with all leading and trailing whitespace stripped, and inner blanks replaced with single space character. * using variable slots::
And now...
No.
THE LARCH
Msgid will be: ``"And now...
No.${slideNo}
THE LARCH"``. Template rendering will use context variable ``number`` (you may use any expression) to put instead of ``${slideNo}`` in translation. * attribute translation::