Pages
API Documentation
On this page

KLocalizedContext Class

This class is meant to be used to simplify integration of the KI18n framework in QML. This class is deprecated since 6.8. We strongly advise against using it in new code. More...

  • Header: #include <KLocalizedContext>
  • CMake: find_package(KF6 REQUIRED COMPONENTS I18n)
    target_link_libraries(mytarget PRIVATE KF6::I18n)
  • Inherits: QObject
  • Status: Deprecated since 6.8

List of all members, including inherited members

Properties

Public Functions

This class is deprecated since 6.8. We strongly advise against using it in new code.

Detailed Description

The way to do so, is by creating this object and setting it as a context object:

QQuickView* view = new QQuickView;
view.engine()->rootContext()->setContextObject(new KLocalizedContext(view));

Then i18n*() and xi18n*() functions should be available for use from the code loaded in the engine, for the view.

Note: Plural functions differ from the C/C++ version. On QML/JS we can get a real value easily. To solve warnings on those cases we'll cast the first argument to make sure it's taken into account for the plural.

Use KLocalizedQmlContext or KLocalization::setupLocalizedContext instead.

Property Documentation

translationDomain : QString

This property only needs to be specified if the context is being run on a library. in an application there is no need to set the translation domain as the application's domain can be used.

Access functions:

Notifier signal:

  • void translationDomainChanged(const QString &translationDomain)

Member Function Documentation

[explicit] KLocalizedContext::KLocalizedContext(QObject *parent = nullptr)

void KLocalizedContext::setTranslationDomain(const QString &domain)

Note: Setter function for property translationDomain.

See also translationDomain()

QString KLocalizedContext::translationDomain() const

Note: Getter function for property translationDomain.

See also setTranslationDomain()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.