mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
Merge pull request #994 from codedge/#705-set-app-language-for-templates
Make app language available in templates
This commit is contained in:
commit
a3271d6688
37
app/Http/ViewComposers/AppLanguageComposer.php
Normal file
37
app/Http/ViewComposers/AppLanguageComposer.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\ViewComposers;
|
||||||
|
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AppLanguageComposer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bind data to the view.
|
||||||
|
*
|
||||||
|
* @param View $view
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function compose(View $view)
|
||||||
|
{
|
||||||
|
$view->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;
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,11 @@ class ComposerServiceProvider extends ServiceProvider
|
|||||||
['accounts.details', 'clients.edit', 'payments.edit', 'invoices.edit', 'accounts.localization'],
|
['accounts.details', 'clients.edit', 'payments.edit', 'invoices.edit', 'accounts.localization'],
|
||||||
'App\Http\ViewComposers\TranslationComposer'
|
'App\Http\ViewComposers\TranslationComposer'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
view()->composer(
|
||||||
|
['header', 'tasks.edit'],
|
||||||
|
'App\Http\ViewComposers\AppLanguageComposer'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,6 +305,7 @@
|
|||||||
|
|
||||||
/* Set the defaults for Bootstrap datepicker */
|
/* Set the defaults for Bootstrap datepicker */
|
||||||
$.extend(true, $.fn.datepicker.defaults, {
|
$.extend(true, $.fn.datepicker.defaults, {
|
||||||
|
language: '{{ $appLanguage }}',
|
||||||
weekStart: {{ Session::get('start_of_week') }}
|
weekStart: {{ Session::get('start_of_week') }}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@
|
|||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
// http://xdsoft.net/jqplugins/datetimepicker/
|
// http://xdsoft.net/jqplugins/datetimepicker/
|
||||||
$(element).datetimepicker({
|
$(element).datetimepicker({
|
||||||
lang: '{{ Utils::getLocaleRegion() }}',
|
lang: '{{ $appLanguage }}',
|
||||||
lazyInit: true,
|
lazyInit: true,
|
||||||
validateOnBlur: false,
|
validateOnBlur: false,
|
||||||
step: 30,
|
step: 30,
|
||||||
|
Loading…
Reference in New Issue
Block a user