diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-10-18 14:36:57 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-10-18 14:44:34 +0200 |
commit | efa766aa8b93c484148a497f628512c4ec096f0f (patch) | |
tree | 14f9f29aec83f49e403b7b171c8c0958076d5cb2 /src/i18n.php |
initial commit
Diffstat (limited to 'src/i18n.php')
-rw-r--r-- | src/i18n.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/i18n.php b/src/i18n.php new file mode 100644 index 0000000..a458002 --- /dev/null +++ b/src/i18n.php @@ -0,0 +1,29 @@ +<?php + +function i18n($i18n) +{ + return [ + 'translate' => function ($id) use ($i18n) { + return $i18n[$_GET['lang'] ?? 'de'][$id] ?? $i18n['de'][$id]; + }, + + 'link_page' => function ($page) { + $locale = $_GET['lang'] ?? 'de'; + $page = trim($page, '/'); + $link = "/$locale/$page"; + + return $link; + }, + + 'link_language' => function ($locale) { + $page = trim($_GET['page'], '/'); + $link = "/$locale/$page"; + + return $link; + }, + + 'inactive_languages' => function () { + return array_values(array_diff(['de', 'en', 'jp'], [$_GET['lang'] ?? 'de'])); + }, + ]; +} |