aboutsummaryrefslogtreecommitdiff
path: root/localisation.php
diff options
context:
space:
mode:
Diffstat (limited to 'localisation.php')
-rw-r--r--localisation.php23
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);
}