Skip to content

Commit

Permalink
Cleanup + release note
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 11, 2023
1 parent 6a4056a commit 2f360aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Release Notes for Craft Generator

## Unreleased
- Added `craft\generator\BaseGenerator::messageTwig()`. ([#25](https://github.com/craftcms/generator/pull/25))
- The plugin generator now ensures that the project’s `composer.json` file has `minimum-stability: dev` and `prefer-stable: true` set. ([#22](https://github.com/craftcms/generator/issues/22))
- Fixed a bug where the Service generator was suggesting adding a `config()` method which defined the service config, even when the target was a module. ([#24](https://github.com/craftcms/generator/issues/24))

Expand Down
7 changes: 4 additions & 3 deletions src/BaseGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ protected function namespacePath(string $namespace): string
protected function messagePhp(string $message): string
{
$messagePhp = var_export($message, true);
$category = $this->getTranslationCategory();
$category = $this->translationCategory();

return $category ? sprintf("Craft::t('%s', %s)", $category, $messagePhp) : $messagePhp;
}
Expand All @@ -745,11 +745,12 @@ protected function messagePhp(string $message): string
*
* @param string $message The string to output
* @return string Twig statement
* @since 1.6.0
*/
protected function messageTwig(string $message): string
{
$messageTwig = var_export($message, true);
$category = $this->getTranslationCategory();
$category = $this->translationCategory();

return $category ? sprintf("'%1\$s\'|t('%2\$s\', %1\$s)", $category, $messageTwig) : $messageTwig;
}
Expand All @@ -764,7 +765,7 @@ protected function messageTwig(string $message): string
*
* @return string|null Translation category handle
*/
protected function getTranslationCategory(): ?string
private function translationCategory(): ?string
{
return match (true) {
$this->module instanceof Application => 'app',
Expand Down

0 comments on commit 2f360aa

Please sign in to comment.