translation#
- dibisoplot.translation.get_translator(domain: str = 'dibisoplot', language: str = 'en', locale_dir: str | None = None) Callable[[str], str]#
Initialize and return a gettext translation function for the specified domain and language. If the language is English or no translation files are found, it falls back to null translations, which are English strings. If the locale directory is not provided, it defaults to a ‘locales’ directory relative to this file.
- Parameters:
domain (str) – The gettext domain to use for translations. Defaults to ‘dibisoplot’.
language (str) – The language code for the desired translations (e.g., ‘fr’, ‘en’). Defaults to ‘en’.
locale_dir (str | None) – Path to the directory containing translation files. If None, defaults to a ‘locales’ directory relative to this file.
- Returns:
A translation function (gettext) that translates strings to the specified language. If translation files are missing or the language is English, returns a null translator.
- Return type:
Callable[[str], str]