From a6d71988f28eeafbeb64dd6dee9793e3a6efa07d Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 24 Dec 2015 08:35:08 +0100 Subject: [PATCH] Replaced some language calls. --- .env.example | 3 ++ .../Account/ChartJsAccountChartGenerator.php | 6 +-- .../Chart/Bill/ChartJsBillChartGenerator.php | 3 +- .../Budget/ChartJsBudgetChartGenerator.php | 7 ++- .../ChartJsCategoryChartGenerator.php | 6 +-- .../ChartJsPiggyBankChartGenerator.php | 3 +- .../Report/ChartJsReportChartGenerator.php | 3 +- app/Http/Controllers/Controller.php | 4 +- .../Controllers/PreferencesController.php | 8 ++-- app/Http/Middleware/Authenticate.php | 6 ++- app/Http/breadcrumbs.php | 3 +- resources/lang/en_US/firefly.php | 1 + resources/twig/preferences/index.twig | 48 ++++++++++++------- 13 files changed, 56 insertions(+), 45 deletions(-) diff --git a/.env.example b/.env.example index 0633f79412..f8a2c2d6e0 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,7 @@ APP_ENV=production APP_DEBUG=false APP_KEY=SomeRandomStringOf32CharsExactly + DB_CONNECTION=mysql DB_HOST=localhost DB_DATABASE=homestead @@ -20,6 +21,8 @@ EMAIL_USERNAME= EMAIL_PASSWORD= EMAIL_PRETEND=false +SHOW_INCOMPLETE_TRANSLATIONS=false + ANALYTICS_ID= RUNCLEANUP=true SITE_OWNER=mail@example.com diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index 280c0a2bdc..194e667633 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -105,8 +105,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator public function frontpage(Collection $accounts, Carbon $start, Carbon $end) { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.monthAndDay.' . $language); + $format = trans('config.month_and_day'); $data = [ 'count' => 0, 'labels' => [], @@ -151,8 +150,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator public function single(Account $account, Carbon $start, Carbon $end) { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.monthAndDay.' . $language); + $format = trans('config.month_and_day'); $data = [ 'count' => 1, diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 972944763f..9a319be137 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -71,8 +71,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator public function single(Bill $bill, Collection $entries) { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.month.' . $language); + $format = trans('config.month'); $data = [ 'count' => 3, diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index d0952216c9..42608e027d 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -24,7 +24,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator public function budget(Collection $entries, $dateFormat = 'month') { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; + $language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data; $format = Config::get('firefly.' . $dateFormat . '.' . $language); $data = [ @@ -33,7 +33,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator [ 'label' => 'Amount', 'data' => [], - ] + ], ], ]; @@ -115,8 +115,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator public function year(Collection $budgets, Collection $entries) { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.month.' . $language); + $format = trans('config.month'); $data = [ 'labels' => [], diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php index cac74e488e..76c09790f2 100644 --- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php @@ -101,8 +101,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.month.' . $language); + $format = trans('config.month'); $data = [ 'count' => 0, @@ -135,8 +134,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.month.' . $language); + $format = trans('config.month'); $data = [ 'count' => 0, diff --git a/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php b/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php index e1aa9fb352..3e10f5cac0 100644 --- a/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php +++ b/app/Generator/Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php @@ -25,8 +25,7 @@ class ChartJsPiggyBankChartGenerator implements PiggyBankChartGenerator { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.monthAndDay.' . $language); + $format = trans('config.month_and_day'); $data = [ 'count' => 1, diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 8cd93f3ccf..8cb01d82d3 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -22,8 +22,7 @@ class ChartJsReportChartGenerator implements ReportChartGenerator public function yearInOut(Collection $entries) { // language: - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $format = Config::get('firefly.month.' . $language); + $format = trans('config.month'); $data = [ 'count' => 2, diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index dcbb6cf7be..bb9b3d2bc6 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -36,8 +36,8 @@ abstract class Controller extends BaseController if (Auth::check()) { $pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US')); $lang = $pref->data; - $this->monthFormat = Config::get('firefly.month.' . $lang); - $this->monthAndDayFormat = Config::get('firefly.monthAndDay.' . $lang); + $this->monthFormat = trans('config.month'); + $this->monthAndDayFormat = trans('config.month_and_day'); View::share('monthFormat', $this->monthFormat); View::share('monthAndDayFormat', $this->monthAndDayFormat); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 9fd0cb95b9..c782b418e4 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -37,10 +37,12 @@ class PreferencesController extends Controller $viewRange = $viewRangePref->data; $frontPageAccounts = Preferences::get('frontPageAccounts', []); $budgetMax = Preferences::get('budgetMaximum', 1000); - $language = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; + $language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data; $budgetMaximum = $budgetMax->data; - return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange')); + $showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', 'false') == 'true'; + + return view('preferences.index', compact('budgetMaximum', 'language', 'accounts', 'frontPageAccounts', 'viewRange', 'showIncomplete')); } /** @@ -70,7 +72,7 @@ class PreferencesController extends Controller // language: $lang = Input::get('language'); - if (in_array($lang, array_keys(Config::get('firefly.lang')))) { + if (in_array($lang, array_keys(Config::get('firefly.languages')))) { Preferences::set('language', $lang); } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index b0caed5ef4..d867e9512f 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -64,9 +64,11 @@ class Authenticate $pref = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US')); App::setLocale($pref->data); Carbon::setLocale(substr($pref->data,0,2)); + $locale = explode(',', trans('config.locale')); + $locale = array_map('trim', $locale); - setlocale(LC_TIME, Config::get('firefly.locales.' . $pref->data)); - setlocale(LC_MONETARY, Config::get('firefly.locales.' . $pref->data)); + setlocale(LC_TIME, $locale); + setlocale(LC_MONETARY, $locale); return $next($request); } diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 6030da8875..2e6ccb2834 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -354,8 +354,7 @@ Breadcrumbs::register( 'reports.report', function (Generator $breadcrumbs, Carbon $start, Carbon $end, $reportType, $accountIds) { $breadcrumbs->parent('reports.index'); - $pref = Preferences::get('language', env('DEFAULT_LANGUAGE','en_US'))->data; - $monthFormat = Config::get('firefly.monthAndDay.' . $pref); + $monthFormat = trans('config.month_and_day'); $title = trans('firefly.report_default', ['start' => $start->formatLocalized($monthFormat), 'end' => $end->formatLocalized($monthFormat)]); $breadcrumbs->push($title, route('reports.report', ['url' => 'abcde'])); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 493522627f..6a8cb5a3e1 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -2,6 +2,7 @@ return [ // general stuff: + 'language_incomplete' => 'This language is not yet fully translated', 'test' => 'You have selected English.', 'close' => 'Close', 'pleaseHold' => 'Please hold...', diff --git a/resources/twig/preferences/index.twig b/resources/twig/preferences/index.twig index da4aaac469..f847fa1f6d 100644 --- a/resources/twig/preferences/index.twig +++ b/resources/twig/preferences/index.twig @@ -21,9 +21,11 @@
@@ -55,35 +57,40 @@
@@ -97,17 +104,22 @@

{{ 'pref_languages_help'|_ }}

- {% for key, lang in Config.get('firefly.lang') %} -
- -
+ {% for key, lang in Config.get('firefly.languages') %} + {% if lang.complete == true or (lang.complete == false and showIncomplete) %} +
+ +
+ {% endif %} {% endfor %}