diff options
| author | hallgren <hallgren@chalmers.se> | 2016-06-05 12:21:56 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2016-06-05 12:21:56 +0000 |
| commit | bd8c6cc4e46ec211176bd8088318d97d6ba676bc (patch) | |
| tree | 0425460418ff727cc6309245d0c48087a6193cc2 /src/www/minibar/minibar_support.js | |
| parent | e682f0972d4e6ca4c2b7ba52125512565ed2020b (diff) | |
Minibar: detect the language for show speech synthesis buttons in more cases
This was done to obtain speech synthesis for more languages in the Numerals
grammar, which uses neither language flags nor the standard naming for
concrete syntax.
Diffstat (limited to 'src/www/minibar/minibar_support.js')
| -rw-r--r-- | src/www/minibar/minibar_support.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/www/minibar/minibar_support.js b/src/www/minibar/minibar_support.js index 1448df8a2..46da3d846 100644 --- a/src/www/minibar/minibar_support.js +++ b/src/www/minibar/minibar_support.js @@ -69,11 +69,20 @@ function supportsSVG() { function speech_buttons(to3,to2,txt) { var voices = window.speechSynthesis && window.speechSynthesis.getVoices() || [] var dvs = voices.filter(function(v){return v.default}) + function pick2dash(v) { return hasPrefix(v.lang,to2dash) } if(to2) var pick=function (v) { return v.lang==to2 } - else { + else if(to3.length==3) { var to2dash=alangcode(to3)+"-" - var pick=function(v) { return hasPrefix(v.lang,to2dash) } + var pick=pick2dash + } + else { + // Maybe the name of the concrete syntax is the name of the language + // like in Numerals.pgf + var lang=to3.substr(0,1).toUpperCase()+to3.substr(1).toLowerCase() + var codes=langcode[lang] + var to2dash=(codes ? codes.code2 : to3)+"-" + var pick=pick2dash } function btn(v) { var u=new SpeechSynthesisUtterance(txt) |
