Re-enable multi-language support on accessibility definitions.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I5d376260d05f72ebd56a8d4313dcbb1845b5041c
This commit is contained in:
Gökay Şatır 2023-08-15 12:35:53 +03:00 committed by Gökay ŞATIR
parent 34635de5d4
commit 49354607e0

View file

@ -8,25 +8,26 @@
/* eslint-disable-next-line */ /* eslint-disable-next-line */
var NotebookbarAccessibilityDefinitions = function() { var NotebookbarAccessibilityDefinitions = function() {
this.getContentListRecursive = function(rawList, list) { this.getContentListRecursive = function(rawList, list, language) {
if (Array.isArray(rawList)) { if (Array.isArray(rawList)) {
for (var i = 0; i < rawList.length; i++) { for (var i = 0; i < rawList.length; i++) {
if (rawList[i].accessibility) { if (rawList[i].accessibility) {
var combination = language && rawList[i].accessibility[language] ? rawList[i].accessibility[language]: rawList[i].accessibility.combination;
var element = document.getElementById(rawList[i].id + '-button'); var element = document.getElementById(rawList[i].id + '-button');
if (element) { if (element) {
list.push({ id: rawList[i].id + '-button', focusBack: rawList[i].accessibility.focusBack, combination: rawList[i].accessibility.combination }); list.push({ id: rawList[i].id + '-button', focusBack: rawList[i].accessibility.focusBack, combination: combination });
} }
else { else {
list.push({ id: rawList[i].id, focusBack: rawList[i].accessibility.focusBack, combination: rawList[i].accessibility.combination }); list.push({ id: rawList[i].id, focusBack: rawList[i].accessibility.focusBack, combination: combination });
} }
} }
else if (rawList[i].children && Array.isArray(rawList[i].children) && rawList[i].children.length > 0) { else if (rawList[i].children && Array.isArray(rawList[i].children) && rawList[i].children.length > 0) {
this.getContentListRecursive(rawList[i].children, list); this.getContentListRecursive(rawList[i].children, list, language);
} }
} }
} }
else if (rawList.children && Array.isArray(rawList.children) && rawList.children.length > 0) { else if (rawList.children && Array.isArray(rawList.children) && rawList.children.length > 0) {
this.getContentListRecursive(rawList.children, list); this.getContentListRecursive(rawList.children, list, language);
} }
else else
return; return;
@ -60,37 +61,27 @@ var NotebookbarAccessibilityDefinitions = function() {
} }
var defs = {}; var defs = {};
var language = this.getLanguage();
for (i = 0; i < tabs.length; i++) { for (i = 0; i < tabs.length; i++) {
if (tabs[i].accessibility && tabs[i].accessibility.focusBack) { if (tabs[i].accessibility && tabs[i].accessibility.focusBack) {
defs[tabs[i].id] = tabs[i]; defs[tabs[i].id] = tabs[i];
defs[tabs[i].id].focusBack = tabs[i].accessibility.focusBack; defs[tabs[i].id].focusBack = tabs[i].accessibility.focusBack;
defs[tabs[i].id].combination = tabs[i].accessibility.combination; defs[tabs[i].id].combination = language && tabs[i].accessibility[language] ? tabs[i].accessibility[language]: tabs[i].accessibility.combination;
defs[tabs[i].id].contentList = []; defs[tabs[i].id].contentList = [];
this.getContentListRecursive(defs[tabs[i].id].rawContentList, defs[tabs[i].id].contentList); this.getContentListRecursive(defs[tabs[i].id].rawContentList, defs[tabs[i].id].contentList, language);
delete defs[tabs[i].id].rawContentList;
} }
} }
return defs; return defs;
}; };
this.applyLanguageSpecificCombinations = function(selectedDefinitions) { this.getLanguage = function() {
if (!selectedDefinitions)
return;
// Browser language is not reflected to UI so we only check URL's language parameter.
if (app.UI.language.fromURL && app.UI.language.fromURL !== '') { if (app.UI.language.fromURL && app.UI.language.fromURL !== '') {
var lang = app.UI.language.fromURL; return app.UI.language.fromURL;
Object.keys(selectedDefinitions).forEach(function(ID) {
if (selectedDefinitions[ID][lang])
selectedDefinitions[ID].combination = selectedDefinitions[ID][lang];
for (var i = 0; i < selectedDefinitions[ID].contentList.length; i++) {
if (selectedDefinitions[ID].contentList[i][lang])
selectedDefinitions[ID].contentList[i].combination = selectedDefinitions[ID].contentList[i][lang];
}
});
} }
else
return null; // Default.
}; };
this.checkIntegratorButtons = function(selectedDefinitions) { this.checkIntegratorButtons = function(selectedDefinitions) {
@ -124,8 +115,6 @@ var NotebookbarAccessibilityDefinitions = function() {
this.getDefinitions = function() { this.getDefinitions = function() {
var selectedDefinitions = this.getTabsAndContents(); var selectedDefinitions = this.getTabsAndContents();
this.applyLanguageSpecificCombinations(selectedDefinitions);
this.checkIntegratorButtons(selectedDefinitions); this.checkIntegratorButtons(selectedDefinitions);
return selectedDefinitions; return selectedDefinitions;