KI18n

Locale Data QML API

Data Types

The basic types providing locale data in the C++ API are also available in QML as Q_GADGETs and offer the same properties in QML:

Country Lookup

The static country lookup methods found in KCountry in the C++ API are available from the Country singleton in QML, as part of the org.kde.i18n.localeData module.

Listing all

For listing all known countries there is the Country.allCountries property, providing a list of KCountry objects.

import org.kde.i18n.localeData 1.0
... {
ComboBox {
model: Country.allCountries
displayText: currentValue.emojiFlag + " " + currentValue.name
}
}

Lookup by code, name or location

The following methods allow to obtain a KCountry object:

  • Country.fromAlpha2
  • Country.fromAlpha3
  • Country.fromName
  • Country.fromLocation

See the corresponding C++ API with the same name in KCountry for further details.

Country Subdivision Lookup

The static country subdivision lookup methods found in KCountrySubdivision in the C++ API are available from the CountrySubdivision singleton in QML, as part of the org.kde.i18n.localeData module.

The following methods allow to obtain a KCountrySubdivision object:

  • CountrySubdivision.fromCode
  • CountrySubdivision.fromLocation

See the corresponding C++ API with the same name in KCountrySubdivision for further details.

Timezone Lookup

The static country timezone lookup methods found in KTimeZone in the C++ API are available from the TimeZone singleton in QML, as part of the org.kde.i18n.localeData module.

The following methods are provided:

  • TimeZone.country
  • TimeZone.fromLocation

See the corresponding C++ API with the same name in KTimeZone for further details.

Further References

There's a standalone QML example showing most of the above mentioned functionality in tests/demo.qml provided as part of the KI18n source code.

This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Dec 9 2022 04:03:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.