diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-29 10:50:24 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-29 15:18:07 (GMT) |
commit | 7590288fd6419159116f4392389cb8ca9691fb06 (patch) | |
tree | d38121cbb3bb2ea41cbdc7b1b2ae97f3875f7aec /src/corelib/tools/qlocale.cpp | |
parent | 335fdd66947adadcdaaeb2896c42fba28d67843a (diff) | |
download | Qt-7590288fd6419159116f4392389cb8ca9691fb06.zip Qt-7590288fd6419159116f4392389cb8ca9691fb06.tar.gz Qt-7590288fd6419159116f4392389cb8ca9691fb06.tar.bz2 |
Added native language and country names (endonyms) to QLocale.
Task-number: QTBUG-17092
Reviewed-by: Zeno Albisser
Reviewed-by: Liang Qi
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index af95a75..197c742 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3224,4 +3224,44 @@ QStringList QLocale::uiLanguages() const return QStringList(bcp47Name()); } +/*! + \since 4.8 + + Returns a native name of the language for the locale. For example + "Schwiizertüütsch" for Swiss-German locale. + + \sa nativeCountryName(), languageToString() +*/ +QString QLocale::nativeLanguageName() const +{ +#ifndef QT_NO_SYSTEMLOCALE + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(QSystemLocale::NativeLanguageName, QVariant()); + if (!res.isNull()) + return res.toString(); + } +#endif + return getLocaleData(endonyms_data + d()->m_language_endonym_idx, d()->m_language_endonym_size); +} + +/*! + \since 4.8 + + Returns a native name of the country for the locale. For example + "España" for Spanish/Spain locale. + + \sa nativeLanguageName(), countryToString() +*/ +QString QLocale::nativeCountryName() const +{ +#ifndef QT_NO_SYSTEMLOCALE + if (d() == systemPrivate()) { + QVariant res = systemLocale()->query(QSystemLocale::NativeCountryName, QVariant()); + if (!res.isNull()) + return res.toString(); + } +#endif + return getLocaleData(endonyms_data + d()->m_country_endonym_idx, d()->m_country_endonym_size); +} + QT_END_NAMESPACE |