KLocalization
Functions | |
template<typename T > | |
void | retranslateSpinBoxFormatString (T *spinBox) |
KLocalizedQmlContext * | setupLocalizedContext (QQmlEngine *engine) |
template<typename T > | |
void | setupSpinBoxFormatString (T *spinBox, const KLocalizedString &formatString) |
Detailed Description
Namespace containing helpers for localization.
- Since
- 6.5
Function Documentation
◆ retranslateSpinBoxFormatString()
|
inline |
Retranslates a previously set up format string to the current language and updates the spin box.
The format string is initially set up by setupSpinBoxFormatString(). This function updates the prefix and suffix of a spin box to reflect the current language settings. It is useful for responding to language changes, such as those triggered by QEvent::LanguageChange.
- Template Parameters
-
T The type of the spin box, which must be either QSpinBox or QDoubleSpinBox.
- Parameters
-
spinBox Pointer to the spin box.
- Postcondition
- The prefix and suffix of the spin box are updated to reflect the current language.
- See also
- setupSpinBoxFormatString
- Since
- 6.5
Definition at line 59 of file klocalization.h.
◆ setupLocalizedContext()
|
inline |
Creates a KLocalizedQmlContext engine and sets it up in the root context of engine
.
If TRANSLATION_DOMAIN
is defined, that is also set on the created context.
- Since
- 6.8
Definition at line 316 of file klocalizedqmlcontext.h.
◆ setupSpinBoxFormatString()
|
inline |
Sets up a format string for internationalizing spin boxes.
This function allows the customization of prefix and suffix for spin boxes (QSpinBox and QDoubleSpinBox), considering internationalization needs.
Spin boxes display a number and possibly a prefix and/or suffix. However, in some languages, the position of the prefix and suffix may be reversed compared to English. Example: In English, you write 50%, but in Turkish, you write %50. Qt does not offer an out-of-the-box solution for this. This helper now provides complete internationalization for prefixes and suffixes of spin boxes.
For QSpinBox it also provides correct plural handling by installing a handler for the valueChanged() signal to update prefix and suffix whenever the spin box value changes in the future.
Example usage:
- Template Parameters
-
T The type of the spin box, which must be either QSpinBox or QDoubleSpinBox.
- Parameters
-
spinBox Pointer to the spin box. formatString A localized string in the format "PREFIX%vSUFFIX". - For QDoubleSpinBox, plural forms in
formatString
are ignored and should be avoided. Use ki18nc() to generate the format string. - For QSpinBox, if
formatString
includes plural forms, they are utilized. While optional, their use is highly recommended for accurate pluralization. Use ki18ncp() to generate the format string.
- For QDoubleSpinBox, plural forms in
- Note
- It is safe to call this function multiple times on the same spin box.
- See also
- retranslateSpinBoxFormatString
- Since
- 6.5
Definition at line 139 of file klocalization.h.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:34 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.