From 193af45ecd49ff91b0916bb8bc42a6ca2c971ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Tue, 14 Feb 2023 14:37:56 +0100 Subject: [PATCH 1/2] fixed generation of translations by adding support for domains to be set as constants --- .../src/Component/Translation/PhpParserNodeHelper.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Component/Translation/PhpParserNodeHelper.php b/packages/framework/src/Component/Translation/PhpParserNodeHelper.php index 8121d9b9bf5..cca8b8ddb6e 100644 --- a/packages/framework/src/Component/Translation/PhpParserNodeHelper.php +++ b/packages/framework/src/Component/Translation/PhpParserNodeHelper.php @@ -4,12 +4,15 @@ use PhpParser\Node; use PhpParser\Node\Expr\BinaryOp\Concat; +use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Scalar\String_; use Shopsys\FrameworkBundle\Component\Translation\Exception\StringValueUnextractableException; use SplFileInfo; class PhpParserNodeHelper { + protected const TRANSLATOR_CLASS_FQN = '\Shopsys\FrameworkBundle\Component\Translation\Translator'; + /** * @param \PhpParser\Node $node * @param \SplFileInfo $fileInfo @@ -28,10 +31,15 @@ public static function getConcatenatedStringValue(Node $node, SplFileInfo $fileI ); } + if ($node instanceof ClassConstFetch && $node->class->parts[0] === 'Translator') { + return constant(static::TRANSLATOR_CLASS_FQN . '::' . $node->name->name); + } + throw new StringValueUnextractableException( sprintf( - 'Can only extract the message ID or message domain from a scalar or concatenated string,' + 'Can only extract the message ID or message domain from a scalar, concatenated string or "%s" class constant,' . ' but got "%s". Please refactor your code to make it extractable (in %s on line %d).', + static::TRANSLATOR_CLASS_FQN, get_class($node), $fileInfo, $node->getLine() From ffa43a8ab47749a13fbf2d2fcd21340bfd71a267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Tue, 14 Feb 2023 14:39:34 +0100 Subject: [PATCH 2/2] dumped missing translations --- packages/framework/src/Resources/translations/messages.cs.po | 3 +++ packages/framework/src/Resources/translations/messages.en.po | 3 +++ packages/framework/src/Resources/translations/validators.cs.po | 3 +++ packages/framework/src/Resources/translations/validators.en.po | 3 +++ project-base/translations/validators.cs.po | 3 --- project-base/translations/validators.en.po | 3 --- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/framework/src/Resources/translations/messages.cs.po b/packages/framework/src/Resources/translations/messages.cs.po index eb5057a1949..3e03b7715a7 100644 --- a/packages/framework/src/Resources/translations/messages.cs.po +++ b/packages/framework/src/Resources/translations/messages.cs.po @@ -547,6 +547,9 @@ msgstr "Vytvořeno administrátorem" msgid "Created on" msgstr "Vytvořeno dne" +msgid "Creation date" +msgstr "Datum vytvoření" + msgid "Cron overview" msgstr "Přehled cronů" diff --git a/packages/framework/src/Resources/translations/messages.en.po b/packages/framework/src/Resources/translations/messages.en.po index 2dcda25bf4a..84fc76c527e 100644 --- a/packages/framework/src/Resources/translations/messages.en.po +++ b/packages/framework/src/Resources/translations/messages.en.po @@ -547,6 +547,9 @@ msgstr "" msgid "Created on" msgstr "" +msgid "Creation date" +msgstr "" + msgid "Cron overview" msgstr "" diff --git a/packages/framework/src/Resources/translations/validators.cs.po b/packages/framework/src/Resources/translations/validators.cs.po index 36e3dffbb67..94eb6d7d2bf 100644 --- a/packages/framework/src/Resources/translations/validators.cs.po +++ b/packages/framework/src/Resources/translations/validators.cs.po @@ -226,6 +226,9 @@ msgstr "Vyplňte prosím kurz měny" msgid "Please enter currency minimum fraction digits" msgstr "Prosím zadejte minimální počet desetinných míst měny" +msgid "Please enter date of creation" +msgstr "Vyplňte prosím datum vytvoření" + msgid "Please enter default VAT" msgstr "Prosím zadejte výchozí výši DPH" diff --git a/packages/framework/src/Resources/translations/validators.en.po b/packages/framework/src/Resources/translations/validators.en.po index a7b11b7746a..973171f460e 100644 --- a/packages/framework/src/Resources/translations/validators.en.po +++ b/packages/framework/src/Resources/translations/validators.en.po @@ -226,6 +226,9 @@ msgstr "" msgid "Please enter currency minimum fraction digits" msgstr "" +msgid "Please enter date of creation" +msgstr "" + msgid "Please enter default VAT" msgstr "" diff --git a/project-base/translations/validators.cs.po b/project-base/translations/validators.cs.po index 05555e22ae7..b62d937e266 100644 --- a/project-base/translations/validators.cs.po +++ b/project-base/translations/validators.cs.po @@ -61,9 +61,6 @@ msgstr "Vyplňte prosím název firmy" msgid "Please enter content" msgstr "Vyplňte prosím text" -msgid "Please enter date of creation" -msgstr "Vyplňte prosím datum vytvoření" - msgid "Please enter email" msgstr "Vyplňte prosím e-mail" diff --git a/project-base/translations/validators.en.po b/project-base/translations/validators.en.po index f74c9de20aa..36228052553 100644 --- a/project-base/translations/validators.en.po +++ b/project-base/translations/validators.en.po @@ -61,9 +61,6 @@ msgstr "" msgid "Please enter content" msgstr "" -msgid "Please enter date of creation" -msgstr "" - msgid "Please enter email" msgstr ""