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>.
Loading...
Searching...
No Matches
QQmlLocale Namespace Reference

Enumerations

enum  DayOfWeek {
  Sunday = 0 , Monday = Qt::Monday , Tuesday = Qt::Tuesday , Wednesday = Qt::Wednesday ,
  Thursday = Qt::Thursday , Friday = Qt::Friday , Saturday = Qt::Saturday
}
 

Functions

Q_QML_EXPORT QV4::ReturnedValue locale (QV4::ExecutionEngine *engine, const QString &localeName)
 Provides locale specific properties and formatted data.
 
Q_QML_EXPORT void registerStringLocaleCompare (QV4::ExecutionEngine *engine)
 
Q_QML_EXPORT QV4::ReturnedValue method_localeCompare (const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
 

Enumeration Type Documentation

◆ DayOfWeek

Enumerator
Sunday 
Monday 
Tuesday 
Wednesday 
Thursday 
Friday 
Saturday 

Definition at line 66 of file qqmllocale_p.h.

Function Documentation

◆ locale()

QV4::ReturnedValue QQmlLocale::locale ( QV4::ExecutionEngine * engine,
const QString & localeName )

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:

import QtQuick 2.0
Text {
text: "The date is: " + Date().toLocaleString(Qt.locale("de_DE"))
}
Definition qcompare.h:63

The following example displays the specified number in the correct format for the default locale:

import QtQuick 2.0
Text {
text: "The value is: " + Number(23443.34).toLocaleString(Qt.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.

+ Here is the call graph for this function:

◆ method_localeCompare()

ReturnedValue QQmlLocale::method_localeCompare ( const QV4::FunctionObject * b,
const QV4::Value * thisObject,
const QV4::Value * argv,
int argc )

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerStringLocaleCompare()

void QQmlLocale::registerStringLocaleCompare ( QV4::ExecutionEngine * engine)

Definition at line 698 of file qqmllocale.cpp.

References engine, method_localeCompare(), and QStringLiteral.

Referenced by QV4::ExecutionEngine::initializeGlobal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: