Skip to content

Translations as a developer

trigg edited this page Jul 22, 2022 · 1 revision

Simplified

gettext

Each python module that needs translation must have the same setup steps

in imports include import gettext

directly after imports (and logging setup) prepare get text with

t = gettext.translation(
    'default', pkg_resources.resource_filename('discover_overlay', 'locales'), fallback=True)
_ = t.gettext

_("")

Inside the module any user-facing text string must be first translated using the command _. So to find the local translation for 'Overlay' the user must print(_('Overlay'))

Glade

All Button & Label widgets are automatically translated on Configuration start. An edge case is used for the Overview blurb