Translate more date / time outputs

This commit is contained in:
Igor Scheller 2023-02-04 02:43:47 +01:00 committed by Michael Weimann
parent 6b15e6b86e
commit 34e9d01c18
16 changed files with 58 additions and 48 deletions

View File

@ -220,11 +220,12 @@ function angeltype_controller_shiftsFilterDays(AngelType $angeltype)
$days = []; $days = [];
foreach ($all_shifts as $shift) { foreach ($all_shifts as $shift) {
$day = Carbon::make($shift['start'])->format('Y-m-d'); $day = Carbon::make($shift['start'])->format('Y-m-d');
if (!in_array($day, $days)) { $dayFormatted = Carbon::make($shift['start'])->format(__('Y-m-d'));
$days[] = $day; if (!isset($days[$day])) {
$days[$day] = $dayFormatted;
} }
} }
sort($days); ksort($days);
return $days; return $days;
} }
@ -244,8 +245,8 @@ function angeltype_controller_shiftsFilter(AngelType $angeltype, $days)
[$angeltype->id] [$angeltype->id]
); );
$selected_day = date('Y-m-d'); $selected_day = date('Y-m-d');
if (!empty($days) && !in_array($selected_day, $days)) { if (!empty($days) && !isset($days[$selected_day])) {
$selected_day = $days[0]; $selected_day = array_key_first($days);
} }
if ($request->input('shifts_filter_day')) { if ($request->input('shifts_filter_day')) {
$selected_day = $request->input('shifts_filter_day'); $selected_day = $request->input('shifts_filter_day');

View File

@ -27,8 +27,8 @@ function room_controller(): array
$days = []; $days = [];
foreach ($all_shifts as $shift) { foreach ($all_shifts as $shift) {
$day = $shift->start->format('Y-m-d'); $day = $shift->start->format('Y-m-d');
if (!in_array($day, $days)) { if (!isset($days[$day])) {
$days[] = $day; $days[$day] = $shift->start->format(__('Y-m-d'));
} }
} }
@ -38,8 +38,8 @@ function room_controller(): array
AngelType::query()->get('id')->pluck('id')->toArray() AngelType::query()->get('id')->pluck('id')->toArray()
); );
$selected_day = date('Y-m-d'); $selected_day = date('Y-m-d');
if (!empty($days) && !in_array($selected_day, $days)) { if (!empty($days) && !isset($days[$selected_day])) {
$selected_day = $days[0]; $selected_day = array_key_first($days);
} }
if ($request->input('shifts_filter_day')) { if ($request->input('shifts_filter_day')) {
$selected_day = $request->input('shifts_filter_day'); $selected_day = $request->input('shifts_filter_day');

View File

@ -273,8 +273,8 @@ function shift_delete_controller()
error(sprintf( error(sprintf(
__('Do you want to delete the shift %s from %s to %s?'), __('Do you want to delete the shift %s from %s to %s?'),
$shift->shiftType->name, $shift->shiftType->name,
$shift->start->format('Y-m-d H:i'), $shift->start->format(__('Y-m-d H:i')),
$shift->end->format('H:i') $shift->end->format(__('H:i'))
), true), ), true),
form([ form([
form_hidden('delete_shift', $shift->id), form_hidden('delete_shift', $shift->id),

View File

@ -41,13 +41,13 @@ class Shift
(($end->timestamp - $start->timestamp) / 60 / 60) (($end->timestamp - $start->timestamp) / 60 / 60)
* Shifts::getNightShiftMultiplier($start, $end); * Shifts::getNightShiftMultiplier($start, $end);
$workLog->comment = sprintf( $workLog->comment = sprintf(
'%s (%s as %s) in %s, %s - %s', __('%s (%s as %s) in %s, %s - %s'),
$name, $name,
$title, $title,
$type, $type,
$room->name, $room->name,
$start->format('Y-m-d H:i'), $start->format(__('Y-m-d H:i')),
$end->format('Y-m-d H:i') $end->format(__('Y-m-d H:i'))
); );
$workLog->save(); $workLog->save();

View File

@ -36,8 +36,8 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
if ($old_shift->start->timestamp != $new_shift->start->timestamp) { if ($old_shift->start->timestamp != $new_shift->start->timestamp) {
$message .= sprintf( $message .= sprintf(
__('* Shift Start changed from %s to %s'), __('* Shift Start changed from %s to %s'),
$old_shift->start->format('Y-m-d H:i'), $old_shift->start->format(__('Y-m-d H:i')),
$new_shift->start->format('Y-m-d H:i') $new_shift->start->format(__('Y-m-d H:i'))
) . "\n"; ) . "\n";
$noticeable_changes = true; $noticeable_changes = true;
} }
@ -45,8 +45,8 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
if ($old_shift->end->timestamp != $new_shift->end->timestamp) { if ($old_shift->end->timestamp != $new_shift->end->timestamp) {
$message .= sprintf( $message .= sprintf(
__('* Shift End changed from %s to %s'), __('* Shift End changed from %s to %s'),
$old_shift->end->format('Y-m-d H:i'), $old_shift->end->format(__('Y-m-d H:i')),
$new_shift->end->format('Y-m-d H:i') $new_shift->end->format(__('Y-m-d H:i'))
) . "\n"; ) . "\n";
$noticeable_changes = true; $noticeable_changes = true;
} }
@ -66,7 +66,7 @@ function mail_shift_change(Shift $old_shift, Shift $new_shift)
$message .= $new_shift->shiftType->name . "\n"; $message .= $new_shift->shiftType->name . "\n";
$message .= $new_shift->title . "\n"; $message .= $new_shift->title . "\n";
$message .= $new_shift->start->format('Y-m-d H:i') . ' - ' . $new_shift->end->format('H:i') . "\n"; $message .= $new_shift->start->format(__('Y-m-d H:i')) . ' - ' . $new_shift->end->format(__('H:i')) . "\n";
$message .= $new_room->name . "\n\n"; $message .= $new_room->name . "\n\n";
$message .= url('/shifts', ['action' => 'view', 'shift_id' => $new_shift->id]) . "\n"; $message .= url('/shifts', ['action' => 'view', 'shift_id' => $new_shift->id]) . "\n";
@ -94,7 +94,7 @@ function mail_shift_assign(User $user, Shift $shift)
$message = __('You have been assigned to a Shift:') . "\n"; $message = __('You have been assigned to a Shift:') . "\n";
$message .= $shift->shiftType->name . "\n"; $message .= $shift->shiftType->name . "\n";
$message .= $shift->title . "\n"; $message .= $shift->title . "\n";
$message .= $shift->start->format('Y-m-d H:i') . ' - ' . $shift->end->format('H:i') . "\n"; $message .= $shift->start->format(__('Y-m-d H:i')) . ' - ' . $shift->end->format(__('H:i')) . "\n";
$message .= $room->name . "\n\n"; $message .= $room->name . "\n\n";
$message .= url('/shifts', ['action' => 'view', 'shift_id' => $shift->id]) . "\n"; $message .= url('/shifts', ['action' => 'view', 'shift_id' => $shift->id]) . "\n";
@ -112,7 +112,7 @@ function mail_shift_removed(User $user, Shift $shift)
$message = __('You have been removed from a Shift:') . "\n"; $message = __('You have been removed from a Shift:') . "\n";
$message .= $shift->shiftType->name . "\n"; $message .= $shift->shiftType->name . "\n";
$message .= $shift->title . "\n"; $message .= $shift->title . "\n";
$message .= $shift->start->format('Y-m-d H:i') . ' - ' . $shift->end->format('H:i') . "\n"; $message .= $shift->start->format(__('Y-m-d H:i')) . ' - ' . $shift->end->format(__('H:i')) . "\n";
$message .= $room->name . "\n"; $message .= $room->name . "\n";
engelsystem_email_to_user($user, __('Removed from Shift'), $message, true); engelsystem_email_to_user($user, __('Removed from Shift'), $message, true);

View File

@ -115,7 +115,7 @@ function admin_arrive()
]); ]);
if ($usr->state->arrival_date) { if ($usr->state->arrival_date) {
$day = $usr->state->arrival_date->format('Y-m-d'); $day = $usr->state->arrival_date->format(__('Y-m-d'));
if (!isset($arrival_count_at_day[$day])) { if (!isset($arrival_count_at_day[$day])) {
$arrival_count_at_day[$day] = 0; $arrival_count_at_day[$day] = 0;
} }
@ -123,7 +123,7 @@ function admin_arrive()
} }
if ($usr->personalData->planned_arrival_date) { if ($usr->personalData->planned_arrival_date) {
$day = $usr->personalData->planned_arrival_date->format('Y-m-d'); $day = $usr->personalData->planned_arrival_date->format(__('Y-m-d'));
if (!isset($planned_arrival_count_at_day[$day])) { if (!isset($planned_arrival_count_at_day[$day])) {
$planned_arrival_count_at_day[$day] = 0; $planned_arrival_count_at_day[$day] = 0;
} }
@ -131,7 +131,7 @@ function admin_arrive()
} }
if ($usr->personalData->planned_departure_date && $usr->state->arrived) { if ($usr->personalData->planned_departure_date && $usr->state->arrived) {
$day = $usr->personalData->planned_departure_date->format('Y-m-d'); $day = $usr->personalData->planned_departure_date->format(__('Y-m-d'));
if (!isset($planned_departure_count_at_day[$day])) { if (!isset($planned_departure_count_at_day[$day])) {
$planned_departure_count_at_day[$day] = 0; $planned_departure_count_at_day[$day] = 0;
} }

View File

@ -304,9 +304,9 @@ function admin_shifts()
$shifts_table_entry = [ $shifts_table_entry = [
'timeslot' => 'timeslot' =>
icon('clock-history') . ' ' icon('clock-history') . ' '
. $shift['start']->format('Y-m-d H:i') . $shift['start']->format(__('Y-m-d H:i'))
. ' - ' . ' - '
. $shift['end']->format('H:i') . $shift['end']->format(__('H:i'))
. '<br />' . '<br />'
. Room_name_render(Room::find($shift['room_id'])), . Room_name_render(Room::find($shift['room_id'])),
'title' => 'title' =>

View File

@ -54,7 +54,7 @@ function admin_user()
$html .= '<table>' . "\n"; $html .= '<table>' . "\n";
$html .= ' <tr><td>' . __('Nickname') . '</td><td>' . '<input size="40" name="eNick" value="' . $user_source->name . '" class="form-control" maxlength="24"></td></tr>' . "\n"; $html .= ' <tr><td>' . __('Nickname') . '</td><td>' . '<input size="40" name="eNick" value="' . $user_source->name . '" class="form-control" maxlength="24"></td></tr>' . "\n";
$html .= ' <tr><td>' . __('Last login') . '</td><td><p class="help-block">' $html .= ' <tr><td>' . __('Last login') . '</td><td><p class="help-block">'
. ($user_source->last_login_at ? $user_source->last_login_at->format('Y-m-d H:i') : '-') . ($user_source->last_login_at ? $user_source->last_login_at->format(__('Y-m-d H:i')) : '-')
. '</p></td></tr>' . "\n"; . '</p></td></tr>' . "\n";
if (config('enable_user_name')) { if (config('enable_user_name')) {
$html .= ' <tr><td>' . __('Prename') . '</td><td>' . '<input size="40" name="eName" value="' . $user_source->personalData->last_name . '" class="form-control" maxlength="64"></td></tr>' . "\n"; $html .= ' <tr><td>' . __('Prename') . '</td><td>' . '<input size="40" name="eName" value="' . $user_source->personalData->last_name . '" class="form-control" maxlength="64"></td></tr>' . "\n";

View File

@ -96,7 +96,7 @@ function user_myshifts()
return ShiftEntry_edit_view( return ShiftEntry_edit_view(
$shifts_user, $shifts_user,
$shift->start->format('Y-m-d H:i') . ', ' . shift_length($shift), $shift->start->format(__('Y-m-d H:i')) . ', ' . shift_length($shift),
$shift->room->name, $shift->room->name,
$shift->shiftType->name, $shift->shiftType->name,
$shiftEntry->angelType->name, $shiftEntry->angelType->name,

View File

@ -262,6 +262,10 @@ function view_user_shifts()
info(render_user_arrived_hint()); info(render_user_arrived_hint());
} }
$formattedDays = collect($days)->map(function ($value) {
return Carbon::make($value)->format(__('Y-m-d'));
})->toArray();
return page([ return page([
div('col-md-12', [ div('col-md-12', [
msg(), msg(),
@ -276,14 +280,14 @@ function view_user_shifts()
'start_select' => html_select_key( 'start_select' => html_select_key(
'start_day', 'start_day',
'start_day', 'start_day',
array_combine($days, $days), array_combine($days, $formattedDays),
$start_day $start_day
), ),
'start_time' => $start_time, 'start_time' => $start_time,
'end_select' => html_select_key( 'end_select' => html_select_key(
'end_day', 'end_day',
'end_day', 'end_day',
array_combine($days, $days), array_combine($days, $formattedDays),
$end_day $end_day
), ),
'end_time' => $end_time, 'end_time' => $end_time,

View File

@ -21,8 +21,8 @@ function ShiftEntry_delete_view_admin(Shift $shift, AngelType $angeltype, User $
__('Do you want to sign off %s from shift %s from %s to %s as %s?'), __('Do you want to sign off %s from shift %s from %s to %s as %s?'),
User_Nick_render($signoff_user), User_Nick_render($signoff_user),
$shift->shiftType->name, $shift->shiftType->name,
$shift->start->format('Y-m-d H:i'), $shift->start->format(__('Y-m-d H:i')),
$shift->end->format('Y-m-d H:i'), $shift->end->format(__('Y-m-d H:i')),
$angeltype->name $angeltype->name
), true), ), true),
form([ form([
@ -49,8 +49,8 @@ function ShiftEntry_delete_view(Shift $shift, AngelType $angeltype, User $signof
info(sprintf( info(sprintf(
__('Do you want to sign off from your shift %s from %s to %s as %s?'), __('Do you want to sign off from your shift %s from %s to %s as %s?'),
$shift->shiftType->name, $shift->shiftType->name,
$shift->start->format('Y-m-d H:i'), $shift->start->format(__('Y-m-d H:i')),
$shift->end->format('Y-m-d H:i'), $shift->end->format(__('Y-m-d H:i')),
$angeltype->name $angeltype->name
), true), ), true),

View File

@ -49,12 +49,13 @@ class ShiftsFilterRenderer
$toolbar = []; $toolbar = [];
if ($this->daySelectionEnabled && !empty($this->days)) { if ($this->daySelectionEnabled && !empty($this->days)) {
$selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime()); $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
$selected_day_formatted = date(__('Y-m-d'), $this->shiftsFilter->getStartTime());
$day_dropdown_items = []; $day_dropdown_items = [];
foreach ($this->days as $day) { foreach ($this->days as $value => $day) {
$link = $page_link . '&shifts_filter_day=' . $day; $link = $page_link . '&shifts_filter_day=' . $value;
$day_dropdown_items[] = toolbar_item_link($link, '', $day); $day_dropdown_items[] = toolbar_item_link($link, '', $day);
} }
$toolbar[] = toolbar_dropdown($selected_day, $day_dropdown_items, true); $toolbar[] = toolbar_dropdown($selected_day_formatted, $day_dropdown_items, true);
if ($dashboardFilter) { if ($dashboardFilter) {
$toolbar[] = sprintf( $toolbar[] = sprintf(

View File

@ -61,14 +61,14 @@ function Shift_editor_info_render(Shift $shift)
if (!empty($shift->created_by)) { if (!empty($shift->created_by)) {
$info[] = sprintf( $info[] = sprintf(
icon('plus-lg') . __('created at %s by %s'), icon('plus-lg') . __('created at %s by %s'),
$shift->created_at->format('Y-m-d H:i'), $shift->created_at->format(__('Y-m-d H:i')),
User_Nick_render($shift->createdBy) User_Nick_render($shift->createdBy)
); );
} }
if (!empty($shift->updated_by)) { if (!empty($shift->updated_by)) {
$info[] = sprintf( $info[] = sprintf(
icon('pencil') . __('edited at %s by %s'), icon('pencil') . __('edited at %s by %s'),
$shift->updated_at->format('Y-m-d H:i'), $shift->updated_at->format(__('Y-m-d H:i')),
User_Nick_render($shift->updatedBy) User_Nick_render($shift->updatedBy)
); );
} }
@ -164,7 +164,7 @@ function Shift_view(Shift $shift, ShiftType $shifttype, Room $room, $angeltypes_
if (config('signup_advance_hours') && $shift->start->timestamp > time() + config('signup_advance_hours') * 3600) { if (config('signup_advance_hours') && $shift->start->timestamp > time() + config('signup_advance_hours') * 3600) {
$content[] = info(sprintf( $content[] = info(sprintf(
__('This shift is in the far future and becomes available for signup at %s.'), __('This shift is in the far future and becomes available for signup at %s.'),
date(__('Y-m-d') . ' H:i', $shift->start->timestamp - config('signup_advance_hours') * 3600) date(__('Y-m-d H:i'), $shift->start->timestamp - config('signup_advance_hours') * 3600)
), true); ), true);
} }

View File

@ -305,10 +305,10 @@ function User_view_myshift(Shift $shift, $user_source, $its_me)
$myshift = [ $myshift = [
'date' => icon('calendar-event') 'date' => icon('calendar-event')
. $shift->start->format('Y-m-d') . '<br>' . $shift->start->format(__('Y-m-d')) . '<br>'
. icon('clock-history') . $shift->start->format('H:i') . icon('clock-history') . $shift->start->format('H:i')
. ' - ' . ' - '
. $shift->end->format('H:i'), . $shift->end->format(__('H:i')),
'duration' => sprintf('%.2f', ($shift->end->timestamp - $shift->start->timestamp) / 3600) . '&nbsp;h', 'duration' => sprintf('%.2f', ($shift->end->timestamp - $shift->start->timestamp) / 3600) . '&nbsp;h',
'room' => Room_name_render($shift->room), 'room' => Room_name_render($shift->room),
'shift_info' => $shift_info, 'shift_info' => $shift_info,
@ -445,7 +445,7 @@ function User_view_worklog(Worklog $worklog, $admin_user_worklog_privilege)
} }
return [ return [
'date' => icon('calendar-event') . date('Y-m-d', $worklog->worked_at->timestamp), 'date' => icon('calendar-event') . date(__('Y-m-d'), $worklog->worked_at->timestamp),
'duration' => sprintf('%.2f', $worklog->hours) . ' h', 'duration' => sprintf('%.2f', $worklog->hours) . ' h',
'room' => '', 'room' => '',
'shift_info' => __('Work log entry'), 'shift_info' => __('Work log entry'),
@ -453,7 +453,7 @@ function User_view_worklog(Worklog $worklog, $admin_user_worklog_privilege)
. sprintf( . sprintf(
__('Added by %s at %s'), __('Added by %s at %s'),
User_Nick_render($worklog->creator), User_Nick_render($worklog->creator),
$worklog->created_at->format('Y-m-d H:i') $worklog->created_at->format(__('Y-m-d H:i'))
), ),
'actions' => $actions, 'actions' => $actions,
]; ];
@ -711,7 +711,7 @@ function User_view_state_admin($freeloader, $user_source)
$state[] = '<span class="text-success">' . icon('house') $state[] = '<span class="text-success">' . icon('house')
. sprintf( . sprintf(
__('Arrived at %s'), __('Arrived at %s'),
$user_source->state->arrival_date ? $user_source->state->arrival_date->format('Y-m-d') : '' $user_source->state->arrival_date ? $user_source->state->arrival_date->format(__('Y-m-d')) : ''
) )
. '</span>'; . '</span>';
@ -728,7 +728,7 @@ function User_view_state_admin($freeloader, $user_source)
$state[] = '<span class="text-danger">' $state[] = '<span class="text-danger">'
. ($arrivalDate ? sprintf( . ($arrivalDate ? sprintf(
__('Not arrived (Planned: %s)'), __('Not arrived (Planned: %s)'),
$arrivalDate->format('Y-m-d') $arrivalDate->format(__('Y-m-d'))
) : __('Not arrived')) ) : __('Not arrived'))
. '</span>'; . '</span>';
} }

View File

@ -797,6 +797,9 @@ msgid "User %s could not be notified by email due to an error."
msgstr "" msgstr ""
"Aufgrund eines Fehlers konnte dem User %s keine E-Mail gesendet werden." "Aufgrund eines Fehlers konnte dem User %s keine E-Mail gesendet werden."
msgid "%s (%s as %s) in %s, %s - %s"
msgstr "%s (%s als %s) in %s, %s - %s"
#: includes/mailer/shifts_mailer.php:17 #: includes/mailer/shifts_mailer.php:17
msgid "A Shift you are registered on has changed:" msgid "A Shift you are registered on has changed:"
msgstr "Eine deiner Schichten hat sich geändert:" msgstr "Eine deiner Schichten hat sich geändert:"

View File

@ -53,8 +53,9 @@ class DesignController extends BaseController
$date = CarbonImmutable::now(); $date = CarbonImmutable::now();
for ($i = 1; $i <= 600; $i++) { for ($i = 1; $i <= 600; $i++) {
$formattedDate = $date->format('Y-m-d'); $dateKey = $date->format("Y-m-d");
$dateSelectOptions[$formattedDate] = $formattedDate; $formattedDisplayDate = $date->format(__("Y-m-d"));
$dateSelectOptions[$dateKey] = $formattedDisplayDate;
$date = $date->addDay(); $date = $date->addDay();
} }