Add support for British English and allow the user to set a locale.

This commit is contained in:
James Cole
2020-04-19 06:51:40 +02:00
parent aa786eaaf3
commit c398aa2b69
17 changed files with 78 additions and 42 deletions

View File

@@ -287,10 +287,11 @@ class Navigation
*/
public function listOfPeriods(Carbon $start, Carbon $end): array
{
$locale = app('steam')->getLocale();
// define period to increment
$increment = 'addDay';
$format = $this->preferredCarbonFormat($start, $end);
$displayFormat = (string)trans('config.month_and_day');
$displayFormat = (string)trans('config.month_and_day', [], $locale);
// increment by month (for year)
if ($start->diffInMonths($end) > 1) {
$increment = 'addMonth';
@@ -391,13 +392,14 @@ class Navigation
*/
public function preferredCarbonLocalizedFormat(Carbon $start, Carbon $end): string
{
$format = (string)trans('config.month_and_day');
$locale = app('steam')->getLocale();
$format = (string)trans('config.month_and_day', [], $locale);
if ($start->diffInMonths($end) > 1) {
$format = (string)trans('config.month');
$format = (string)trans('config.month', [], $locale);
}
if ($start->diffInMonths($end) > 12) {
$format = (string)trans('config.year');
$format = (string)trans('config.year', [], $locale);
}
return $format;