Skip to content

Commit

Permalink
docs(README): add instructions to translate the theme
Browse files Browse the repository at this point in the history
  • Loading branch information
tillywoodfield committed Nov 12, 2024
1 parent 823d8d7 commit f359c55
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MESSAGE_CATALOG_NAME = sphinx

.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " extract to extract translatable strings into POT files"
@echo " init to initialise a PO file for a new language"
@echo " update to update existing PO files"
@echo " compile to compile updated PO files"

.PHONY: extract
extract:
pybabel extract -o iati_sphinx_theme/locale/$(MESSAGE_CATALOG_NAME).pot -F babel.cfg iati_sphinx_theme

.PHONY: init
init:
pybabel init -i iati_sphinx_theme/locale/$(MESSAGE_CATALOG_NAME).pot -d iati_sphinx_theme/locale --domain=$(MESSAGE_CATALOG_NAME) -l ${lang}

.PHONY: update
update:
pybabel update -i iati_sphinx_theme/locale/$(MESSAGE_CATALOG_NAME).pot -d iati_sphinx_theme/locale --domain=${MESSAGE_CATALOG_NAME}

.PHONE: compile
compile:
pybabel compile --directory=iati_sphinx_theme/locale --domain=${MESSAGE_CATALOG_NAME}
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,37 @@ To run a local version of the theme with another project, e.g. `my-docs`, take t
pip install sphinx-autobuild
sphinx-autobuild docs docs/_build/html
```

### Translation

Follow the steps below to translate the theme's built-in strings from the HTML templates in the `iati_sphinx_theme` directory.
The message catalog name is `sphinx.[pot|po|mo]` and is found in the `iati_sphinx_theme/locale` directory.
These are bundled with the published theme in order for consumers to have access to the translations.

A `Makefile` exists to make running the commands easier:

1. Extract text into `.pot` files

```
make extract
```

2. Update existing `.po` files based on `.pot` files

```
make update
```

3. Optionally, initialise a `.po` file for a new language

```
make init lang=es
```

4. Add translations to the `.po` files

5. Compile to `.mo` files (only applies to the theme's built-in strings, so that they can be bundled with the theme)

```
make compile
```

0 comments on commit f359c55

Please sign in to comment.