Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Qt.locale() always returns the 'C' locale.
QLocale(QString()) does not return the default locale.  If no
locale is specified, use the QLocale() constructor.

Change-Id: I76198b7ea66a6326483ec47ac36e080159ca459a
Reviewed-by: Martin Jones <martin.jones@nokia.com>
  • Loading branch information
Martin Jones authored and Qt by Nokia committed Dec 20, 2011
1 parent 2ac3393 commit f0c82e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/declarative/qml/qdeclarativelocale.cpp
Expand Up @@ -811,7 +811,10 @@ v8::Handle<v8::Value> QDeclarativeLocale::locale(QV8Engine *v8engine, const QStr
QV8LocaleDataDeletable *d = localeV8Data(v8engine);
v8::Local<v8::Object> v8Value = d->constructor->NewInstance();
QV8LocaleDataResource *r = new QV8LocaleDataResource(v8engine);
r->locale = QLocale(locale);
if (locale.isEmpty())
r->locale = QLocale();
else
r->locale = QLocale(locale);
v8Value->SetExternalResource(r);

return v8Value;
Expand Down
Expand Up @@ -54,6 +54,8 @@ class tst_qdeclarativelocale : public QObject
tst_qdeclarativelocale() { }

private slots:
void defaultLocale();

void properties_data();
void properties();
void currencySymbol_data();
Expand Down Expand Up @@ -114,6 +116,16 @@ private slots:
QDeclarativeEngine engine;
};

void tst_qdeclarativelocale::defaultLocale()
{
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));

QObject *obj = c.create();
QVERIFY(obj);

QCOMPARE(obj->property("name").toString(), QLocale().name());
}

#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }

void tst_qdeclarativelocale::addPropertyData(const QString &l)
Expand Down

0 comments on commit f0c82e7

Please sign in to comment.