Skip to content

Commit

Permalink
IBX-4922: [Product type] Missing translation for validation message f…
Browse files Browse the repository at this point in the history
…or identifier field and notification message (#691)
  • Loading branch information
GrabowskiM committed Feb 8, 2023
1 parent 4a64431 commit ef771fe
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@
<target>Personalization Access</target>
<note>key: policy.limitation.identifier.personalizationaccess</note>
</trans-unit>
<trans-unit id="9f2e53e094725bbc243ad777547724ab923a31d1" resname="policy.limitation.identifier.role">
<source>Role</source>
<target>Role</target>
<note>key: policy.limitation.identifier.role</note>
</trans-unit>
<trans-unit id="af73694f5c5e5868af7948fb04f0d6bfe7ee6ad4" resname="policy.limitation.identifier.producttype">
<source>Product Type</source>
<target>Product Type</target>
<note>key: policy.limitation.identifier.producttype</note>
</trans-unit>
<trans-unit id="9f2e53e094725bbc243ad777547724ab923a31d1" resname="policy.limitation.identifier.role">
<source>Role</source>
<target>Role</target>
<note>key: policy.limitation.identifier.role</note>
</trans-unit>
<trans-unit id="bb77b27363dad566197a200290f0f0b18baa4705" resname="policy.limitation.identifier.section">
<source>Section</source>
<target>Section</target>
Expand Down
10 changes: 10 additions & 0 deletions src/bundle/Resources/translations/validators.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<target state="new">Content Type identifier may only contain letters from "a" to "z", numbers and underscores.</target>
<note>key: ez.content_type.identifier.pattern</note>
</trans-unit>
<trans-unit id="e03cdf7df4e43a891269e0bbe734e7bab5cc61eb" resname="ez.content_type.identifier.unique">
<source>The Content Type identifier "%identifier%" is used by another Content Type. Enter a unique identifier.</source>
<target state="new">The Content Type identifier "%identifier%" is used by another Content Type. Enter a unique identifier.</target>
<note>key: ez.content_type.identifier.unique</note>
</trans-unit>
<trans-unit id="7ecfa6bd2c1993d18d067f3abe3acebeb9c2458c" resname="ez.content_type.names">
<source>Content Type name cannot be blank and cannot be longer than 255 characters.</source>
<target state="new">Content Type name cannot be blank and cannot be longer than 255 characters.</target>
Expand All @@ -26,6 +31,11 @@
<target state="new">Field definition description cannot be longer than 255 characters.</target>
<note>key: ez.field_definition.descriptions</note>
</trans-unit>
<trans-unit id="3c8e362f900d886ce75b34d0fd952128612a2b12" resname="ez.field_definition.identifier.unique">
<source>The Field definition identifier "%identifier%" is used by another Field definition. Enter a unique identifier.</source>
<target state="new">The Field definition identifier "%identifier%" is used by another Field definition. Enter a unique identifier.</target>
<note>key: ez.field_definition.identifier.unique</note>
</trans-unit>
<trans-unit id="0f7d936836760a506042c4d25cd38c5a30c3d9de" resname="ez.field_definition.names">
<source>Field definition name cannot be blank cannot be longer than 255 characters.</source>
<target state="new">Field definition name cannot be blank cannot be longer than 255 characters.</target>
Expand Down
15 changes: 14 additions & 1 deletion src/lib/Validator/Constraints/UniqueContentTypeIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*/
namespace Ibexa\AdminUi\Validator\Constraints;

use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Component\Validator\Constraint;

/**
* @Annotation
*/
class UniqueContentTypeIdentifier extends Constraint
class UniqueContentTypeIdentifier extends Constraint implements TranslationContainerInterface
{
/**
* %identifier% placeholder is passed.
Expand All @@ -20,6 +22,17 @@ class UniqueContentTypeIdentifier extends Constraint
*/
public $message = 'ez.content_type.identifier.unique';

/**
* @return array<\JMS\TranslationBundle\Model\Message>
*/
public static function getTranslationMessages(): array
{
return [
Message::create('ez.content_type.identifier.unique', 'validators')
->setDesc('The Content Type identifier "%identifier%" is used by another Content Type. Enter a unique identifier.'),
];
}

public function validatedBy()
{
return 'ezplatform.content_forms.validator.unique_content_type_identifier';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*/
namespace Ibexa\AdminUi\Validator\Constraints;

use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Component\Validator\Constraint;

/**
* @Annotation
*/
class UniqueFieldDefinitionIdentifier extends Constraint
class UniqueFieldDefinitionIdentifier extends Constraint implements TranslationContainerInterface
{
/**
* %identifier% placeholder is passed.
Expand All @@ -20,6 +22,17 @@ class UniqueFieldDefinitionIdentifier extends Constraint
*/
public $message = 'ez.field_definition.identifier.unique';

/**
* @return array<\JMS\TranslationBundle\Model\Message>
*/
public static function getTranslationMessages(): array
{
return [
Message::create('ez.field_definition.identifier.unique', 'validators')
->setDesc('The Field definition identifier "%identifier%" is used by another Field definition. Enter a unique identifier.'),
];
}

public function getTargets()
{
return self::CLASS_CONSTRAINT;
Expand Down

0 comments on commit ef771fe

Please sign in to comment.