1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview 'cr-settings-languages-page' is the settings page
7 * for language and input method settings.
9 * @group Chrome Settings Elements
10 * @element cr-settings-languages-page
13 is: 'cr-settings-languages-page',
27 return [{code: 'en', displayName: 'English', supportsSpellcheck: true},
28 {code: 'es', displayName: 'Spanish', supportsSpellcheck: true},
29 {code: 'ru', displayName: 'Russian', supportsSpellcheck: true},
30 {code: 'ar', displayName: 'Arabic'}];
37 return [{id: 'us', name: 'US Keyboard'},
38 {id: 'fr', name: 'French Keyboard'}];
47 dummyCurrentInputMethod_: {
52 dummySpellcheckDictionaries_: {
55 return ['en', 'es', 'ru'];
62 * Whether the page is a subpage.
80 * Title for the page header and navigation menu.
85 return loadTimeData.getString('languagesPageTitle');
90 * Name of the 'iron-icon' to be shown in the settings-page-header.
100 * @param {!Array<!Language>} languages
101 * @return {!Array<!Language>} The languages from |languages| which support
105 getSpellcheckLanguages_: function(languages) {
106 return languages.filter(function(language) {
107 return language.supportsSpellcheck;
112 * @param {string} languageCode The language code identifying a language.
113 * @param {string} dummyAppLocale A fake app locale.
114 * @return {boolean} True if the given language matches the app locale pref
115 * (which may be different from the actual app locale if it was changed).
118 isUILanguage_: function(languageCode, dummyAppLocale) {
119 return languageCode == dummyAppLocale;
123 * @param {string} id The input method ID.
124 * @param {string} currentId The ID of the currently enabled input method.
125 * @return {boolean} True if the IDs match.
128 isCurrentInputMethod_: function(id, currentId) {
129 assert(cr.isChromeOS);
130 return id == currentId;
134 * @param {string} languageCode The language code identifying a language.
135 * @param {!Array<string>} spellcheckDictionaries The list of languages
136 * for which spell check is enabled.
137 * @return {boolean} True if spell check is enabled for the language.
140 isSpellcheckEnabled_: function(languageCode, spellcheckDictionaries) {
141 return spellcheckDictionaries.indexOf(languageCode) != -1;