Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7436 from fabi1cazenave/default-locale

Bug 828297 - Makefile should apply GAIA_DEFAULT_LOCALE to the `language.current' setting, r=ochameau, a=21
  • Loading branch information...
commit 31a820fb7ad7620a60aa915a1f020f8c3302e892 2 parents 002baad + f53fc73
@fabi1cazenave fabi1cazenave authored
View
2  Makefile
@@ -633,7 +633,7 @@ SETTINGS_ARG=--noftu
endif
profile/settings.json: build/settings.py build/wallpaper.jpg
- python build/settings.py $(SETTINGS_ARG) --console --homescreen $(SCHEME)homescreen.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --ftu $(SCHEME)communications.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --wallpaper build/wallpaper.jpg --override build/custom-settings.json --output $@
+ python build/settings.py $(SETTINGS_ARG) --console --locale $(GAIA_DEFAULT_LOCALE) --homescreen $(SCHEME)homescreen.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --ftu $(SCHEME)communications.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --wallpaper build/wallpaper.jpg --override build/custom-settings.json --output $@
# push profile/settings.json to the phone
install-settings-defaults: profile/settings.json
View
34 apps/communications/ftu/js/language.js
@@ -2,31 +2,33 @@
var LanguageManager = {
init: function init() {
- var panel = document.getElementById('languages');
- this.buildLanguageList(panel.querySelector('ul'));
- panel.addEventListener('change', this);
+ this.getCurrentLanguage(this.buildLanguageList.bind(this));
+ document.getElementById('languages').addEventListener('change', this);
},
handleEvent: function handleEvent(evt) {
- if (evt.target.name != 'language.current') {
+ var settings = window.navigator.mozSettings;
+ if (!settings || evt.target.name != 'language.current')
return true;
- }
+ settings.createLock().set({'language.current': evt.target.value});
+ return false;
+ },
+
+ getCurrentLanguage: function settings_getCurrent(callback) {
var settings = window.navigator.mozSettings;
- if (!settings.createLock) {
- return true;
- }
+ if (!settings || !settings.createLock || !callback)
+ return;
+
var req = settings.createLock().get('language.current');
- req.onsuccess = function() {
- settings.createLock().set({'language.current': evt.target.value});
+ req.onsuccess = function _onsuccess() {
+ callback(req.result['language.current']);
};
- req.onerror = function() {
- console.error('Error changing language');
+ req.onerror = function _onerror() {
+ console.error('Error checking language');
};
-
- return false;
},
getSupportedLanguages: function settings_getLanguages(callback) {
@@ -55,9 +57,9 @@ var LanguageManager = {
}
},
- buildLanguageList: function settings_buildLanguageList(container) {
+ buildLanguageList: function settings_buildLanguageList(uiLanguage) {
+ var container = document.querySelector('#languages ul');
container.innerHTML = '';
- var uiLanguage = document.documentElement.lang || 'en-US';
this.getSupportedLanguages(function fillLanguageList(languages) {
for (var lang in languages) {
var input = document.createElement('input');
View
5 build/settings.py
@@ -146,6 +146,7 @@ def main():
parser.add_option("-w", "--wallpaper", help="specify the name of the wallpaper file")
parser.add_option("-v", "--verbose", help="increase output verbosity", action="store_true")
parser.add_option( "--noftu", help="bypass the ftu app")
+ parser.add_option( "--locale", help="specify the default locale to use")
(options, args) = parser.parse_args(sys.argv[1:])
verbose = options.verbose
@@ -188,6 +189,10 @@ def main():
if not options.noftu:
settings["ftu.manifestURL"] = ftu_url
+ # Set the default locale
+ if options.locale:
+ settings["language.current"] = options.locale
+
# Grab wallpaper.jpg and convert it into a base64 string
wallpaper_file = open(wallpaper_filename, "rb")
wallpaper_base64 = base64.b64encode(wallpaper_file.read())
Please sign in to comment.
Something went wrong with that request. Please try again.