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 * @author svartoyg
*/ */
async function retrieveData (language) { async function retrieveData (language) {
let json
try { try {
return (await import(`../loc/${language}.json`)).default json = (await import(`../loc/${language}.json`)).default
} catch (exception) { } 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": {
"connectdialog.address": "Adresse", "title": "Verbindung herstellen",
"connectdialog.port": "Port", "address": "Adresse",
"connectdialog.username": "Nutzername", "port": "Port",
"connectdialog.password": "Passwort", "username": "Nutzername",
"connectdialog.tokens": "Tokens", "password": "Passwort",
"connectdialog.remove": "Entfernen", "tokens": "Tokens",
"connectdialog.add": "Hinzufügen", "remove": "Entfernen",
"connectdialog.cancel": "Abbrechen", "add": "Hinzufügen",
"connectdialog.connect": "Verbinden" "cancel": "Abbrechen",
"connect": "Verbinden"
}
} }

View file

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

View file

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