Add a function to mark translated strings as dirty

This commit is contained in:
Olivier Goffart 2024-04-18 14:27:48 +02:00
parent 2c012aa2d9
commit 808b1ef946
13 changed files with 112 additions and 14 deletions

View file

@ -1258,6 +1258,27 @@ inline SharedString translate(const SharedString &original, const SharedString &
} // namespace private_api
#ifdef SLINT_FEATURE_GETTEXT
/// Forces all the strings that are translated with `@tr(...)` to be re-evaluated.
/// This is useful if the language is changed at runtime.
/// The function is only available when Slint is compiled with `SLINT_FEATURE_GETTEXT`.
///
/// Example
/// ```cpp
/// my_ui->global<LanguageSettings>().on_french_selected([] {
/// // trick from https://www.gnu.org/software/gettext/manual/html_node/gettext-grok.html
/// setenv("LANGUAGE", langs[l], true);
/// extern int _nl_msg_cat_cntr;
/// ++_nl_msg_cat_cntr;
/// slint::update_all_translations();
/// });
/// ```
inline void update_all_translations()
{
cbindgen_private::slint_translations_mark_dirty();
}
#endif
#if !defined(DOXYGEN)
cbindgen_private::Flickable::Flickable()
{