Giter VIP home page Giter VIP logo

sphinx-intl's Introduction

sphinx-intl: translation support utility for Sphinx

https://travis-ci.org/sphinx-doc/sphinx-intl.svg?branch=master

sphinx-intl is a utility tool that provides several features that make it easy to translate and to apply translation to Sphinx generated document. Optional: support the Transifex service for translation with Sphinx .

This section describe to translate with Sphinx and sphinx-intl command.

  1. Create your document by using Sphinx.

  2. Add configurations to your conf.py:

    locale_dirs = ['locale/']   #path is example but recommended.
    gettext_compact = False     #optional.
    

    locale_dirs is required and gettext_compact is optional.

  3. Extract document's translatable messages into pot files:

    $ make gettext
    
  4. Setup/Update your locale_dir:

    $ sphinx-intl update -p _build/locale -l de -l ja
    

    Done. You got these directories that contain po files:

    • ./locale/de/LC_MESSAGES/
    • ./locale/ja/LC_MESSAGES/
  5. Translate your po files under ./locale/<lang>/LC_MESSAGES/.

  6. Build mo files and make translated document:

    $ sphinx-intl build
    $ make -e SPHINXOPTS="-D language='ja'" html
    

That's all!

  • create or update po files from pot files.
  • build mo files from po files.

These features need transifex-client library.

  • create .transifexrc file from environment variable, without interactive input.
  • create .tx/config file without interactive input.
  • update .tx/config file from locale/pot files automatically.
  • build mo files from po files in the locale directory.

You need to use tx command for below features:

  • tx push -s : push pot (translation catalogs) to transifex.
  • tx pull -l ja : pull po (translated catalogs) from transifex.
  • Your transifex account if you want to download po files from transifex or you want to translate on transifex.
  • external library: transifex-client

Recommend strongly: use virtualenv for this procedure:

$ pip install sphinx-intl

If you want to use Optional Features, you need install additional library:

$ pip install sphinx-intl[transifex]

Type sphinx-intl without arguments, options to show command help.

All command-line options can be set with environment variables using the format SPHINXINTL_<UPPER_LONG_NAME> . Dashes (-) have to replaced with underscores (_).

For example, to set the languages:

export SPHINXINTL_LANGUAGE=de,ja

This is the same as passing the option to sphinx-intl directly:

sphinx-intl <command> --language=de --language=ja

Add below settings to sphinx document's conf.py if not exists:

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

make gettext will generate pot files into _build/locale directory, however pot files should be generated in the locale/pot is convenient. You can be done by replacing _build/locale with locale/pot in your Makefile and/or make.bat that was generated by sphinx-quickstart.

Licensed under the BSD license. See the LICENSE file for specific terms.

This utilty derived from these projects.

See: https://github.com/sphinx-doc/sphinx-intl/blob/master/CHANGES

sphinx-intl's People

Contributors

shimizukawa avatar tk0miya avatar ideasman42 avatar knzm avatar giacomos avatar guitorri avatar s0undt3ch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.