Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
#include <qqmllocale_p.h>
Static Public Member Functions | |
static QV4::ReturnedValue | locale (QV4::ExecutionEngine *engine, const QString &localeName) |
Provides locale specific properties and formatted data. | |
static void | registerStringLocaleCompare (QV4::ExecutionEngine *engine) |
static QV4::ReturnedValue | method_localeCompare (const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc) |
Static Public Member Functions inherited from QLocale | |
static QString | languageToCode (Language language, LanguageCodeTypes codeTypes=AnyLanguageCode) |
Returns the two- or three-letter language code for language, as defined in the ISO 639 standards. | |
static Language | codeToLanguage (QStringView languageCode, LanguageCodeTypes codeTypes=AnyLanguageCode) noexcept |
Returns the QLocale::Language enum corresponding to the two- or three-letter languageCode, as defined in the ISO 639 standards. | |
static QString | territoryToCode (Territory territory) |
static Territory | codeToTerritory (QStringView territoryCode) noexcept |
static QString | scriptToCode (Script script) |
Returns the four-letter script code for script, as defined in the ISO 15924 standard. | |
static Script | codeToScript (QStringView scriptCode) noexcept |
Returns the QLocale::Script enum corresponding to the four-letter script scriptCode, as defined in the ISO 15924 standard. | |
static QString | languageToString (Language language) |
Returns a QString containing the name of language. | |
static QString | territoryToString (Territory territory) |
static QString | scriptToString (Script script) |
static void | setDefault (const QLocale &locale) |
\nonreentrant | |
static QLocale | c () |
Returns a QLocale object initialized to the "C" locale. | |
static QLocale | system () |
Returns a QLocale object initialized to the system locale. | |
static QList< QLocale > | matchingLocales (QLocale::Language language, QLocale::Script script, QLocale::Territory territory) |
Returns a list of valid locale objects that match the given language, script and territory. | |
Additional Inherited Members | |
Public Member Functions inherited from QLocale | |
QLocale () | |
Constructs a QLocale object initialized with the default locale. | |
QLocale (const QString &name) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QLocale (QStringView name) | |
\variable QLocale::DefaultTwoDigitBaseYear | |
QLocale (Language language, Territory territory) | |
Constructs a QLocale object for the specified language and territory. | |
QLocale (Language language, Script script=AnyScript, Territory territory=AnyTerritory) | |
QLocale (const QLocale &other) noexcept | |
Constructs a QLocale object as a copy of other. | |
QLocale & | operator= (const QLocale &other) noexcept |
Assigns other to this QLocale object and returns a reference to this QLocale object. | |
~QLocale () | |
Destructor. | |
void | swap (QLocale &other) noexcept |
Language | language () const |
Returns the language of this locale. | |
Script | script () const |
Territory | territory () const |
QString | name (TagSeparator separator=TagSeparator::Underscore) const |
The short name of this locale. | |
QString | bcp47Name (TagSeparator separator=TagSeparator::Dash) const |
Returns the BCP47 field names joined with dashes. | |
QString | nativeLanguageName () const |
QString | nativeTerritoryName () const |
short | toShort (const QString &s, bool *ok=nullptr) const |
Returns the short int represented by the localized string s. | |
ushort | toUShort (const QString &s, bool *ok=nullptr) const |
Returns the unsigned short int represented by the localized string s. | |
int | toInt (const QString &s, bool *ok=nullptr) const |
Returns the int represented by the localized string s. | |
uint | toUInt (const QString &s, bool *ok=nullptr) const |
Returns the unsigned int represented by the localized string s. | |
long | toLong (const QString &s, bool *ok=nullptr) const |
ulong | toULong (const QString &s, bool *ok=nullptr) const |
qlonglong | toLongLong (const QString &s, bool *ok=nullptr) const |
Returns the long long int represented by the localized string s. | |
qulonglong | toULongLong (const QString &s, bool *ok=nullptr) const |
Returns the unsigned long long int represented by the localized string s. | |
float | toFloat (const QString &s, bool *ok=nullptr) const |
Returns the float represented by the localized string s. | |
double | toDouble (const QString &s, bool *ok=nullptr) const |
Returns the double represented by the localized string s. | |
short | toShort (QStringView s, bool *ok=nullptr) const |
Returns the short int represented by the localized string s. | |
ushort | toUShort (QStringView s, bool *ok=nullptr) const |
Returns the unsigned short int represented by the localized string s. | |
int | toInt (QStringView s, bool *ok=nullptr) const |
Returns the int represented by the localized string s. | |
uint | toUInt (QStringView s, bool *ok=nullptr) const |
Returns the unsigned int represented by the localized string s. | |
long | toLong (QStringView s, bool *ok=nullptr) const |
ulong | toULong (QStringView s, bool *ok=nullptr) const |
qlonglong | toLongLong (QStringView s, bool *ok=nullptr) const |
Returns the long long int represented by the localized string s. | |
qulonglong | toULongLong (QStringView s, bool *ok=nullptr) const |
Returns the unsigned long long int represented by the localized string s. | |
float | toFloat (QStringView s, bool *ok=nullptr) const |
Returns the float represented by the localized string s. | |
double | toDouble (QStringView s, bool *ok=nullptr) const |
Returns the double represented by the localized string s. | |
QString | toString (qlonglong i) const |
Returns a localized string representation of i. | |
QString | toString (qulonglong i) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QString | toString (long i) const |
QString | toString (ulong i) const |
QString | toString (short i) const |
QString | toString (ushort i) const |
QString | toString (int i) const |
QString | toString (uint i) const |
QString | toString (double f, char format='g', int precision=6) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns a string representing the floating-point number f. | |
QString | toString (float f, char format='g', int precision=6) const |
QString | toString (QDate date, const QString &format) const |
Returns a localized string representation of the given date in the specified format. | |
QString | toString (QTime time, const QString &format) const |
Returns a localized string representation of the given time according to the specified format. | |
QString | toString (const QDateTime &dateTime, const QString &format) const |
QString | toString (QDate date, QStringView format) const |
QString | toString (QTime time, QStringView format) const |
QString | toString (const QDateTime &dateTime, QStringView format) const |
QString | toString (QDate date, FormatType format=LongFormat) const |
QString | toString (QTime time, FormatType format=LongFormat) const |
Returns a localized string representation of the given time in the specified format (see timeFormat()). | |
QString | toString (const QDateTime &dateTime, FormatType format=LongFormat) const |
QString | toString (QDate date, QStringView format, QCalendar cal) const |
QString | toString (QDate date, FormatType format, QCalendar cal) const |
QString | toString (const QDateTime &dateTime, FormatType format, QCalendar cal) const |
QString | toString (const QDateTime &dateTime, QStringView format, QCalendar cal) const |
QString | dateFormat (FormatType format=LongFormat) const |
QString | timeFormat (FormatType format=LongFormat) const |
QString | dateTimeFormat (FormatType format=LongFormat) const |
QString | decimalPoint () const |
QString | groupSeparator () const |
QString | percent () const |
QString | zeroDigit () const |
QString | negativeSign () const |
QString | positiveSign () const |
QString | exponential () const |
QString | monthName (int, FormatType format=LongFormat) const |
QString | standaloneMonthName (int, FormatType format=LongFormat) const |
QString | dayName (int, FormatType format=LongFormat) const |
QString | standaloneDayName (int, FormatType format=LongFormat) const |
Qt::DayOfWeek | firstDayOfWeek () const |
QList< Qt::DayOfWeek > | weekdays () const |
QString | amText () const |
QString | pmText () const |
MeasurementSystem | measurementSystem () const |
QLocale | collation () const |
Qt::LayoutDirection | textDirection () const |
QString | toUpper (const QString &str) const |
QString | toLower (const QString &str) const |
QString | currencySymbol (CurrencySymbolFormat=CurrencySymbol) const |
QString | toCurrencyString (qlonglong, const QString &symbol=QString()) const |
QString | toCurrencyString (qulonglong, const QString &symbol=QString()) const |
QString | toCurrencyString (short i, const QString &symbol=QString()) const |
QString | toCurrencyString (ushort i, const QString &symbol=QString()) const |
QString | toCurrencyString (int i, const QString &symbol=QString()) const |
QString | toCurrencyString (uint i, const QString &symbol=QString()) const |
QString | toCurrencyString (double, const QString &symbol=QString(), int precision=-1) const |
QString | toCurrencyString (float i, const QString &symbol=QString(), int precision=-1) const |
QString | formattedDataSize (qint64 bytes, int precision=2, DataSizeFormats format=DataSizeIecFormat) const |
QStringList | uiLanguages (TagSeparator separator=TagSeparator::Dash) const |
List of locale names for use in selecting translations. | |
void | setNumberOptions (NumberOptions options) |
NumberOptions | numberOptions () const |
QString | quoteString (const QString &str, QuotationStyle style=StandardQuotation) const |
QString | quoteString (QStringView str, QuotationStyle style=StandardQuotation) const |
QString | createSeparatedList (const QStringList &strl) const |
Static Public Attributes inherited from QLocale | |
static constexpr int | DefaultTwoDigitBaseYear = 1900 |
Related Symbols inherited from QLocale | |
size_t | qHash (const QLocale &key, size_t seed) noexcept |
Definition at line 60 of file qqmllocale_p.h.
Enumerator | |
---|---|
Sunday | |
Monday | |
Tuesday | |
Wednesday | |
Thursday | |
Friday | |
Saturday |
Definition at line 67 of file qqmllocale_p.h.
|
static |
Provides locale specific properties and formatted data.
\qmltype Locale
! \instantiates QQmlLocale \inqmlmodule QtQml
The Locale object may only be created via the \l{QtQml::Qt::locale()}{Qt.locale()} function. It cannot be created directly.
The \l{QtQml::Qt::locale()}{Qt.locale()} function returns a JS Locale object representing the locale with the specified name, which has the format "language[_territory][.codeset][@modifier]" or "C".
Locale supports the concept of a default locale, which is determined from the system's locale settings at application startup. If no parameter is passed to Qt.locale() the default locale object is returned.
The Locale object provides a number of functions and properties providing data for the specified locale.
The Locale object may also be passed to the \l Date and \l Number toLocaleString() and fromLocaleString() methods in order to convert to/from strings using the specified locale.
This example shows the current date formatted for the German locale:
The following example displays the specified number in the correct format for the default locale:
Qt Quick Locale's data is based on Common Locale Data Repository v1.8.1.
\target FormatType \section2 Locale String Format Types The monthName(), standaloneMonthName(), dayName() and standaloneDayName() can use the following enumeration values to specify the formatting of the string representation for a Date object. \value Locale.LongFormat The long version of day and month names; for example, returning "January" as a month name. \value Locale.ShortFormat The short version of day and month names; for example, returning "Jan" as a month name. \value Locale.NarrowFormat A special version of day and month names for use when space is limited; for example, returning "J" as a month name. Note that the narrow format might contain the same text for different months and days or it can even be an empty string if the locale doesn't support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat. Additionally the double-to-string and string-to-double conversion functions are covered by the following licenses: \legalese Copyright (c) 1991 by AT&T. Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software. THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. This product includes software developed by the University of California, Berkeley and its contributors. \sa Date, Number
Definition at line 684 of file qqmllocale.cpp.
References QV4::QQmlValueTypeWrapper::create(), and engine.
|
static |
Definition at line 703 of file qqmllocale.cpp.
References QV4::Value::as(), QV4::Value::isString(), QString::localeAwareCompare(), QV4::StringPrototype::method_localeCompare(), and QV4::Value::toQStringNoThrow().
Referenced by registerStringLocaleCompare().
|
static |
Definition at line 698 of file qqmllocale.cpp.
References engine, method_localeCompare(), and QStringLiteral.
Referenced by QV4::ExecutionEngine::initializeGlobal().