NOW MANAGED ON CODEBERG
Added locale and text direction to html templates
Kostas Dizas86f56dd22b09
diff --git a/app/Http/Middleware/Localization.php b/app/Http/Middleware/Localization.phpindex ff5526cc7..753fe438e 100644--- a/app/Http/Middleware/Localization.php+++ b/app/Http/Middleware/Localization.php@@ -59,6 +59,8 @@ class Localization$locale = setting()->getUser(user(), 'language', $defaultLang);}+ config()->set('app.lang', $this->getLocaleIso($locale));+// Set text directionif (in_array($locale, $this->rtlLocales)) {config()->set('app.rtl', true);@@ -88,6 +90,16 @@ class Localizationreturn $default;}+ /**+ * Get the ISO version of a BookStack language name+ * @param string $locale+ * @return string+ */+ public function getLocaleIso(string $locale)+ {+ return $this->localeMap[$locale] ?? $locale;+ }+/*** Set the system date locale for localized date formatting.* Will try both the standard locale name and the UTF8 variant.@@ -95,7 +107,7 @@ class Localization*/protected function setSystemDateLocale(string $locale){- $systemLocale = $this->localeMap[$locale] ?? $locale;+ $systemLocale = $this->getLocaleIso($locale);$set = setlocale(LC_TIME, $systemLocale);if ($set === false) {setlocale(LC_TIME, $systemLocale . '.utf8');diff --git a/resources/views/base.blade.php b/resources/views/base.blade.phpindex 367a2cd8b..971a90340 100644--- a/resources/views/base.blade.php+++ b/resources/views/base.blade.php@@ -1,5 +1,5 @@<!DOCTYPE html>-<html class="@yield('body-class')">+<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}" class="@yield('body-class')"><head><title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name') }}</title>diff --git a/resources/views/books/export.blade.php b/resources/views/books/export.blade.phpindex 61c16c72d..fd1ba3fd1 100644--- a/resources/views/books/export.blade.php+++ b/resources/views/books/export.blade.php@@ -1,5 +1,5 @@<!doctype html>-<html lang="en">+<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>{{ $book->name }}</title>diff --git a/resources/views/chapters/export.blade.php b/resources/views/chapters/export.blade.phpindex 2830855b4..5fae78269 100644--- a/resources/views/chapters/export.blade.php+++ b/resources/views/chapters/export.blade.php@@ -1,5 +1,5 @@<!doctype html>-<html lang="en">+<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>{{ $chapter->name }}</title>diff --git a/resources/views/pages/export.blade.php b/resources/views/pages/export.blade.phpindex e40643c25..970db3c2f 100644--- a/resources/views/pages/export.blade.php+++ b/resources/views/pages/export.blade.php@@ -1,5 +1,5 @@<!doctype html>-<html lang="en">+<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>{{ $page->name }}</title>diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.phpindex 3e02cbba9..8d63fedfd 100644--- a/resources/views/vendor/notifications/email.blade.php+++ b/resources/views/vendor/notifications/email.blade.php@@ -1,5 +1,5 @@<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-<html>+<html lang="{{ config('app.lang') }}" dir="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"><head><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />