diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-13 16:30:31 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-13 16:30:31 -0400 |
commit | 4f8c84d524365a32e6f4478597905bc553ad20c2 (patch) | |
tree | 45455da961f4bc7634074d1ded9eae5280009350 /ext/bg | |
parent | f8e666b70c9d114f3469c7c21d41474faac00c13 (diff) |
Fix Japanese voice ordering on Firefox for Android
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/settings.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index debf9f2f..acc47f69 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -358,24 +358,28 @@ function updateTextToSpeechVoices() { select.val(select.attr('data-value')); } -function compareLanguageTags(a, b) { - if (a.substr(0, 3) === 'ja-') { - return (b.substr(0, 3) === 'ja-') ? 0 : -1; - } else { - return (b.substr(0, 3) === 'ja-') ? 1 : 0; - } +function languageTagIsJapanese(languageTag) { + return ( + languageTag.startsWith('ja-') || + languageTag.startsWith('jpn-') + ); } function textToSpeechVoiceCompare(a, b) { - const i = compareLanguageTags(a.voice.lang, b.voice.lang); - if (i !== 0) { return i; } + const aIsJapanese = languageTagIsJapanese(a.voice.lang); + const bIsJapanese = languageTagIsJapanese(b.voice.lang); + if (aIsJapanese) { + if (!bIsJapanese) { return -1; } + } else { + if (bIsJapanese) { return 1; } + } - if (a.voice.default) { - if (!b.voice.default) { - return -1; - } - } else if (b.voice.default) { - return 1; + const aIsDefault = a.voice.default; + const bIsDefault = b.voice.default; + if (aIsDefault) { + if (!bIsDefault) { return -1; } + } else { + if (bIsDefault) { return 1; } } if (a.index < b.index) { return -1; } |