Various date localisation. [skip ci]

This commit is contained in:
James Cole 2015-05-14 13:41:21 +02:00
parent de9ac97887
commit 417766f0db
8 changed files with 39 additions and 5 deletions

View File

@ -68,13 +68,14 @@ class ReportHelper implements ReportHelperInterface
*/
public function listOfMonths(Carbon $date)
{
$start = clone $date;
$end = Carbon::now();
$months = [];
while ($start <= $end) {
$year = $start->year;
$months[$year][] = [
'formatted' => $start->format('F Y'),
'formatted' => $start->formatLocalized('%B %Y'),
'month' => $start->month,
'year' => $year,
];

View File

@ -1,8 +1,11 @@
<?php namespace FireflyIII\Http\Controllers;
use Auth;
use Config;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Preferences;
use View;
/**
@ -15,6 +18,11 @@ abstract class Controller extends BaseController
use DispatchesCommands, ValidatesRequests;
/** @var string */
protected $monthAndDayFormat;
/** @var string */
protected $monthFormat;
/**
*
*/
@ -24,5 +32,16 @@ abstract class Controller extends BaseController
View::share('hideCategories', false);
View::share('hideBills', false);
View::share('hideTags', false);
if (Auth::check()) {
$pref = Preferences::get('language', 'en');
$lang = $pref->data;
$this->monthFormat = Config::get('firefly.month.' . $lang);
$this->monthAndDayFormat = Config::get('firefly.monthAndDay.' . $lang);
View::share('monthFormat', $this->monthFormat);
View::share('monthAndDayFormat', $this->monthAndDayFormat);
View::share('language', $lang);
}
}
}

View File

@ -171,7 +171,7 @@ class GoogleChartController extends Controller
$spent = $expenses > floatval($repetition->amount) ? 0 : $expenses;
$overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0;
$allEntries->push(
[$budget->name . ' (' . $repetition->startdate->format('j M Y') . ')',
[$budget->name . ' (' . $repetition->startdate->formatLocalized($this->monthAndDayFormat) . ')',
$left,
$spent,
$overspent

View File

@ -6,7 +6,7 @@ use FireflyIII\Models\Preference;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Preferences;
use Config;
/**
* Class Authenticate
*
@ -55,6 +55,7 @@ class Authenticate
$pref = Preferences::get('language', 'en');
App::setLocale($pref->data);
setlocale(LC_TIME, Config::get('firefly.locales.'.$pref->data));
return $next($request);
}

View File

@ -94,5 +94,17 @@ return [
'en' => 'English',
'nl' => 'Nederlands'
],
'locales' => [
'en' => ['en', 'English', 'en_US', 'en_US.utf8'],
'nl' => ['nl', 'Dutch', 'nl_NL', 'nl_NL.utf8'],
],
'month' => [
'en' => '%B %Y',
'nl' => '%B %Y',
],
'monthAndDay' => [
'en' => '%B %e, %Y',
'nl' => '%e %B %Y',
],
];

View File

@ -1,5 +1,5 @@
var google = google || {};
google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'line', 'sankey', 'table']});
google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'line'],'language': language });
function googleChart(chartType, URL, container, options) {
if ($('#' + container).length === 1) {

View File

@ -134,6 +134,7 @@
var firstDate = moment("{{Session.get('first').format('Y-m-d')}}");
var currentMonthName = "{{ currentMonthName }}";
var previousMonthName = "{{ previousMonthName }}";
var language = "{{ language }}";
var nextMonthName = "{{ nextMonthName }}";
var currencyCode = '{{getCurrencyCode() }}';
$('#daterange span').text(titleString);

View File

@ -61,7 +61,7 @@
{% endif %}
</td>
<td>
{{journal.date.format('j F Y')}}
{{journal.date.formatLocalized(monthAndDayFormat)}}
</td>
<td class="hidden-xs">
{% if journal.transactions[0].account.accountType.type == 'Cash account' %}