key language info by locale id, and add chinese

This commit is contained in:
Eric Rosenbaum 2019-01-30 17:00:42 -05:00
parent cd85e8ddfa
commit 0d12cead31

View file

@ -152,20 +152,56 @@ class Scratch3Text2SpeechBlocks {
*/ */
get LANGUAGE_INFO () { get LANGUAGE_INFO () {
return { return {
'Danish': 'da', 'da': {
'Dutch': 'nl', name: 'Danish'
'English': 'en', },
'French': 'fr', 'nl': {
'German': 'de', name: 'Dutch'
'Icelandic': 'is', },
'Italian': 'it', 'en': {
'Japanese': 'ja', name: 'English'
'Polish': 'pl', },
'Portuguese (Brazilian)': 'pt-br', 'fr': {
'Portuguese (European)': 'pt', name: 'French'
'Russian': 'ru', },
'Spanish (European)': 'es', 'de': {
'Spanish (Latin American)': 'es-419' name: 'German'
},
'is': {
name: 'Icelandic'
},
'it': {
name: 'Italian'
},
'ja': {
name: 'Japanese'
},
'pl': {
name: 'Polish'
},
'pt-br': {
name: 'Portuguese (Brazilian)'
},
'pt': {
name: 'Portuguese (European)'
},
'ru': {
name: 'Russian'
},
'es': {
name: 'Spanish (European)'
},
'es-419': {
name: 'Spanish (Latin American)'
},
'zh-cn': {
name: 'Chinese (Simplified)',
singleGender: true
},
'zh-tw': {
name: 'Chinese (Traditional)',
singleGender: true
}
}; };
} }
@ -190,7 +226,9 @@ class Scratch3Text2SpeechBlocks {
'pt': 'pt-PT', // Portuguese (European) 'pt': 'pt-PT', // Portuguese (European)
'ru': 'ru-RU', // Russian 'ru': 'ru-RU', // Russian
'es': 'es-ES', // Spanish (European) 'es': 'es-ES', // Spanish (European)
'es-419': 'es-US' // Spanish (Latin American) 'es-419': 'es-US', // Spanish (Latin American)
'zh-cn': 'cmn-CN', // Chinese (simplified) -> Mandarin
'zh-tw': 'cmn-CN' // Chinese (traditional) -> Mandarin
}; };
let converted = 'en-US'; let converted = 'en-US';
if (pollyLocales[locale]) { if (pollyLocales[locale]) {
@ -382,7 +420,7 @@ class Scratch3Text2SpeechBlocks {
* @returns {boolean} true if the language code is supported. * @returns {boolean} true if the language code is supported.
*/ */
isSupportedLanguage (languageCode) { isSupportedLanguage (languageCode) {
return Object.values(this.LANGUAGE_INFO).includes(languageCode); return Object.keys(this.LANGUAGE_INFO).includes(languageCode);
} }
/** /**
@ -401,9 +439,9 @@ class Scratch3Text2SpeechBlocks {
* @return {array} the text and value for each menu item. * @return {array} the text and value for each menu item.
*/ */
getLanguageMenu () { getLanguageMenu () {
return Object.keys(this.LANGUAGE_INFO).map(languageName => ({ return Object.keys(this.LANGUAGE_INFO).map(key => ({
text: languageName, text: this.LANGUAGE_INFO[key].name,
value: this.LANGUAGE_INFO[languageName] value: key
})); }));
} }