diff options
| author | winter Sparkles | 2026-08-08 23:33:27 +0100 |
|---|---|---|
| committer | winter Sparkles | 2026-08-08 23:33:27 +0100 |
| commit | 4bb659e1f7bb5850db5695a536428a9b71e3ffe5 (patch) | |
| tree | 749e41db42f9f5a08e2342e65e660ac5e59c46f7 /localisation.php | |
| parent | b422b6ded608807c7d3bb8b965b3797ca513610b (diff) | |
tidy up the localisation stuff
Diffstat (limited to 'localisation.php')
| -rw-r--r-- | localisation.php | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/localisation.php b/localisation.php index 0e193b0..a1c7bac 100644 --- a/localisation.php +++ b/localisation.php @@ -1,14 +1,15 @@ <?php -function L(string $key) { - // me when im lazy - return [ - 'login.title' => '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); } |
