Skip to content

Firefly III: a personal finances manager

Various date localisation. [skip ci]

James Cole417766f0db6f
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index f90e22e0e2..fd2814c8e6 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -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,
];
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 1af8d4b562..8030bf45be 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -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);
+ }
}
}
diff --git a/app/Http/Controllers/GoogleChartController.php b/app/Http/Controllers/GoogleChartController.php
index 1fdfe04c64..4ab34c5685 100644
--- a/app/Http/Controllers/GoogleChartController.php
+++ b/app/Http/Controllers/GoogleChartController.php
@@ -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
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index aa9bb615b9..c40f66c263 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -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);
}
diff --git a/config/firefly.php b/config/firefly.php
index da81a14f10..aa8bb76867 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -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',
+ ],
];
diff --git a/public/js/gcharts.js b/public/js/gcharts.js
index e1d057551b..065c4975ad 100644
--- a/public/js/gcharts.js
+++ b/public/js/gcharts.js
@@ -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) {
diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig
index cb4ec3bf4a..60038da2f8 100644
--- a/resources/twig/layout/default.twig
+++ b/resources/twig/layout/default.twig
@@ -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);
diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twig
index 7d7e01edac..32a742aa44 100644
--- a/resources/twig/list/journals.twig
+++ b/resources/twig/list/journals.twig
@@ -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' %}