From 4bb659e1f7bb5850db5695a536428a9b71e3ffe5 Mon Sep 17 00:00:00 2001 From: winter Sparkles Date: Sat, 8 Aug 2026 23:33:27 +0100 Subject: tidy up the localisation stuff --- localisation.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'localisation.php') diff --git a/localisation.php b/localisation.php index 0e193b0..a1c7bac 100644 --- a/localisation.php +++ b/localisation.php @@ -1,14 +1,15 @@ 'Log in', - 'challenge.input.username' => 'Username', - 'challenge.input.password' => 'Password', - 'challenge.input.otp' => 'One-time passcode', - 'challenge.message.wrong-password' => 'Incorrect username or password', - 'challenge.message.wrong-otp' => 'Invalid OTP code', - 'challenge.continue' => 'Continue', - ][$key] ?? $key; +// TODO: actually determine this from request header (/ user info?) +const LANGUAGE = 'en'; + +$langData = parse_ini_file(__DIR__ . '/locale/' . LANGUAGE . '.ini'); + +function L(string $key, mixed ...$values) { + global $langData; + if (!isset($langData[$key])) { + error_log("warn: translation key $key does not exist"); + return $key; + } + return sprintf($langData[$key], ...$values); } -- cgit v1.3