2 * Copyright (c) 2013, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 var localeChanged = false;
12 function localePanelInit() {
13 /* Locale Settings Panel */
14 $('#page_locale').on('pageshow', function(event, data) {
18 $('[name="radio_locale"]').on('change', function(event, data) {
19 var new_locale = $('input[name=radio_locale]:checked').val();
22 if (new_locale !== tizen.locale.getLocale()) {
27 console.error('tizen.locale missing');
31 $('#button_locale_apply').on('click', function(event, data) {
33 localeChanged = false;
40 $('#button_locale_cancel').on('click', function(event, data) {
45 function localeShowOption() {
46 $('#button_locale_apply').show();
47 $('#button_locale_cancel').show();
50 function localeHideOption() {
51 $('#button_locale_apply').hide();
52 $('#button_locale_cancel').hide();
55 function localePageReload() {
56 localeChanged = false;
61 var locale = tizen.locale.getLocale();
62 var language = localeToLanguage(locale);
64 console.error('Failed to get current locale');
67 console.log('Current locale is set to ' + locale);
68 console.log('Current language is set to ' + language);
70 $('#radio_locale_' + language).prop('checked', true);
71 $('input[name=radio_locale]').checkboxradio('refresh');
73 console.log('Unknown locale ' + locale + ', default to English');
74 $('#radio_locale_english').prop('checked', true);
75 $('input[name=radio_locale]').checkboxradio('refresh');
78 console.error('tizen.locale missing');
79 $('input[name=radio_locale]').checkboxradio('disable');
83 function updateSystemLocale() {
84 var locale = $('input[name=radio_locale]:checked').val();
87 console.log('New locale is set to ' + locale);
88 tizen.locale.setLocale(locale);
91 console.error('tizen.locale missing - cannot update locale');
95 function localeToLanguage(locale) {
96 if (locale === 'C' || locale === 'en_US.UTF-8') return 'english';
97 else if (locale === 'de_DE.UTF-8') return 'german';
98 else if (locale === 'ja_JP.UTF-8') return 'japanese';
99 else if (locale === 'zh_CN.UTF-8') return 'simplified_chinese';
100 else if (locale === 'zh_HK.UTF-8' || locale === 'zh_TW.UTF-8') return 'traditional_chinese';