Merge branch 'kostasdizas-unicode'

This commit is contained in:
Dan Brown 2019-08-18 18:58:06 +01:00
commit 78f8a51664
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
6 changed files with 18 additions and 6 deletions

View File

@ -57,6 +57,8 @@ class Localization
$locale = setting()->getUser(user(), 'language', $defaultLang); $locale = setting()->getUser(user(), 'language', $defaultLang);
} }
config()->set('app.lang', str_replace('_', '-', $this->getLocaleIso($locale)));
// Set text direction // Set text direction
if (in_array($locale, $this->rtlLocales)) { if (in_array($locale, $this->rtlLocales)) {
config()->set('app.rtl', true); config()->set('app.rtl', true);
@ -86,6 +88,16 @@ class Localization
return $default; 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. * Set the system date locale for localized date formatting.
* Will try both the standard locale name and the UTF8 variant. * Will try both the standard locale name and the UTF8 variant.
@ -93,7 +105,7 @@ class Localization
*/ */
protected function setSystemDateLocale(string $locale) protected function setSystemDateLocale(string $locale)
{ {
$systemLocale = $this->localeMap[$locale] ?? $locale; $systemLocale = $this->getLocaleIso($locale);
$set = setlocale(LC_TIME, $systemLocale); $set = setlocale(LC_TIME, $systemLocale);
if ($set === false) { if ($set === false) {
setlocale(LC_TIME, $systemLocale . '.utf8'); setlocale(LC_TIME, $systemLocale . '.utf8');

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="@yield('body-class')"> <html lang="{{ config('app.lang') }}" class="@yield('body-class')">
<head> <head>
<title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name') }}</title> <title>{{ isset($pageTitle) ? $pageTitle . ' | ' : '' }}{{ setting('app-name') }}</title>

View File

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="{{ config('app.lang') }}">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $book->name }}</title> <title>{{ $book->name }}</title>

View File

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="{{ config('app.lang') }}">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $chapter->name }}</title> <title>{{ $chapter->name }}</title>

View File

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="{{ config('app.lang') }}">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ $page->name }}</title> <title>{{ $page->name }}</title>

View 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"> <!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') }}">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />