Locales: use http-accept-language or cookie (#976)

* Locales: use http-accept-language or "language"-cookie

* Add user-setting "locale"

Rename CULTURE to DEFAULT_LOCALE

* Use LocaleMiddleware also in dev mode

* CORS: don't require authentication on OPTIONS

* Use a standard user-settings-control and start a new generic user settings page, not a separate page for the locale setting

* Fixed (broken by myself) link-return handling

* Clarify language settings

* Removed unneeded files

* Better user settings icon

* Added localization hints

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
fipwmaqzufheoxq92ebc
2020-08-31 19:11:51 +02:00
committed by GitHub
parent 4a030b7ffc
commit 6f8ad9b76e
21 changed files with 383 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ GROCY_CULTURE }}">
<html lang="{{ GROCY_LOCALE }}">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
@@ -52,7 +52,7 @@
Grocy.BaseUrl = '{{ $U('/') }}';
Grocy.CurrentUrlRelative = "/" + window.location.href.split('?')[0].replace(Grocy.BaseUrl, "");
Grocy.ActiveNav = '@yield('activeNav', '')';
Grocy.Culture = '{{ GROCY_CULTURE }}';
Grocy.Culture = '{{ GROCY_LOCALE }}';
Grocy.Currency = '{{ GROCY_CURRENCY }}';
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
@@ -416,6 +416,9 @@
@if(GROCY_FEATURE_FLAG_TASKS)
<a class="dropdown-item discrete-link permission-TASKS" href="{{ $U('/taskssettings') }}"><i class="fas fa-tasks"></i>&nbsp;{{ $__t('Tasks settings') }}</a>
@endif
<a data-href="{{ $U('/usersettings') }}" class="dropdown-item discrete-link link-return">
<i class="fas fa-user-cog"></i> {{ $__t('User settings') }}
</a>
<div class="dropdown-divider"></div>
@if(GROCY_SHOW_AUTH_VIEWS)
<a class="dropdown-item discrete-link permission-USERS_READ" href="{{ $U('/users') }}"><i class="fas fa-users"></i>&nbsp;{{ $__t('Manage users') }}</a>

View File

@@ -0,0 +1,30 @@
@extends('layout.default')
@section('title', $__t('User settings'))
@section('activeNav', '')
@section('viewJsName', 'usersettings')
@section('content')
<div class="row">
<div class="col">
<h2 class="title">@yield('title')</h2>
<hr>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-xs-12">
<div class="form-group">
<label for="locale">{{ $__t('Language') }}</label>
<select class="form-control user-setting-control" id="locale" data-setting-key="locale">
<option value="">{{ $__t('Default') }}</option>
@foreach($languages as $lang)
<option value="{{ $lang }}" @if(GROCY_LOCALE == $lang) checked @endif>{{ $__t($lang) }}</option>
@endforeach
</select>
</div>
<a href="{{ $U('/') }}" class="btn btn-success link-return">{{ $__t('OK') }}</a>
</div>
</div>
@stop