aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-02-17 10:11:43 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-17 04:29:42 +0100
commitceb09a144afae488057c1841ec68a2fa0117a3f3 (patch)
tree12b5ead7b2033fa3c836696e2064dae3ee62cc24 /src/declarative
parent297cdf59dec32635cc162b472fb63bc86dbe121c (diff)
Make QLocale::uiLanguages() available in Qt.locale() object
Available as uiLanguages property returning an array of strings. Change-Id: Ic698bbaff2eb0f9f6720ae06952c12a987298964 Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativelocale.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativelocale.cpp b/src/declarative/qml/qdeclarativelocale.cpp
index fc6017ce5a..8ec51b058c 100644
--- a/src/declarative/qml/qdeclarativelocale.cpp
+++ b/src/declarative/qml/qdeclarativelocale.cpp
@@ -556,6 +556,19 @@ static v8::Handle<v8::Value> locale_get_weekDays(v8::Local<v8::String>, const v8
return result;
}
+static v8::Handle<v8::Value> locale_get_uiLanguages(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ GET_LOCALE_DATA_RESOURCE(info.This());
+
+ QStringList langs = r->locale.uiLanguages();
+ v8::Handle<v8::Array> result = v8::Array::New(langs.size());
+ for (int i = 0; i < langs.size(); ++i) {
+ result->Set(i, r->engine->toString(langs.at(i)));
+ }
+
+ return result;
+}
+
static v8::Handle<v8::Value> locale_currencySymbol(const v8::Arguments &args)
{
GET_LOCALE_DATA_RESOURCE(args.This());
@@ -717,6 +730,7 @@ QV8LocaleDataDeletable::QV8LocaleDataDeletable(QV8Engine *engine)
ft->PrototypeTemplate()->SetAccessor(v8::String::New("weekDays"), locale_get_weekDays);
ft->PrototypeTemplate()->SetAccessor(v8::String::New("measurementSystem"), locale_get_measurementSystem);
ft->PrototypeTemplate()->SetAccessor(v8::String::New("textDirection"), locale_get_textDirection);
+ ft->PrototypeTemplate()->SetAccessor(v8::String::New("uiLanguages"), locale_get_uiLanguages);
constructor = qPersistentNew(ft->GetFunction());
}
@@ -998,6 +1012,17 @@ v8::Handle<v8::Value> QDeclarativeLocale::locale(QV8Engine *v8engine, const QStr
\sa firstDayOfWeek
*/
+/*!
+ \qmlproperty Array<string> QtQuick2::Locale::uiLanguages
+
+ 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.
+*/
/*!
\qmlproperty enumeration QtQuick2::Locale::textDirection