Translations/DivingIntoCode

Not logged in - Log In / Register

Rendering of reStructured text is not possible, please install Docutils.

General translations overview
=============================

Translations database model
---------------------------

Originally modelled around gettext PO files (http://www.gnu.org/software/gettext/manual/html_node/PO-Files.html).

 * POTemplate: a collection of POTMsgSets
 * TranslationTemplateItem: a linking table for POTemplate and POTMsgSet
 * POTMsgSet: an original untranslated English message
 * POMsgID: an English string
 * POFile: a collection of translated messages for a single language and a single POTemplate
 * TranslationMessage: a single translated message (for a language and POTMsgSet)
 * POTranslation: a translated string

Browsing interface
------------------

 * IHasTranslationTemplates: provides a generic API to access collection of templates in a context (ProductSeries, DistroSeries, SourcePackage)
 * ITranslatedLanguage (implemented by IProductSeriesLanguage): provides a generic access to all the POFiles for a language in a context (eg. ProductSeries)
 * IDistroSeriesLanguage: as above, but for DistroSeries (should inherit ITL)

Message sharing
---------------

By allowing one POTMsgSet to participate in several different POTemplates, we optimize DB usage and implement a translations feature where you don't have to translate a single string twice over the lifetime of a software component.

This concept is called "message sharing" (because internally, POTMsgSets, or English messages, are shared between participating templates), or more frequently in public "translations sharing" (because that's how it appears to users).

Today, message sharing happens between all the POTemplates having the same `name` in a set of related templates (all templates for a single product, or for a single source package; if a product and a source package are "linked", the full set of "sharing templates" is the union of all templates in either).

Core
----

Core functionality is provided by setCurrentTranslation method which manages setting of appropriate flags for a single translation message.

https://dev.launchpad.net/Translations/Specs/UpstreamImportIntoUbuntu/FixingIsImported/setCurrentTranslation

Translation statistics
======================

 * IRosettaStats interface: model quite behind, look at TranslatedLanguageMixin.recalculateCounts() to get a mapping to the current model
 * IPOFile.updateStatistics call to update statistics on a single POFile
 * cronscripts/rosetta-pofile-stats.py runs updateStatistics on all POFiles in database
 * cronscripts/rosetta-pofile-stats-daily.py runs updateStatistics on all POFiles modified in the last 7 days (config option), including POFiles that have been indirectly touched through message sharing
 * DistroSeriesLanguage contains cached values for a DistroSeries by language; these are updated by cronscripts/update-stats.py which calls DistroSeries.updateStats() and updates LaunchpadStatistics object (lib/canonical/launchpad/database/launchpadstatistics.py)
 * POFileTranslator, while not strictly statistics, is a cache of all the Persons that have contributed to a POFile and is cached for performance reasons

Translation permissions model
=============================

ITranslationGroup is used for managing translation permissions.
It provides a mapping of translator per language (ITranslator).

Permissions for a product, project group or distribution are defined by a TranslationGroup and a translation permission policy (https://help.launchpad.net/Translations/YourProject/PermissionPolicies)

Translations import
===================

Import queue (tag: import-queue)
--------------------------------

 * TranslationImportQueueEntry: translation import queue implementation
 * cronscripts/rosetta-poimport.py: processes the import
 * cronscripts/rosetta-approve-imports.py: does automatic approval of templates/translations and cleans up deleted and old entries (also called translation-import-queue-gardener)

Imports (tag: rosetta-imports)
------------------------------

Most of the code in lib/lp/translations/utilities:

 * Generic import code in translation_import.py
 * Generic data (TranslationFileData, TranslationMessageData) model in translation_common_format.py
 * Format-specific import code in gettext_po_parser.py, gettext_po_importer.py, mozilla*.py (for XPI files)
 * Import carried out through POFile.importFromQueue and POTemplate.importFromQueue methods
 * ExistingPOFileInDatabase: "super-fast-imports" caching system which fetches just the relevant message data to determine which messages definitely do not need re-importing (i.e. they are identical to what we have in the DB already)

Translations export
===================

Queue
-----
 * POExportRequest table
 * cronscripts/rosetta-export-queue.py

Exports
-------

Most of the code in lib/lp/translations/utilities:
 * Generic export code in translation_export.py
 * Format specific code in gettext_po_exporter.py, gettext_mo_exporter.py, xpi_*_exporter.py

Ubuntu specifics
================

Language packs
--------------

Language packs are tarballs containing all (for full) POFiles or only those updated since the last full export (for "delta") for a single DistroSeries.  These are processed outside Launchpad by langpack-o-matic to product actual installable language-packs.

cronscripts/language-pack-exporter.py is the entry point for the script

DistroSeries opening
--------------------

DistroSeries opening is the process of copying translations from the previous distribution release to the new one.  With message-sharing, only higher-level metadata is actually copied (POTemplate, POFile, TranslationTemplateItem, POFileTranslator).

cronscripts/copy-translations-from-parent.py

Bazaar import
=============

 * cronscripts/rosetta-branches.py does the import
 * lib/lp/code/model/branchjob.py RosettaUploadJob does the upload

Bazaar export
=============

 * cronscripts/translations-export-to-branch.py

Template generation
===================

Pottery
-------

Pottery is (supposed to be) generic code to detect if we are likely to be able to generate a template, and generate it if we are.  It is not very generic atm.

 * lib/lp/translations/pottery/ for template detection
 * lib/canonical/buildd/pottery/ for template generation

Template build farm jobs
------------------------

 * Old-style build farm job *and* a branch job TranslationTemplatesBuildJob: lib/lp/translations/model/translationtemplatesbuildjob.py
 * Build-farm job behavior: lib/lp/translations/model/translationtemplatesbuildbehaviour.py
 * New-style build farm job TranslationTemplatesBuild in lib/lp/translations/model/translationtemplatebuild.py

Web UI
======

 * Core UI are POFile:+translate and CurrentTranslationMessage:+translate views
 * TBC.

Translations/DivingIntoCode (last edited 2011-01-18 14:01:22 by danilo)