Replaced some language calls.

This commit is contained in:
James Cole 2015-12-24 08:35:08 +01:00
parent 7069e242ae
commit a6d71988f2
13 changed files with 56 additions and 45 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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' => [],

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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']));

View File

@ -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...',

View File

@ -21,9 +21,11 @@
<div class="checkbox">
<label>
{% if account.id in frontPageAccounts.data or frontPageAccounts.data|length == 0 %}
<input type="checkbox" name="frontPageAccounts[]" value="{{ account.id }}" checked> {{ account.name }}
<input type="checkbox" name="frontPageAccounts[]" value="{{ account.id }}"
checked> {{ account.name }}
{% else %}
<input type="checkbox" name="frontPageAccounts[]" value="{{ account.id }}"> {{ account.name }}
<input type="checkbox" name="frontPageAccounts[]"
value="{{ account.id }}"> {{ account.name }}
{% endif %}
</label>
</div>
@ -55,35 +57,40 @@
<div class="radio">
<label>
<input type="radio" name="viewRange" value="1D" {% if viewRange == '1D' %} checked {% endif %}>
<input type="radio" name="viewRange"
value="1D" {% if viewRange == '1D' %} checked {% endif %}>
{{ 'pref_1D'|_ }}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="viewRange" value="1W" {% if viewRange == '1W' %} checked {% endif %}>
<input type="radio" name="viewRange"
value="1W" {% if viewRange == '1W' %} checked {% endif %}>
{{ 'pref_1W'|_ }}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="viewRange" value="1M" {% if viewRange == '1M' %} checked {% endif %}>
<input type="radio" name="viewRange"
value="1M" {% if viewRange == '1M' %} checked {% endif %}>
{{ 'pref_1M'|_ }}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="viewRange" value="3M" {% if viewRange == '3M' %} checked {% endif %}>
<input type="radio" name="viewRange"
value="3M" {% if viewRange == '3M' %} checked {% endif %}>
{{ 'pref_3M'|_ }}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="viewRange" value="6M" {% if viewRange == '6M' %} checked {% endif %}>
<input type="radio" name="viewRange"
value="6M" {% if viewRange == '6M' %} checked {% endif %}>
{{ 'pref_6M'|_ }}
</label>
</div>
@ -97,17 +104,22 @@
</div>
<div class="box-body">
<p class="text-info">{{ 'pref_languages_help'|_ }}</p>
{% for key, lang in Config.get('firefly.lang') %}
<div class="radio">
<label>
<input type="radio" name="language" value="{{ key }}"
{% if language == key %}
checked
{% endif %}
/>
{{ lang }}
</label>
</div>
{% for key, lang in Config.get('firefly.languages') %}
{% if lang.complete == true or (lang.complete == false and showIncomplete) %}
<div class="radio">
<label>
<input type="radio" name="language" value="{{ key }}"
{% if language == key %}
checked
{% endif %}
/>
{{ lang.name_locale }} ({{ lang.name_english }})
{% if lang.complete == false %}
<span class="small text-danger">({{ 'language_incomplete'|_ }})</span>
{% endif %}
</label>
</div>
{% endif %}
{% endfor %}
</div>