зеркало из https://github.com/mozilla/buddyup.git
[Bug 12094272] Set the locale of newly created accounts based on device locale.
This commit is contained in:
Родитель
afbf5cb099
Коммит
f3d596f885
|
@ -305,7 +305,8 @@
|
|||
var data = {
|
||||
username: username,
|
||||
password: password,
|
||||
email: email
|
||||
email: email,
|
||||
locale: Utils.get_supported_device_language(),
|
||||
};
|
||||
return request(endpoint, 'POST', data).then(JSON.parse);
|
||||
},
|
||||
|
|
|
@ -55,11 +55,16 @@
|
|||
});
|
||||
}
|
||||
|
||||
var _create_user_promise = null;
|
||||
/**
|
||||
* Create and store new user.
|
||||
*/
|
||||
function create_user() {
|
||||
return SumoDB.create_user().then(function(response) {
|
||||
if (_create_user_promise !== null) {
|
||||
return _create_user_promise;
|
||||
}
|
||||
|
||||
return _create_user_promise = SumoDB.create_user().then(function(response) {
|
||||
var promises = [];
|
||||
|
||||
var is_helper = false;
|
||||
|
@ -68,7 +73,17 @@
|
|||
|
||||
promises.push(sync_user(response.user));
|
||||
|
||||
return Promise.all(promises).then(function([credentials, user]) {
|
||||
// If the device is using a supported locale, set the profile of
|
||||
// the created user to use that locale.
|
||||
promises.push(User.update_user({
|
||||
user: {
|
||||
username: response.user.username,
|
||||
locale: Utils.get_supported_device_language(),
|
||||
},
|
||||
settings: {},
|
||||
}));
|
||||
|
||||
return Promise.all(promises).then(function([credentials, outdated_user, user]) {
|
||||
return user;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -248,6 +248,16 @@
|
|||
});
|
||||
|
||||
return deferred;
|
||||
},
|
||||
|
||||
get_supported_device_language() {
|
||||
var user_meta = Utils.get_user_meta();
|
||||
for (var i = 0; i < Settings.LOCALES.length; i++) {
|
||||
if (Settings.LOCALES[i][0] == user_meta.lang) {
|
||||
return user_meta.lang;
|
||||
}
|
||||
}
|
||||
return Settings.LOCALES[0][0];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче