mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
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.
This commit is contained in:
@@ -29,10 +29,12 @@ var languages =
|
||||
}()
|
||||
|
||||
var langname={}
|
||||
var langcode={}
|
||||
var langcode2={}
|
||||
var langcode3={}
|
||||
for(var i in languages) {
|
||||
langname[languages[i].code]=languages[i].name
|
||||
langcode[languages[i].name]=languages[i]
|
||||
langcode2[languages[i].code]=languages[i].code2
|
||||
langcode3[languages[i].code2]=languages[i].code
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user