From acc7409bfe1d072f44c1c50937a422a7624457db Mon Sep 17 00:00:00 2001 From: Miraty Date: Mon, 30 May 2022 20:51:16 +0200 Subject: [PATCH] Fix bug when all requested locales are unavailable + automatically list locales --- index.php | 6 +++--- locales/template.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 5889201..4d11325 100755 --- a/index.php +++ b/index.php @@ -13,19 +13,19 @@ require "vendor/autoload.php"; define("LIBREQR_VERSION", "2.0.0dev"); // Defines the locale to be used +$locale = DEFAULT_LOCALE; if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $clientLocales = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $clientLocales = preg_replace("#[A-Z0-9]|q=|;|-|\.#", "", $clientLocales); $clientLocales = explode(',', $clientLocales); - $availableLocales = array('en', 'fr', 'oc', 'template'); + foreach (array_diff(scandir("locales"), array('..', '.')) as $key => $localeFile) + $availableLocales[$key] = basename($localeFile, ".php"); foreach ($clientLocales as $clientLocale) { if (in_array($clientLocale, $availableLocales)) { $locale = $clientLocale; break; } } -} else { - $locale = DEFAULT_LOCALE; } require "locales/" . $locale . ".php"; diff --git a/locales/template.php b/locales/template.php index f3b5717..bf27fe1 100644 --- a/locales/template.php +++ b/locales/template.php @@ -11,6 +11,7 @@ $loc = array( 'label_mainColor' => "label_mainColor", 'placeholder' => "placeholder", + 'placeholder_pixels' => "placeholder_pixels", 'value_default' => "value_default",