Getting Started
Installation#
Install from PyPI:
For YAML support, install the extra dependency:
Or install from source:
First Steps#
Create a directory for your localization files.
Tip
doti18n supports YAML, JSON, XML, and TOML out of the box. You can add other formats via Custom Loaders.
Directory Structure:
Create Files#
Note
The root element is ignored in XML files. See Supported Formats for details.
locales/en.xml:
locales/fr.xml: Usage#
Load and access translations using dot-notation:
from doti18n import LocaleData
i18n = LocaleData("locales")
print(i18n["en"].hello) # Output: Hello World!
print(i18n["fr"].hello) # Output: Bonjour le monde!
That's it! Check the Usage section for advanced features like pluralization, formatting, and strict mode.