Skip to main content

latex-ji18n (LaTeX -> Jinja2 -> internacionalization)

Set of tools to render LaTeX documents in multiple languages using Jinja2 Python library and some conventions inspired by jekyll-multiple-languages-plugin.

So you have a LaTeX document that you want to internationalize. The first step is convert your project in a template. Using latex-ji18n command line tool, you can render YAML files into LaTeX Jinja2 templates.

Install

You need a pdflatex binary available at the PATH. Then run:

pip install latex-ji18n

Separation of data, style and layout

Next structure of directories is the workflow that imposes this utility working with it:

 ├── _config
 │   ├── data.yml
 │   ├── layout.yml
 │   ├── style.yml
 │   └── _private
 │       ├── data.yml
 │       └── layout.yml
 ├── dist
 │   ├── en.pdf
 │   ├── es.pdf
 │   └── fr.pdf
 ├── _i18n
 │   ├── _private
 │   │   └── es.yml
 │   ├── en.yml
 │   ├── es.yml
 │   └── fr.yml
 └── src
     ├── template.tex
     └── your-assets.jpg

The process is simple, you write your replacements in src/template.tex Jinja2 template file with \BLOCK{} and \VAR{} syntax, write your data or options inside _i18n/ and _config/ folders YAML files, run latex-ji18n to compile the PDFs and you will see each one for each language in dist/ folder.

Convention for separate data files

  • _private/: Directories that stores all the sensitive data that you don't want to include, for example, sharing your repositorie with GIT. This folders are totally optional. Inside each one, you must keep the same files structure that in _i18n/ and _config/ directories.
  • data.yml: Data that you want to include in the context, at the root of the dictionary, common to all languages. All the fields stored here are included at the root of the context. You can't include the fields layout nor style in the root of the context for data files.
  • layout.yml: Designed to store some layout options for the template. Fields stored here are available for the context in the layout dictionary.
  • style.yml: Designed to store style options for the template. Fields stored here are available for the context in the style dictionary.
  • _i18n/{language}.yml: Overrides data for the context. Designed to localize your data output. An output file will be created for every {language}.yml file, with the name of {language}.pdf.

Context creation

The contexts are created updating a dictionary iterating over files in next order:

  • config/data.yml
  • config/layout.yml
  • config/style.yml
  • config/_private/data.yml
  • config/_private/layout.yml
  • config/_private/style.yml
  • _i18n/{language}.yml
  • _i18n/_private/{language}.yml

Context data is dumped following next rules:

  • All the data located in data.yml files is dumped at the root of the context..
  • Data located in layout.yml files are dumped into a layout variable at the root of the context.
  • Data located in style.yml files are dumped into a layout variable at the root of the context.
  • If src/ directory contains .bib files, database entries located at this files will be available ordered by entry type at _bibdb variable at the root of the context.

Metadata

Release files for latex-ji18n 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for latex-ji18n 0.0.4
File Size Uploaded Provenance Actions
latex-ji18n-0.0.4.tar.gz 12.4 kB Without provenance Details for latex-ji18n-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for latex-ji18n 0.0.4
File Interpreter ABI Platform Actions
latex_ji18n-0.0.4-py2.py3-none-any.whl Python 3, Python 2 none any Details for latex_ji18n-0.0.4-py2.py3-none-any.whl

Total release size: 27.4 kB

Release files / latex-ji18n-0.0.4.tar.gz

Download URL latex-ji18n-0.0.4.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f1935268d874904cad1c5946d0932d7bb2d7b59d0da45c79eee423d63d85f81f
BLAKE2b-256 checksum
How to use checksums
a8caa90df4e451d8c35dd1ecc1983935b3312cebc1c84e98ce0f76656f472f98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Release files / latex_ji18n-0.0.4-py2.py3-none-any.whl

Download URL latex_ji18n-0.0.4-py2.py3-none-any.whl
Size 14.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
895ec2b2495712e9ebd1e30173822aec156575e367439d165a2ef3e8ade00614
BLAKE2b-256 checksum
How to use checksums
23016f7a46290a98b180869769439af86020b119562d465e427b57795d6a1123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

Security for latex-ji18n 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page