.. _hooks:

Hooks
=====

Pootle supports hooks to customize its behavior at various points in its
interaction with :doc:`Version Control Systems <version_control>`,
translation update and translation initialization.

Hooks are Python scripts and can do things like checking or converting
formats before commit.

.. note:: See `bug 2559 <http://bugs.locamotion.org/show_bug.cgi?id=2559>`_ tracking changes
   needed for hooks to run on Pootle 2.5.


.. _hooks#implementing:

Implementing a hook
-------------------
Hooks are Python scripts stored in the *pootle/scripts* directory and are
named after their project name.  Thus, *hello.py* for a project called
**hello**.

The project hook should implement functions for each needed hooktype.


.. _hooks#hooktypes:

Available hooktypes
-------------------

+------------+---------------------------+---------+
| Hooktype   | Arguments                 | Return  |
+============+===========================+=========+
| initalize  | projectdir, languagecode  |         |
+------------+---------------------------+---------+
| precommit  | file, author, message     |         |
+------------+---------------------------+---------+
| postcommit | file, success             |         |
+------------+---------------------------+---------+
| preupdate  | file                      |         |
+------------+---------------------------+---------+
| postupdate | file                      |         |
+------------+---------------------------+---------+
