Skip to content

Internationalization

All strategies accept a babel.support.Translations object as the tr argument in plot() and build(). The same object is accepted by FigureView (web layer) to translate the dynamically generated WTForms form labels.

Translated surface

Layer Translated strings
Strategy (plot / build) Month and day-of-week labels on time-based axes
Web form (FigureView, form_factory) Variable names, option names, aggregation function labels, enum option labels, fixed form labels (Title, Subtitle, …), StringOption default values
Demo templates All static UI text (accordion headings, buttons, placeholders, empty-state messages)

No translations (English)

When internationalization is not needed, pass NullTranslations (returns strings as-is):

from babel.support import NullTranslations

view = strategy.plot(dfs={"main": df}, tr=NullTranslations(), theme=theme)

Load translations from .mo files

from babel.support import Translations

tr = Translations.load("locale", locales=["es"])
view = strategy.plot(dfs={"main": df}, tr=tr, theme=theme)

Dict-based translations

For cases where .po/.mo tooling is not available (e.g. demos or tests):

from babel.support import Translations

class DictTranslations(Translations):
    def __init__(self, catalog: dict[str, str]) -> None:
        super().__init__()
        self._catalog = catalog

    def gettext(self, message: str) -> str:
        return self._catalog.get(message, message)

tr = DictTranslations({"January": "Enero", "February": "Febrero", ...})

Demo application

The demo application ships a complete Spanish catalog in demo/translations.py and selects the active locale via the ORAMA_LOCALE environment variable (default "en"):

ORAMA_LOCALE=es flask --app demo.app run