LaTeX Jinja2 i18n utilities.
Project description
latex-ji18n (LaTeX + Jinja2 + YAML = i18n)
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 your system 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 (optional)
│ ├── data.yml
│ └── layout.yml
├── dist
│ ├── en.pdf
│ ├── es.pdf
│ └── fr.pdf
├── _i18n
│ ├── _private (optional)
│ │ └── es.yml
│ ├── en.yml
│ ├── es.yml
│ └── fr.yml
└── src
├── template.tex
├── assets.jpg
└── references.bib
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 fieldslayoutnorstylein 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 thelayoutdictionary.style.yml: Designed to store style options for the template. Fields stored here are available for the context in thestyledictionary._i18n/{language}.yml: Overrides data for the context. Designed to localize your data output. An output file will be created for every{language}.ymlfile, with the name of{language}.pdf.
Context creation
The contexts are created updating a dictionary iterating over files in next order:
config/data.ymlconfig/layout.ymlconfig/style.ymlconfig/_private/data.ymlconfig/_private/layout.ymlconfig/_private/style.yml_i18n/{language}.yml_i18n/_private/{language}.yml
Context data is dumped following next rules:
- All the data located in
data.ymlfiles is dumped at the root of the context. - Data located in
layout.ymlfiles are dumped into alayoutvariable at the root of the context. - Data located in
style.ymlfiles are dumped into astylevariable at the root of the context. - If
src/directory contains.bibfiles, database entries located at this files will be available ordered by entry type at_bibdbvariable at the root of the context.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latex-ji18n-0.0.6.tar.gz.
File metadata
- Download URL: latex-ji18n-0.0.6.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abb77e44156aef0ffdfe2adf0f3219dd56505bdde3884006c8913208e23e9955
|
|
| MD5 |
374a533d4dbcc76737fed1f687610cae
|
|
| BLAKE2b-256 |
2dbd528a3ace9ea3ec5e1be56808335a0d2f9c65d88f9ac0e417916ac3b312a6
|
File details
Details for the file latex_ji18n-0.0.6-py3-none-any.whl.
File metadata
- Download URL: latex_ji18n-0.0.6-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f32758282804110a565df28d077accbe264932db0b4a1bcf968df87c504ebc7
|
|
| MD5 |
255a0ce4a1a42658db1024db9d722d86
|
|
| BLAKE2b-256 |
c3fdf75c3727310ee7fa71497eee4e40a064daa55963c3d211d2ee19423f5c55
|