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)); |
}; |