]> BookStack Code Mirror - bookstack/commitdiff
Added locale and text direction to html templates 1486/head
authorKostas Dizas <redacted>
Tue, 11 Jun 2019 19:35:31 +0000 (20:35 +0100)
committerKostas Dizas <redacted>
Tue, 11 Jun 2019 22:01:08 +0000 (23:01 +0100)
app/Http/Middleware/Localization.php
resources/views/base.blade.php
resources/views/books/export.blade.php
resources/views/chapters/export.blade.php
resources/views/pages/export.blade.php
resources/views/vendor/notifications/email.blade.php

index ff5526cc70d61f6fbdcde2aa35a63c034d74ff1a..753fe438e0dbf8422ed3c647fa97cb63f1eae988 100644 (file)
@@ -59,6 +59,8 @@ class Localization
             $locale = setting()->getUser(user(), 'language', $defaultLang);
         }
 
+        config()->set('app.lang', $this->getLocaleIso($locale));
+
         // Set text direction
         if (in_array($locale, $this->rtlLocales)) {
             config()->set('app.rtl', true);
@@ -88,6 +90,16 @@ class Localization
         return $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');
index 367a2cd8b9ba69536d985dc85cbf1a14681c7395..971a903401b5a8e2cfbdb38e5d2a8cd39a907a1e 100644 (file)
@@ -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>
 
index 61c16c72dc586282f298cb0c2f98421dd0c3f688..fd1ba3fd1b0aff3b7d005f794f9dde6c0ad4382e 100644 (file)
@@ -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>
index 2830855b4f8a0fc53a132ebda8cc9c19b5e818e9..5fae78269215a3cf719a4820f31f51fad5d6bbb1 100644 (file)
@@ -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>
index e40643c256ff5346124a36dc717c5dada02fadde..970db3c2f2b820c0534876261847bd7a0abd0935 100644 (file)
@@ -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>
index 3e02cbba9ceb15e7dacc4cac74b3db58ca02fc57..8d63fedfdec4afecd40581e7c6462fc3a8a9babc 100644 (file)
@@ -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" />