From 0f69e739a8d009c2b54e49b3fdb2dc0d6ca123b8 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 4 Nov 2024 22:06:07 +0100 Subject: [PATCH] partially fix format --- abrechenbarkeit.lua | 10 ++++++---- locale/de.ini | 1 + locale/en.ini | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index d29cf20..190bea7 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -91,10 +91,12 @@ local stylesheet = io.open("style.css"):read("a") local script = io.open("script.js"):read("a") local function format(template, params) - return string.gsub(template, "{([%w\\.!]+)}", function(n) - local raw = n:sub(1,1) ~= "!" - if raw then n = n:sub(2) end - local s = format(params[n] or translations[n] or "NIL TEMPLATE", params) + params = params or {} + if template == nil then return "NIL TEMPLATE" end + return string.gsub(template, "{([%w_\\.!]+)}", function(n) + local raw = n:sub(1, 1) ~= "!" + if not raw then n = n:sub(2) end + local s = format(params[n] or translations[n] or "NIL PARAM", params) return raw and s or escape(s) end) end diff --git a/locale/de.ini b/locale/de.ini index c549161..babbbd9 100644 --- a/locale/de.ini +++ b/locale/de.ini @@ -1,3 +1,4 @@ +[abrechenbarkeit] appname=Abrechenbarkeit about=Über field.amount=Menge diff --git a/locale/en.ini b/locale/en.ini index 1deac2a..5eecfaf 100644 --- a/locale/en.ini +++ b/locale/en.ini @@ -1,3 +1,4 @@ +[abrechenbarkeit] appname=Abrechenbarkeit about=About field.amount=Amount