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

slugify(txt, /)

Turn input string into a valid lower-case slug by removing non-alphanumerics after unaccenting.

Classes

Translatable(*args, **kwargs)

Protocol for non-QObject classes that support translation using Qt translation API.

class stratified_packager.toolbelt.i18n.QgsStringUtils
static unaccent(s, /, *_a, **_k)
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:
Return type:

str

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:

str

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.