Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bin/i18n/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

### Strings and localization

New text should not be hardcoded into the python, but added to tabcmd/locales/en/extra.properties. This file can be given to the translation team and they will return a copy for each other language. Until then, the english string will be used as a fallback.

To handle localizing text we used the python standard library tool [gettext](https://docs.python.org/3/library/gettext.html). This expects .mo files. I couldn't find a tool that transformed .properties -> .mo directly so we go through .po format.
(FYI: to read mo files for debugging use https://poedit.net/download)


These steps are separated for easier troubleshooting: each step is idempotent and will overwrite the existing output. More details about implementation are in the script code at dodo.py

1. convert strings from .properties files to .mo for bundling
This step combines the .properties files into a single file, discarding any strings that are not present in code and normalizing curly quotes and unrecognized characters in the strings it keeps. (These files are separate because they are pulled from separate translation sources internally.)
> python -m doit properties

2. Convert the combined .properties file into a .po file (these are human readable)
> python -m doit po

3. Convert the .po files into .mo files (these are not human readable)
This also checks the .mo files for validity by loading them with gettext
> python -m doit mo
25 changes: 25 additions & 0 deletions bin/i18n/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
i18n utilities for tabcmd localization.

This package contains tools for checking and processing localization strings.
"""

from .check_strings import (
find_python_files,
extract_string_keys_from_file,
load_properties_files,
load_properties_file,
find_missing_strings,
check_build_mode,
check_dev_mode
)

__all__ = [
'find_python_files',
'extract_string_keys_from_file',
'load_properties_files',
'load_properties_file',
'find_missing_strings',
'check_build_mode',
'check_dev_mode'
]
Loading
Loading