Fix translations when removing users from angeltype

This commit is contained in:
Igor Scheller 2024-03-10 12:38:49 +01:00 committed by xuwhite
parent 0642bff804
commit ba908bf849
3 changed files with 22 additions and 14 deletions

View File

@ -231,8 +231,9 @@ function user_angeltype_delete_controller(): array
$user_angeltype = UserAngelType::findOrFail($request->input('user_angeltype_id')); $user_angeltype = UserAngelType::findOrFail($request->input('user_angeltype_id'));
$angeltype = $user_angeltype->angelType; $angeltype = $user_angeltype->angelType;
$user_source = $user_angeltype->user; $user_source = $user_angeltype->user;
$isOwnAngelType = $user->id == $user_source->id;
if ( if (
$user->id != $user_angeltype->user_id !$isOwnAngelType
&& !$user->isAngelTypeSupporter($angeltype) && !$user->isAngelTypeSupporter($angeltype)
&& !auth()->can('admin_user_angeltypes') && !auth()->can('admin_user_angeltypes')
) { ) {
@ -243,15 +244,15 @@ function user_angeltype_delete_controller(): array
if ($request->hasPostData('delete')) { if ($request->hasPostData('delete')) {
$user_angeltype->delete(); $user_angeltype->delete();
engelsystem_log(sprintf('User %s removed from %s.', User_Nick_render($user_source, true), $angeltype->name)); engelsystem_log(sprintf('User "%s" removed from "%s".', User_Nick_render($user_source, true), $angeltype->name));
success(sprintf(__('User %s removed from %s.'), $user_source->displayName, $angeltype->name)); success(sprintf($isOwnAngelType ? __('You successfully left "%2$s".') : __('User "%s" removed from "%s".'), $user_source->displayName, $angeltype->name));
throw_redirect(url('/angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id])); throw_redirect(url('/angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id]));
} }
return [ return [
__('Remove angeltype'), __('Leave angeltype'),
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype), UserAngelType_delete_view($user_angeltype, $user_source, $angeltype, $isOwnAngelType),
]; ];
} }

View File

@ -108,14 +108,15 @@ function UserAngelType_confirm_view(UserAngelType $user_angeltype, User $user, A
* @param UserAngelType $user_angeltype * @param UserAngelType $user_angeltype
* @param User $user * @param User $user
* @param AngelType $angeltype * @param AngelType $angeltype
* @param bool $isOwnAngelType
* @return string * @return string
*/ */
function UserAngelType_delete_view(UserAngelType $user_angeltype, User $user, AngelType $angeltype) function UserAngelType_delete_view(UserAngelType $user_angeltype, User $user, AngelType $angeltype, bool $isOwnAngelType)
{ {
return page_with_title(__('Remove angeltype'), [ return page_with_title(__('Leave angeltype'), [
msg(), msg(),
info(sprintf( info(sprintf(
__('Do you really want to delete %s from %s?'), $isOwnAngelType ? __('Do you really want to leave "%2$s"?') : __('Do you really want to remove "%s" from "%s"?'),
$user->displayName, $user->displayName,
$angeltype->name $angeltype->name
), true), ), true),

View File

@ -365,14 +365,17 @@ msgstr "Engeltyp für Benutzer bestätigen"
msgid "You are not allowed to delete this users angeltype." msgid "You are not allowed to delete this users angeltype."
msgstr "Du darfst diesen Benutzer nicht von diesem Engeltyp entfernen." msgstr "Du darfst diesen Benutzer nicht von diesem Engeltyp entfernen."
msgid "User %s removed from %s." msgid "User \"%s\" removed from \"%s\"."
msgstr "Benutzer %s von %s entfernt." msgstr "Benutzer \"%s\" von \"%s\" entfernt."
msgid "Edit certificates" msgid "Edit certificates"
msgstr "Zertifikate bearbeiten" msgstr "Zertifikate bearbeiten"
msgid "Remove angeltype" msgid "You successfully left \"%2$s\"."
msgstr "Engeltyp löschen" msgstr "Du hast erfolgreich \"%2$s\" verlassen."
msgid "Leave angeltype"
msgstr "Engeltyp verlassen"
msgid "You are not allowed to set supporter rights." msgid "You are not allowed to set supporter rights."
msgstr "Du darfst keine Supporterrechte bearbeiten." msgstr "Du darfst keine Supporterrechte bearbeiten."
@ -1129,8 +1132,11 @@ msgstr "Möchtest Du wirklich alle Benutzer als %s bestätigen?"
msgid "Do you really want to confirm %s for %s?" msgid "Do you really want to confirm %s for %s?"
msgstr "Möchtest Du wirklich %s für %s bestätigen?" msgstr "Möchtest Du wirklich %s für %s bestätigen?"
msgid "Do you really want to delete %s from %s?" msgid "Do you really want to remove \"%s\" from \"%s\"?"
msgstr "Möchtest Du wirklich %s von %s entfernen?" msgstr "Möchtest Du wirklich \"%s\" von \"%s\" entfernen?"
msgid "Do you really want to leave \"%2$s\"?"
msgstr "Möchtest Du \"%2$s\" wirklich verlassen?"
msgid "Do you really want to add %s to %s?" msgid "Do you really want to add %s to %s?"
msgstr "Möchtest Du wirklich %s zu %s hinzufügen?" msgstr "Möchtest Du wirklich %s zu %s hinzufügen?"