=====
Usage
=====

From a Python program
=====================

To use potranslator in a python project:

.. code-block:: console

    from potranslator import PoTranslator

    languages = ('fr', 'es', 'it')
    translator = PoTranslator(pot_dir='path/to/pot_dir', locale_dir='path/to/locale_dir')

    results = translator.translate_all_pot(src_lang='en', target_langs=languages, auto_save=False)


Commands, options, environment variables
========================================

Commands
--------

Type `potranslator` without arguments to show the help instructions.


Setup environment variables
---------------------------

All command-line options can be set with environment variables using the format POTRANSLATOR_<UPPER_LONG_NAME> .

Dashes (-) have to replaced with underscores (_).

For example, to set the languages:

.. code-block:: console

   $ export POTRANSLATOR_LANGUAGE=de,ja

This is the same as passing the option to potranslator directly:

.. code-block:: console

   $ potranslator <command> --language=de --language=ja


Setup sphinx conf.py
--------------------

Add the following settings to your sphinx document's conf.py if it exists:

.. code-block:: console

   locale_dirs = ['locale/']   #for example
   gettext_compact = False     #optional


Setup Makefile / make.bat
-------------------------

`make gettext` will generate pot files into `_build/gettext` directory,
however pot files can be generated in the `locale/pot` if convenient.

You can do that by replacing `_build/gettext` with `locale/pot` in your
`Makefile` and/or `make.bat` that was generated by sphinx-quickstart.
