Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3818)

Unified Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js

Issue 2506203002: Fix language switching (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
diff --git a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
index f8bf898a6a625996064ae6425745a58c4af174c9..cf77f90c761957742598b0b02c0c27e674572929 100644
--- a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
+++ b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js
@@ -57,7 +57,7 @@ cvox.TtsBackground = function(opt_enableMath) {
// specified.
if (this.ttsProperties['lang'] == undefined) {
this.ttsProperties['lang'] =
- chrome.i18n.getMessage('@@ui_locale').replace('_', '-');
+ chrome.i18n.getUILanguage();
dmazzoni 2016/11/17 22:49:38 Did you confirm that this is in the right format,
David Tseng 2016/11/17 23:03:02 Yes, getMessage seems to be the outlier (xx_XX) g
}
this.lastEventType = 'end';
@@ -684,20 +684,21 @@ cvox.TtsBackground.prototype.clearTimeout_ = function() {
*/
cvox.TtsBackground.prototype.updateVoice_ = function(voiceName) {
chrome.tts.getVoices(goog.bind(function(voices) {
- var currentLocale = chrome.i18n.getMessage('@@ui_locale').replace('_', '-');
-
- // TODO(dtseng): Prefer voices having the default property once we switch to
- // web speech. See crbug.com/544139.
-
- var newVoice = voices.find(
- function(v) { return v.voiceName == voiceName; }) ||
- voices.find(function(v) { return v.lang === currentLocale; }) ||
- voices.find(function(v) { return currentLocale.startsWith(v.lang); }) ||
- voices[0];
-
- if (newVoice) {
- this.currentVoice = newVoice.voiceName;
- this.startSpeakingNextItemInQueue_();
- }
+ chrome.i18n.getAcceptLanguages(goog.bind(function(acceptLanguages) {
+ var currentLocale = acceptLanguages[0] ||
dmazzoni 2016/11/17 22:49:38 Ideally we should use all acceptLanguages? Maybe a
David Tseng 2016/11/17 23:03:02 It's all kind of guess work at this point because
+ chrome.i18n.getUILanguage() || '';
+ var match = voices.find.bind(voices);
+ var newVoice =
+ match(function(v) { return v.voiceName == voiceName; }) ||
+ match(function(v) { return v.lang === currentLocale; }) ||
+ match(function(v) { return currentLocale.startsWith(v.lang); }) ||
+ match(function(v) { return v.lang.startsWith(currentLocale); }) ||
+ voices[0];
+
+ if (newVoice) {
+ this.currentVoice = newVoice.voiceName;
+ this.startSpeakingNextItemInQueue_();
+ }
+ }, this));
}, this));
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698