diff --git a/app/Http/ViewComposers/AppLanguageComposer.php b/app/Http/ViewComposers/AppLanguageComposer.php new file mode 100644 index 0000000000..b9de4b801a --- /dev/null +++ b/app/Http/ViewComposers/AppLanguageComposer.php @@ -0,0 +1,37 @@ +with('appLanguage', $this->getLanguage()); + } + + /** + * Get the language from the current locale + * + * @return string + */ + private function getLanguage() + { + $code = app()->getLocale(); + + if(preg_match('/_/', $code)) { + $codes = explode('_', $code); + $code = $codes[0]; + } + + return $code; + } +} \ No newline at end of file diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index 0bd4f0b57c..91d11043b3 100644 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -17,6 +17,11 @@ class ComposerServiceProvider extends ServiceProvider ['accounts.details', 'clients.edit', 'payments.edit', 'invoices.edit', 'accounts.localization'], 'App\Http\ViewComposers\TranslationComposer' ); + + view()->composer( + ['header', 'tasks.edit'], + 'App\Http\ViewComposers\AppLanguageComposer' + ); } /** diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index de91336e1c..4eaa4de24a 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -305,6 +305,7 @@ /* Set the defaults for Bootstrap datepicker */ $.extend(true, $.fn.datepicker.defaults, { + language: '{{ $appLanguage }}', weekStart: {{ Session::get('start_of_week') }} }); diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index 28df47a372..1baee6a367 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -170,7 +170,7 @@ var value = ko.utils.unwrapObservable(valueAccessor()); // http://xdsoft.net/jqplugins/datetimepicker/ $(element).datetimepicker({ - lang: '{{ Utils::getLocaleRegion() }}', + lang: '{{ $appLanguage }}', lazyInit: true, validateOnBlur: false, step: 30,