diff --git a/controller/action/i18nActions.class.php b/controller/action/i18nActions.class.php index a78c5f55..0310d050 100644 --- a/controller/action/i18nActions.class.php +++ b/controller/action/i18nActions.class.php @@ -10,10 +10,10 @@ class i18nActions extends Actions { public static function setCulture() { - $culture = isset($_POST['culture']) ? $_POST['culture'] : null; + $culture = $_POST['culture'] ?? null; // Validate - if ($culture && !($culture == 'en_US' || $culture == 'pt_PT')) + if ($culture && !in_array($culture, i18n::getAllCultures())) { $culture = null; } diff --git a/lib/i18n.class.php b/lib/i18n.class.php index ff7c5378..cc06a21f 100644 --- a/lib/i18n.class.php +++ b/lib/i18n.class.php @@ -13,7 +13,8 @@ class i18n protected static $language = null, $translations = [], - $country = null; + $country = null, + $cultures = ['pt_PT', 'en_US']; public static function register($culture = null) /*needed to trigger class include, presumably setup would happen here*/ { @@ -56,6 +57,11 @@ class i18n return static::$country; } + public static function getAllCultures() + { + return static::$cultures; + } + public static function formatCurrency($amount, $currency = 'USD') { return '' . money_format('%.2n', $amount) . ''; diff --git a/view/template/nav/_globalItems.php b/view/template/nav/_globalItems.php index 0b340c33..d974fdf0 100644 --- a/view/template/nav/_globalItems.php +++ b/view/template/nav/_globalItems.php @@ -25,8 +25,12 @@