Make actual use of JSON format in localization (i.e. nesting)

This commit is contained in:
Jonas Herzig 2020-05-03 18:58:36 +02:00
parent ddbe10c291
commit 995d2ffb65
4 changed files with 103 additions and 73 deletions

View file

@ -31,10 +31,24 @@ var _data = {};
* @author svartoyg
*/
async function retrieveData (language) {
let json
try {
return (await import(`../loc/${language}.json`)).default
json = (await import(`../loc/${language}.json`)).default
} catch (exception) {
return (await import(`../loc/${language.substr(0, language.indexOf('-'))}.json`)).default
json = (await import(`../loc/${language.substr(0, language.indexOf('-'))}.json`)).default
}
const map = {}
flatten(json, '', map)
return map
}
function flatten (tree, prefix, result) {
for (const [key, value] of Object.entries(tree)) {
if (typeof value === 'string') {
result[prefix + key] = value
} else {
flatten(value, prefix + key + '.', result)
}
}
}

View file

@ -1,13 +1,15 @@
{
"connectdialog.title": "Verbindung herstellen",
"connectdialog.address": "Adresse",
"connectdialog.port": "Port",
"connectdialog.username": "Nutzername",
"connectdialog.password": "Passwort",
"connectdialog.tokens": "Tokens",
"connectdialog.remove": "Entfernen",
"connectdialog.add": "Hinzufügen",
"connectdialog.cancel": "Abbrechen",
"connectdialog.connect": "Verbinden"
"connectdialog": {
"title": "Verbindung herstellen",
"address": "Adresse",
"port": "Port",
"username": "Nutzername",
"password": "Passwort",
"tokens": "Tokens",
"remove": "Entfernen",
"add": "Hinzufügen",
"cancel": "Abbrechen",
"connect": "Verbinden"
}
}

View file

@ -1,45 +1,56 @@
{
"connectdialog.title": "Connect to Server",
"connectdialog.address": "Address",
"connectdialog.port": "Port",
"connectdialog.username": "Username",
"connectdialog.password": "Password",
"connectdialog.tokens": "Tokens",
"connectdialog.remove": "Remove",
"connectdialog.add": "Add",
"connectdialog.cancel": "Cancel",
"connectdialog.connect": "Connect",
"connectdialog.error.title": "Failed to connect",
"connectdialog.error.reason.refused": "The connection has been refused.",
"connectdialog.error.reason.version": "The server uses an incompatible version.",
"connectdialog.error.reason.username": "Your user name was rejected. Maybe try a different one?",
"connectdialog.error.reason.userpassword": "The given password is incorrect.\nThe user name you have chosen requires a special one.",
"connectdialog.error.reason.serverpassword": "The given password is incorrect.",
"connectdialog.error.reason.username_in_use": "The user name you have chosen is already in use.",
"connectdialog.error.reason.full": "The server is full.",
"connectdialog.error.reason.clientcert": "The server requires you to provide a client certificate which is not supported by this web application.",
"connectdialog.error.reason.server": "The server reports:",
"connectdialog.error.retry": "Retry",
"connectdialog.error.cancel": "Cancel",
"joindialog.title": "Mumble Voice Conference",
"joindialog.connect": "Join Conference",
"usercontextmenu.mute": "Mute",
"usercontextmenu.deafen": "Deafen",
"usercontextmenu.priority_speaker": "Priority Speaker",
"usercontextmenu.local_mute": "Local Mute",
"usercontextmenu.ignore_messages": "Ignore Messages",
"usercontextmenu.view_comment": "View Comment",
"usercontextmenu.change_comment": "Change Comment",
"usercontextmenu.reset_comment": "Reset Comment",
"usercontextmenu.view_avatar": "View Avatar",
"usercontextmenu.change_avatar": "Change Avatar",
"usercontextmenu.reset_avatar": "Reset Avatar",
"usercontextmenu.send_message": "Send Message",
"usercontextmenu.information": "Information",
"usercontextmenu.self_mute": "Self Mute",
"usercontextmenu.self_deafen": "Self Deafen",
"usercontextmenu.add_friend": "Add Friend",
"usercontextmenu.remove_friend": "Remove Friend",
"connectdialog": {
"title": "Connect to Server",
"address": "Address",
"port": "Port",
"username": "Username",
"password": "Password",
"tokens": "Tokens",
"remove": "Remove",
"add": "Add",
"cancel": "Cancel",
"connect": "Connect",
"error": {
"title": "Failed to connect",
"reason": {
"refused": "The connection has been refused.",
"version": "The server uses an incompatible version.",
"username": "Your user name was rejected. Maybe try a different one?",
"userpassword": "The given password is incorrect.\nThe user name you have chosen requires a special one.",
"serverpassword": "The given password is incorrect.",
"username_in_use": "The user name you have chosen is already in use.",
"full": "The server is full.",
"clientcert": "The server requires you to provide a client certificate which is not supported by this web application.",
"server": "The server reports:"
},
"retry": "Retry",
"cancel": "Cancel"
}
},
"joindialog": {
"title": "Mumble Voice Conference",
"connect": "Join Conference"
},
"usercontextmenu": {
"mute": "Mute",
"deafen": "Deafen",
"priority_speaker": "Priority Speaker",
"local_mute": "Local Mute",
"ignore_messages": "Ignore Messages",
"view_comment": "View Comment",
"change_comment": "Change Comment",
"reset_comment": "Reset Comment",
"view_avatar": "View Avatar",
"change_avatar": "Change Avatar",
"reset_avatar": "Reset Avatar",
"send_message": "Send Message",
"information": "Information",
"self_mute": "Self Mute",
"self_deafen": "Self Deafen",
"add_friend": "Add Friend",
"remove_friend": "Remove Friend"
},
"channelcontextmenu": {
"channelcontextmenu.join": "Join Channel",
"channelcontextmenu.add": "Add",
"channelcontextmenu.edit": "Edit",
@ -51,4 +62,5 @@
"channelcontextmenu.copy_mumble_web_url": "Copy Mumble-Web URL",
"channelcontextmenu.send_message": "Send Message"
}
}

View file

@ -1,13 +1,15 @@
{
"connectdialog.title": "Konektado",
"connectdialog.address": "Adreso",
"connectdialog.port": "Pordo",
"connectdialog.username": "Uzantnomo",
"connectdialog.password": "Pasvorto",
"connectdialog.tokens": "Ĵetonoj",
"connectdialog.remove": "Forigi",
"connectdialog.add": "Aldoni",
"connectdialog.cancel": "Nuligi",
"connectdialog.connect": "Konekti"
"connectdialog": {
"title": "Konektado",
"address": "Adreso",
"port": "Pordo",
"username": "Uzantnomo",
"password": "Pasvorto",
"tokens": "Ĵetonoj",
"remove": "Forigi",
"add": "Aldoni",
"cancel": "Nuligi",
"connect": "Konekti"
}
}