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

View File

@ -27,8 +27,8 @@ function room_controller(): array
$days = [];
foreach ($all_shifts as $shift) {
$day = $shift->start->format('Y-m-d');
if (!in_array($day, $days)) {
$days[] = $day;
if (!isset($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()
);
$selected_day = date('Y-m-d');
if (!empty($days) && !in_array($selected_day, $days)) {
$selected_day = $days[0];
if (!empty($days) && !isset($days[$selected_day])) {
$selected_day = array_key_first($days);
}
if ($request->input('shifts_filter_day')) {
$selected_day = $request->input('shifts_filter_day');

View File

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

View File

@ -41,13 +41,13 @@ class Shift
(($end->timestamp - $start->timestamp) / 60 / 60)
* Shifts::getNightShiftMultiplier($start, $end);
$workLog->comment = sprintf(
'%s (%s as %s) in %s, %s - %s',
__('%s (%s as %s) in %s, %s - %s'),
$name,
$title,
$type,
$room->name,
$start->format('Y-m-d H:i'),
$end->format('Y-m-d H:i')
$start->format(__('Y-m-d H:i')),
$end->format(__('Y-m-d H:i'))
);
$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) {
$message .= sprintf(
__('* Shift Start changed from %s to %s'),
$old_shift->start->format('Y-m-d H:i'),
$new_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'))
) . "\n";
$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) {
$message .= sprintf(
__('* Shift End changed from %s to %s'),
$old_shift->end->format('Y-m-d H:i'),
$new_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'))
) . "\n";
$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->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 .= 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 .= $shift->shiftType->name . "\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 .= 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 .= $shift->shiftType->name . "\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";
engelsystem_email_to_user($user, __('Removed from Shift'), $message, true);

View File

@ -115,7 +115,7 @@ function admin_arrive()
]);
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])) {
$arrival_count_at_day[$day] = 0;
}
@ -123,7 +123,7 @@ function admin_arrive()
}
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])) {
$planned_arrival_count_at_day[$day] = 0;
}
@ -131,7 +131,7 @@ function admin_arrive()
}
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])) {
$planned_departure_count_at_day[$day] = 0;
}

View File

@ -304,9 +304,9 @@ function admin_shifts()
$shifts_table_entry = [
'timeslot' =>
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 />'
. Room_name_render(Room::find($shift['room_id'])),
'title' =>

View File

@ -54,7 +54,7 @@ function admin_user()
$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>' . __('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";
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";

View File

@ -96,7 +96,7 @@ function user_myshifts()
return ShiftEntry_edit_view(
$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->shiftType->name,
$shiftEntry->angelType->name,

View File

@ -262,6 +262,10 @@ function view_user_shifts()
info(render_user_arrived_hint());
}
$formattedDays = collect($days)->map(function ($value) {
return Carbon::make($value)->format(__('Y-m-d'));
})->toArray();
return page([
div('col-md-12', [
msg(),
@ -276,14 +280,14 @@ function view_user_shifts()
'start_select' => html_select_key(
'start_day',
'start_day',
array_combine($days, $days),
array_combine($days, $formattedDays),
$start_day
),
'start_time' => $start_time,
'end_select' => html_select_key(
'end_day',
'end_day',
array_combine($days, $days),
array_combine($days, $formattedDays),
$end_day
),
'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?'),
User_Nick_render($signoff_user),
$shift->shiftType->name,
$shift->start->format('Y-m-d H:i'),
$shift->end->format('Y-m-d H:i'),
$shift->start->format(__('Y-m-d H:i')),
$shift->end->format(__('Y-m-d H:i')),
$angeltype->name
), true),
form([
@ -49,8 +49,8 @@ function ShiftEntry_delete_view(Shift $shift, AngelType $angeltype, User $signof
info(sprintf(
__('Do you want to sign off from your shift %s from %s to %s as %s?'),
$shift->shiftType->name,
$shift->start->format('Y-m-d H:i'),
$shift->end->format('Y-m-d H:i'),
$shift->start->format(__('Y-m-d H:i')),
$shift->end->format(__('Y-m-d H:i')),
$angeltype->name
), true),

View File

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

View File

@ -61,14 +61,14 @@ function Shift_editor_info_render(Shift $shift)
if (!empty($shift->created_by)) {
$info[] = sprintf(
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)
);
}
if (!empty($shift->updated_by)) {
$info[] = sprintf(
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)
);
}
@ -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) {
$content[] = info(sprintf(
__('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);
}

View File

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

View File

@ -797,6 +797,9 @@ msgid "User %s could not be notified by email due to an error."
msgstr ""
"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
msgid "A Shift you are registered on has changed:"
msgstr "Eine deiner Schichten hat sich geändert:"

View File

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