Skip to content

Commit

Permalink
Capitalize the first letter of strings that start with {type} in German
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 27, 2024
1 parent 583fcbc commit 5755af3
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 104 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixed a bug where custom fields were getting included in rendered field layout forms, even if their `getInputHtml()` method returned an empty string.
- Fixed a bug where the password input on the Set Password page wasn’t including the “Show” button.
- Fixed a SQL error that could occur if an element was saved with a title longer than 255 characters.
- Fixed a bug where some UI messages began with a lowercase letter in some languages. ([#16354](https://github.com/craftcms/cms/issues/16354))
- Fixed an RCE vulnerability.

## 4.13.7 - 2024-12-17
Expand Down
8 changes: 4 additions & 4 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -989,19 +989,19 @@ public static function actions(string $source): array
if (!$hasActionType(Edit::class)) {
$actions->prepend([
'type' => Edit::class,
'label' => Craft::t('app', 'Edit {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Edit {type}', [
'type' => static::lowerDisplayName(),
]),
])),
]);
}

// Prepend View?
if (static::hasUris() && !$hasActionType(View::class)) {
$actions->prepend([
'type' => View::class,
'label' => Craft::t('app', 'View {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'View {type}', [
'type' => static::lowerDisplayName(),
]),
])),
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public function actionSaveAsset(): ?Response
if (!Craft::$app->getElements()->saveElement($asset)) {
return $this->asModelFailure(
$asset,
Craft::t('app', 'Couldn’t save {type}.', [
StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Asset::lowerDisplayName(),
]),
])),
$assetVariable
);
}
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use craft\errors\InvalidElementException;
use craft\helpers\Cp;
use craft\helpers\ElementHelper;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\models\CategoryGroup;
use craft\models\CategoryGroup_SiteSettings;
Expand Down Expand Up @@ -279,9 +280,9 @@ public function actionCreate(string $groupHandle): ?Response
// Save it
$category->setScenario(Element::SCENARIO_ESSENTIALS);
if (!Craft::$app->getDrafts()->saveElementAsDraft($category, Craft::$app->getUser()->getId(), null, null, false)) {
return $this->asModelFailure($category, Craft::t('app', 'Couldn’t create {type}.', [
return $this->asModelFailure($category, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => Category::lowerDisplayName(),
]), 'category');
])), 'category');
}

// Set its position in the structure if a before/after param was passed
Expand Down Expand Up @@ -370,9 +371,9 @@ public function actionSaveCategory(): ?Response
if (!Craft::$app->getElements()->saveElement($category)) {
return $this->asModelFailure(
$category,
Craft::t('app', 'Couldn’t save {type}.', [
StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Category::lowerDisplayName(),
]),
])),
$categoryVariable
);
}
Expand Down
48 changes: 24 additions & 24 deletions src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ public function actionCreate(): Response
// Save it
$element->setScenario(Element::SCENARIO_ESSENTIALS);
if (!Craft::$app->getDrafts()->saveElementAsDraft($element, $user->id, null, null, false)) {
return $this->_asFailure($element, Craft::t('app', 'Couldn’t create {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => $element::lowerDisplayName(),
]));
])));
}

// Redirect to its edit page
Expand Down Expand Up @@ -457,9 +457,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
if ($isUnpublishedDraft) {
if ($canSaveCanonical) {
$response
->submitButtonLabel(Craft::t('app', 'Create {type}', [
->submitButtonLabel(StringHelper::upperCaseFirst(Craft::t('app', 'Create {type}', [
'type' => $element::lowerDisplayName(),
]))
])))
->action('elements/apply-draft')
->redirectUrl("$redirectUrl#");
} else {
Expand All @@ -473,9 +473,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
->redirectUrl("$redirectUrl#");
} elseif ($isDraft) {
$response
->submitButtonLabel(Craft::t('app', 'Save {type}', [
->submitButtonLabel(StringHelper::upperCaseFirst(Craft::t('app', 'Save {type}', [
'type' => Craft::t('app', 'draft'),
]))
])))
->action('elements/save-draft')
->redirectUrl("{cpEditUrl}");
} else {
Expand Down Expand Up @@ -516,9 +516,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):

if ($canSaveCanonical) {
if ($isUnpublishedDraft) {
$response->addAltAction(Craft::t('app', 'Save {type}', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Save {type}', [
'type' => Craft::t('app', 'draft'),
]), [
])), [
'action' => 'elements/save-draft',
'redirect' => "$redirectUrl#",
'eventData' => ['autosave' => false],
Expand All @@ -532,9 +532,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
}

if ($canDeleteForSite) {
$response->addAltAction(Craft::t('app', 'Delete {type} for this site', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type} for this site', [
'type' => $isUnpublishedDraft ? Craft::t('app', 'draft') : $type,
]), [
])), [
'destructive' => true,
'action' => 'elements/delete-for-site',
'redirect' => "$redirectUrl#",
Expand All @@ -545,9 +545,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
}

if ($canDeleteCanonical) {
$response->addAltAction(Craft::t('app', 'Delete {type}', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type}', [
'type' => $isUnpublishedDraft ? Craft::t('app', 'draft') : $type,
]), [
])), [
'destructive' => true,
'action' => $isUnpublishedDraft ? 'elements/delete-draft' : 'elements/delete',
'redirect' => "$redirectUrl#",
Expand All @@ -558,19 +558,19 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
}
} elseif ($isDraft && $canDeleteDraft) {
if ($canDeleteForSite) {
$response->addAltAction(Craft::t('app', 'Delete {type} for this site', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type} for this site', [
'type' => Craft::t('app', 'draft'),
]), [
])), [
'destructive' => true,
'action' => 'elements/delete-for-site',
'redirect' => "$redirectUrl#",
'confirm' => Craft::t('app', 'Are you sure you want to delete the {type} for this site?', compact('type')),
]);
}

$response->addAltAction(Craft::t('app', 'Delete {type}', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type}', [
'type' => Craft::t('app', 'draft'),
]), [
])), [
'destructive' => true,
'action' => 'elements/delete-draft',
'redirect' => $canonical->getCpEditUrl(),
Expand Down Expand Up @@ -1150,9 +1150,9 @@ public function actionSave(): ?Response
}

if (!$success) {
return $this->_asFailure($element, Craft::t('app', 'Couldn’t save {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => $element::lowerDisplayName(),
]));
])));
}

$elementsService->trackActivity($element, ElementActivity::TYPE_SAVE);
Expand Down Expand Up @@ -1402,9 +1402,9 @@ public function actionSaveDraft(): ?Response
$element->setScenario(Element::SCENARIO_ESSENTIALS);

if (!$elementsService->saveElement($element)) {
return $this->_asFailure($element, Craft::t('app', 'Couldn’t save {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Craft::t('app', 'draft'),
]));
])));
}

$elementsService->trackActivity($element, ElementActivity::TYPE_SAVE);
Expand Down Expand Up @@ -1556,13 +1556,13 @@ public function actionApplyDraft(): ?Response
private function _asAppyDraftFailure(ElementInterface $element): ?Response
{
if ($element->getIsUnpublishedDraft()) {
$message = Craft::t('app', 'Couldn’t create {type}.', [
$message = StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => $element::lowerDisplayName(),
]);
]));
} elseif ($element->isProvisionalDraft) {
$message = Craft::t('app', 'Couldn’t save {type}.', [
$message = StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => $element::lowerDisplayName(),
]);
]));
} else {
$message = Craft::t('app', 'Couldn’t apply draft.');
}
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use craft\helpers\Cp;
use craft\helpers\DateTimeHelper;
use craft\helpers\ElementHelper;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\models\Section;
use craft\models\Section_SiteSettings;
Expand Down Expand Up @@ -177,9 +178,9 @@ public function actionCreate(?string $section = null): ?Response
DateTimeHelper::resume();

if (!$success) {
return $this->asModelFailure($entry, Craft::t('app', 'Couldn’t create {type}.', [
return $this->asModelFailure($entry, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => Entry::lowerDisplayName(),
]), 'entry');
])), 'entry');
}

// Set its position in the structure if a before/after param was passed
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/GlobalsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\elements\GlobalSet;
use craft\helpers\Cp;
use craft\helpers\Json;
use craft\helpers\StringHelper;
use craft\web\Controller;
use yii\web\BadRequestHttpException;
use yii\web\ForbiddenHttpException;
Expand Down Expand Up @@ -79,9 +80,9 @@ public function actionSaveSet(): ?Response

// Save it
if (!Craft::$app->getGlobals()->saveSet($globalSet)) {
$this->setFailFlash(Craft::t('app', 'Couldn’t save {type}.', [
$this->setFailFlash(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => GlobalSet::lowerDisplayName(),
]));
])));

// Send the global set back to the template
Craft::$app->getUrlManager()->setRouteParams([
Expand Down Expand Up @@ -221,9 +222,9 @@ public function actionSaveContent(): ?Response
$globalSet->setScenario(Element::SCENARIO_LIVE);

if (!Craft::$app->getElements()->saveElement($globalSet)) {
$this->setFailFlash(Craft::t('app', 'Couldn’t save {type}.', [
$this->setFailFlash(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => GlobalSet::lowerDisplayName(),
]));
])));

// Send the global set back to the template
Craft::$app->getUrlManager()->setRouteParams([
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/SystemSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use craft\helpers\ArrayHelper;
use craft\helpers\Component;
use craft\helpers\MailerHelper;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\mail\Mailer;
use craft\mail\transportadapters\BaseTransportAdapter;
Expand Down Expand Up @@ -259,9 +260,9 @@ public function actionGlobalSetIndex(): Response
],
],
'globalSets' => Craft::$app->getGlobals()->getAllSets(),
'buttonLabel' => Craft::t('app', 'New {type}', [
'buttonLabel' => StringHelper::upperCaseFirst(Craft::t('app', 'New {type}', [
'type' => GlobalSet::lowerDisplayName(),
]),
])),
]);
}

Expand Down
17 changes: 9 additions & 8 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use craft\helpers\Html;
use craft\helpers\Image;
use craft\helpers\Session;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\helpers\User as UserHelper;
use craft\i18n\Locale;
Expand Down Expand Up @@ -756,9 +757,9 @@ public function actionEnableUser(): ?Response
$user->archived = false;

if (!$elementsService->saveElement($user, false)) {
return $this->asFailure(Craft::t('app', 'Couldn’t save {type}.', [
return $this->asFailure(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => User::lowerDisplayName(),
]));
])));
}

return $this->asSuccess(Craft::t('app', '{type} saved.', [
Expand Down Expand Up @@ -815,9 +816,9 @@ public function actionIndex(?string $source = null): Response
$this->requirePermission('editUsers');
return $this->renderTemplate('users/_index.twig', [
'title' => Craft::t('app', 'Users'),
'buttonLabel' => Craft::t('app', 'New {type}', [
'buttonLabel' => StringHelper::upperCaseFirst(Craft::t('app', 'New {type}', [
'type' => User::lowerDisplayName(),
]),
])),
'source' => $source,
]);
}
Expand Down Expand Up @@ -1500,9 +1501,9 @@ public function actionSaveUser(): ?Response

return $this->asModelFailure(
$user,
Craft::t('app', 'Couldn’t save {type}.', [
StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => User::lowerDisplayName(),
]),
])),
$userVariable
);
}
Expand Down Expand Up @@ -2084,9 +2085,9 @@ public function actionSaveAddress(): ?Response
$address->setFieldValuesFromRequest($fieldsLocation);

if (!$elementsService->saveElement($address)) {
return $this->asModelFailure($address, Craft::t('app', 'Couldn’t save {type}.', [
return $this->asModelFailure($address, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Address::lowerDisplayName(),
]), 'address');
])), 'address');
}

return $this->asModelSuccess($address, Craft::t('app', '{type} saved.', [
Expand Down
4 changes: 2 additions & 2 deletions src/fields/BaseRelationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,9 @@ protected function settingsTemplateVariables(): array
'label' => Craft::t('app', 'Selectable {type} Condition', [
'type' => $elementType::pluralDisplayName(),
]),
'instructions' => Craft::t('app', 'Only allow {type} to be selected if they match the following rules:', [
'instructions' => StringHelper::upperCaseFirst(Craft::t('app', 'Only allow {type} to be selected if they match the following rules:', [
'type' => $elementType::pluralLowerDisplayName(),
]),
])),
]);
}

Expand Down
Loading

0 comments on commit 5755af3

Please sign in to comment.