Skip to content

Commit

Permalink
Set the correct HTML language code
Browse files Browse the repository at this point in the history
  • Loading branch information
alextselegidis committed Jul 3, 2023
1 parent 674d7c4 commit a9798bf
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@
'tr' => 'turkish',
];

$config['language_codes'] = $languages;

$language_code = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en';

$config['language'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'], $languages[$language_code])
? $languages[$language_code]
: Config::LANGUAGE;

$config['language_code'] = array_search($config['language'], $languages) ?: 'en';

/*
|--------------------------------------------------------------------------
| Available Languages
Expand Down
7 changes: 6 additions & 1 deletion application/core/EA_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ private function configure_language()

if ($session_language)
{
config(['language' => $session_language]);
$language_codes = config('language_codes');

config([
'language' => $session_language,
'language_code' => array_search($session_language, $language_codes) ?: 'en'
]);
}

$this->lang->load('translations');
Expand Down
2 changes: 1 addition & 1 deletion application/views/layouts/account_layout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="<?= config('language_code') ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
2 changes: 1 addition & 1 deletion application/views/layouts/backend_layout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="<?= config('language_code') ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
2 changes: 1 addition & 1 deletion application/views/layouts/booking_layout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="<?= config('language_code') ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
2 changes: 1 addition & 1 deletion application/views/layouts/message_layout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="<?= config('language_code') ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down

0 comments on commit a9798bf

Please sign in to comment.