diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.php index 487490723..2614f50fb 100644 --- a/endpoints/subscriptions/get.php +++ b/endpoints/subscriptions/get.php @@ -18,6 +18,13 @@ $colorTheme = $settings['color_theme']; } +$locale = isset($_COOKIE['user_locale']) ? $_COOKIE['user_locale'] : 'en_US'; +$formatter = new IntlDateFormatter( + $locale, + IntlDateFormatter::MEDIUM, + IntlDateFormatter::NONE +); + if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) { @@ -146,7 +153,9 @@ $paymentMethodId = $subscription['payment_method_id']; $print[$id]['currency_code'] = $currencies[$subscription['currency_id']]['code']; $currencyId = $subscription['currency_id']; - $print[$id]['next_payment'] = date('M d, Y', strtotime($subscription['next_payment'])); + $next_payment_timestamp = strtotime($subscription['next_payment']); + $formatted_date = $formatter->format($next_payment_timestamp); + $print[$id]['next_payment'] = $formatted_date; $paymentIconFolder = (strpos($payment_methods[$paymentMethodId]['icon'], 'images/uploads/icons/') !== false) ? "" : "images/uploads/logos/"; $print[$id]['payment_method_icon'] = $paymentIconFolder . $payment_methods[$paymentMethodId]['icon']; $print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name']; diff --git a/includes/header.php b/includes/header.php index 239af3999..d2186556a 100644 --- a/includes/header.php +++ b/includes/header.php @@ -50,6 +50,13 @@ $isAdmin = $_SESSION['userId'] == 1; +$locale = isset($_COOKIE['user_locale']) ? $_COOKIE['user_locale'] : 'en_US'; +$formatter = new IntlDateFormatter( + $locale, + IntlDateFormatter::MEDIUM, + IntlDateFormatter::NONE +); + function hex2rgb($hex) { $hex = str_replace("#", "", $hex); diff --git a/includes/version.php b/includes/version.php index 8e607f72b..cd3fb878d 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/index.php b/index.php index 83a11eb8b..e673e078e 100644 --- a/index.php +++ b/index.php @@ -334,7 +334,9 @@ $paymentMethodId = $subscription['payment_method_id']; $print[$id]['currency_code'] = $currencies[$subscription['currency_id']]['code']; $currencyId = $subscription['currency_id']; - $print[$id]['next_payment'] = date('M d, Y', strtotime($subscription['next_payment'])); + $next_payment_timestamp = strtotime($subscription['next_payment']); + $formatted_date = $formatter->format($next_payment_timestamp); + $print[$id]['next_payment'] = $formatted_date; $paymentIconFolder = (strpos($payment_methods[$paymentMethodId]['icon'], 'images/uploads/icons/') !== false) ? "" : "images/uploads/logos/"; $print[$id]['payment_method_icon'] = $paymentIconFolder . $payment_methods[$paymentMethodId]['icon']; $print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name']; diff --git a/scripts/common.js b/scripts/common.js index f681dcb44..35a0b5c96 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -70,6 +70,9 @@ function showSuccessMessage(message) { document.addEventListener('DOMContentLoaded', function () { + const userLocale = navigator.language || navigator.languages[0]; + document.cookie = `user_locale=${userLocale}; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict`; + if (window.update_theme_settings) { const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; const themePreference = prefersDarkMode ? 'dark' : 'light'; diff --git a/scripts/login.js b/scripts/login.js index 2cf93b75e..fddc7f5f5 100644 --- a/scripts/login.js +++ b/scripts/login.js @@ -1,13 +1,16 @@ document.addEventListener('DOMContentLoaded', function () { - if (window.update_theme_settings) { - const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; - const themePreference = prefersDarkMode ? 'dark' : 'light'; - const darkThemeCss = document.querySelector("#dark-theme"); - darkThemeCss.disabled = themePreference === 'light'; - document.body.className = themePreference; - const themeColorMetaTag = document.querySelector('meta[name="theme-color"]'); - themeColorMetaTag.setAttribute('content', themePreference === 'dark' ? '#222222' : '#FFFFFF'); - } + const userLocale = navigator.language || navigator.languages[0]; + document.cookie = `user_locale=${userLocale}; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict`; + + if (window.update_theme_settings) { + const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; + const themePreference = prefersDarkMode ? 'dark' : 'light'; + const darkThemeCss = document.querySelector("#dark-theme"); + darkThemeCss.disabled = themePreference === 'light'; + document.body.className = themePreference; + const themeColorMetaTag = document.querySelector('meta[name="theme-color"]'); + themeColorMetaTag.setAttribute('content', themePreference === 'dark' ? '#222222' : '#FFFFFF'); + } }); \ No newline at end of file