提供特定区域设置的特性和格式化数据 更多...
import 语句: | import QtQml 2.2 |
The Locale object may only be created via the Qt.locale() function. It cannot be created directly.
The 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 Date and 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")) }
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.
The monthName() , standaloneMonthName() , dayName() and standaloneDayName() can use the following enumeration values to specify the formatting of the string representation for a Date object.
Additionally the double-to-string and string-to-double conversion functions are covered by the following licenses:
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.
The localized name of the "AM" suffix for times specified using the conventions of the 12-hour clock.
Holds the decimal point character of this locale.
Holds the exponential character of this locale.
Holds the first day of the week according to the current locale.
注意: that these values match the JS Date API which is different from the Qt C++ API where Qt::Sunday = 7.
Holds the group separator character of this locale.
This property defines which units are used for measurement.
Holds the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.
Holds a native name of the country for the locale. For example "España" for Spanish/Spain locale.
另请参阅 nativeLanguageName .
Holds a native name of the language for the locale. For example "Schwiizertüütsch" for Swiss-German locale.
另请参阅 nativeCountryName .
Holds the negative sign character of this locale.
Holds the percent character of this locale.
The localized name of the "PM" suffix for times specified using the conventions of the 12-hour clock.
Holds the positive sign character of this locale.
Holds the text direction of the language:
Returns an ordered list of locale names for translation purposes in preference order.
The return value represents locale names that the user expects to see the UI translation in.
The first item in the list is the most preferred one.
Holds an array of days that are considered week days according to the current locale, where Sunday is 0 and Saturday is 6.
另请参阅 firstDayOfWeek .
Holds Returns the zero digit character of this locale.
Returns the currency symbol for the specified format :
另请参阅 Number::toLocaleCurrencyString() .
Returns the date format used for the current locale. type specifies the FormatType to return.
另请参阅 Date .
Returns the date time format used for the current locale. type specifies the FormatType to return.
另请参阅 Date .
Returns the localized name of the day (where 0 represents Sunday, 1 represents Monday and so on), in the optional FormatType 指定通过 type .
另请参阅 monthName() and standaloneDayName() .
返回本地化名称为 month (0-11), in the optional FormatType 指定通过 type .
注意: the QLocale C++ API expects a range of (1-12), however Locale.monthName() expects 0-11 as per the JS Date object.
另请参阅 dayName() and standaloneMonthName() .
Returns the localized name of the day (where 0 represents Sunday, 1 represents Monday and so on) that is used as a standalone text, in the FormatType 指定通过 type .
If the locale information does not specify the standalone day name then return value is the same as in dayName() .
另请参阅 dayName() and standaloneMonthName() .
返回本地化名称为 month (0-11) that is used as a standalone text, in the optional FormatType 指定通过 type .
If the locale information doesn't specify the standalone month name then return value is the same as in monthName() .
注意: the QLocale C++ API expects a range of (1-12), however Locale.standaloneMonthName() expects 0-11 as per the JS Date object.
另请参阅 monthName() and standaloneDayName() .
返回用于当前区域设置的时间格式。 type specifies the FormatType to return.
另请参阅 Date .