Part of lp.translations.utilities.translation_import View In Hierarchy
Known subclasses: lp.translations.utilities.translation_import.POFileImporter, lp.translations.utilities.translation_import.POTFileImporter
This class is meant to be subclassed for the specialised tasks of importing translations (PO)or translation templates (POT) respectively. Subclasses need to implement the importMessage method and extend the constructor to set self.pofile and self.potemplate correctly.
Method | __init__ | Base constructor to set up common attributes and parse the imported |
Method | getOrCreatePOTMsgSet | Get the POTMsgSet that this message belongs to or create a new |
Method | share_with_other_side | Returns True if translations should be shared with the other side. |
Method | is_upstream_import_on_sourcepackage | Use TranslationMessage.acceptFromUpstreamImportOnPackage`. |
Method | translations_are_msgids | Are these English strings instead of translations? |
Method | storeTranslationsInDatabase | Try to store translations in the database. |
Method | importMessage | Import a single message. |
Method | importFile | Import a parsed file into the database. |
Method | format_exporter | Get the exporter to display a message in error messages. |
Method | _storeCredits | Store credits but only those provided by the maintainer. |
Method | _validateMessage | Validate the message and report success or failure. |
Method | _acceptMessage | Try to approve the message, return None on TranslationConflict. |
Method | _addUpdateError | Add an error returned by updateTranslation. |
Method | _addConflictError | Add an error if there was an edit conflict. |
Subclasses must extend this constructor to set the default values according to their needs, most importantly self.pofile and self.potemplate.
Parameters | translation_import_queue_entry | The queue entry, as has been provided to TranslationImporter.importFile. |
importer | The importer to use for parsing the file. | |
logger | An optional logger. |
Parameters | message | The message. |
Returns | The POTMsgSet instance, existing or new. |
If this template uses symbolic message ids, the English POFile will contain the English original texts that correspond to the symbols.
Perform check if a PO file is available and if the message has any translations that can be stored. If an exception is caught, an error is added to the list in self.errors but the translations are stored anyway, marked as having an error.
Parameters | message_data | The message data for which translations will be stored. |
potmsgset | The POTMsgSet that this message belongs to. | |
Returns | The updated translation_message entry or None, if no storing war done. |
This method must be implemented by the derived class to perform all necessary steps to import a single message into the database.
Parameters | message | The message to be imported. |
Raises | NotImplementedError | if no implementation is provided. |
Loop through all message entries in the parsed file and import them using the importMessage.
Returns | The errors encountered during the import. |
This has been put in a method enhance clarity by removing the long error text from the calling method.
Parameters | message | The current message from the translation file. |
potmsgset | The current messageset for this message id. | |
errormsg | The errormessage returned by updateTranslation. |
This has been put in a method enhance clarity by removing the long error text from the calling method.
Parameters | message | The current message from the translation file. |
potmsgset | The current messageset for this message id. |