Formats and writing direction
Numbers, currency and dates in the rules of the active language, and interfaces that mirror from right to left.
janelkit-i18n Translation catalogs, plurals, locale-aware number, currency and date formats, and language switching at run time. pip install janelkit-i18nFormat with the rules of the language
The formatting helpers follow the active language through Qt’s QLocale, and they are reactive in templates like t. number(x, decimals) groups thousands and uses the right decimal mark, currency(x, symbol) places the symbol where the language expects it, and date(value, "short" | "long") writes a date or a datetime.
<!-- Partial template; the script imports i18n and t from janelkit_i18n,
and defines total, price and today. -->
<text>{i18n.number(total, 2)} · {i18n.currency(price, "€")} · {i18n.date(today, "long")}</text>CopyFragment · Add it to an existing component; it is not a complete file.
Right-to-left languages
When the active language is written from right to left, such as Arabic, Hebrew or Persian, the whole interface mirrors: rows, text alignment and the indicators of the controls. You do not write anything for it. i18n.rtl, the same as janelkit.locale.rtl, tells you whether the active language is one of them, for the rare case where your own drawing must change.
<!-- Partial template: a button that switches to Arabic. -->
<button on:click={i18n.set("ar")}>العربية</button>CopyFragment · Add it to an existing component; it is not a complete file.
Learn morePython API reference ↗
A complete example
apps/examples/idiomas, in the JanelKit repository, switches between Spanish, English and Arabic while running, with plurals, formats and a mirrored layout.
English documentation based on the JanelKit source. For additional details, browse the source docs ↗.