Skip to content

Commit

Permalink
set initial script locale
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Oct 26, 2024
1 parent 53a3248 commit d84d917
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions php/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
define("METADATA_URL", "https://litcal.johnromanodorazio.com/api/{$endpointV}/calendars");
$directAccess = (basename(__FILE__) === basename($_SERVER['SCRIPT_FILENAME']));

// debug value of currentLocale cookie
if (false === $directAccess) {
if (!empty($_COOKIE["currentLocale"])) {
echo '<!-- value of currentLocale: ' . $_COOKIE["currentLocale"] . ' -->';
Expand Down
13 changes: 13 additions & 0 deletions php/src/LitSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ public function __construct(array $DATA, bool $directAccess = false)
$this->Locale = LitLocale::LATIN_PRIMARY_LANGUAGE;
}
$this->Locale = \Locale::canonicalize($this->Locale);
$baseLocale = \Locale::getPrimaryLanguage($this->Locale);
$localeArray = [
$this->Locale . '.utf8',
$this->Locale . '.UTF-8',
$this->Locale,
$baseLocale . '_' . strtoupper($baseLocale) . '.utf8',
$baseLocale . '_' . strtoupper($baseLocale) . '.UTF-8',
$baseLocale . '_' . strtoupper($baseLocale),
$baseLocale . '.utf8',
$baseLocale . '.UTF-8',
$baseLocale
];
setlocale(LC_ALL, $localeArray);

$this->directAccess = $directAccess;

Expand Down

0 comments on commit d84d917

Please sign in to comment.