stratified_packager.toolbelt.i18n
Internationalization helpers: Qt translation support and accent-folding slug creation.
Provides Translatable, a Protocol giving non-QObject classes a
tr classmethod backed by translate(), and
slugify(), which folds accents via qgis.core.QgsStringUtils.unaccent() before reducing
a string to a lower-case identifier slug.
Functions
|
Turn input string into a valid lower-case slug by removing non-alphanumerics after unaccenting. |
Classes
|
Protocol for non-QObject classes that support translation using Qt translation API. |
- class stratified_packager.toolbelt.i18n.Translatable(*args, **kwargs)[source]
Protocol for non-QObject classes that support translation using Qt translation API.
- classmethod tr(sourceText, disambiguation=None, n=-1)[source]
Get the translation for a string using Qt translation API.
- Parameters:
sourceText (
str) – String for translation.disambiguation (
str|None) – Identifying string for when the same text is used in different roles within the context.n (
int) – Number to support plural forms. https://doc.qt.io/qt-6/i18n-source-translation.html#handle-plural-forms
- Return type:
- Returns:
Translated version of the source text.
- __init__(*args, **kwargs)
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- stratified_packager.toolbelt.i18n.slugify(txt, /)[source]
Turn input string into a valid lower-case slug by removing non-alphanumerics after unaccenting.
- Parameters:
txt (
str) – Original string.- Return type:
- Returns:
A slug created by calling
qgis.core.QgsStringUtils.unaccent()on the original string (QGIS 4.0+ only), replacing runs of remaining non-alphanumeric characters by_and lower-casing the result. If the original string starts with a numeric digit, a_is inserted at the beginning.