#1845546: Implement validation for the TypedData API introduces validation based upon the symfony validator for Drupal 8. For translation violation messages we need to extract the messages defined at the validation constraint classes, e.g.
class RangeConstraint extends Range {
public $minMessage = 'This value should be %limit or more.';
public $maxMessage = 'This value should be %limit or less.';
}
Those messages are defined on classes with the "Constraint" suffix and are always public properties that by convention end with the "Message" suffix or are it's a single public $message;
In addition to that there is format_plural() support which is special as it combines singular and plural forms in a single message, e.g.:
class LengthConstraint extends Length {
public $maxMessage = 'This value is too long. It should have %limit character or less.|This value is too long. It should have %limit characters or less.';
public $minMessage = 'This value is too short. It should have %limit character or more.|This value is too short. It should have %limit characters or more.';
public $exactMessage = 'This value should have exactly %limit character.|This value should have exactly %limit characters.';
}
Thus it uses the pattern $message = "singular|plural"; with "|" being a special delimiter here (introduced by symfony).
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff.txt | 1.18 KB | Gábor Hojtsy |
#15 | potx-constraint-1903362-15.patch | 4.91 KB | herom |
#15 | interdiff-1903362-10-15.txt | 411 bytes | herom |
#18 | potx-constraint-1903362-18.patch | 4.95 KB | herom |
#18 | interdiff-1903362-15-18.txt | 747 bytes | herom |
Comments
Comment #1
Gábor HojtsyThanks!
Comment #2
Gábor HojtsyRetitling.
Comment #3
Gábor HojtsyComment #4
Gábor HojtsyAlso tag with this unique tag for findability.
Comment #5
Gábor HojtsyComment #6
herom CreditAttribution: herom commentedI'll work on this.
Comment #7
herom CreditAttribution: herom commentedComment #8
herom CreditAttribution: herom commentedpatch added.
Comment #10
herom CreditAttribution: herom commentedfixing.
Comment #11
herom CreditAttribution: herom commentedComment #12
Gábor HojtsyThanks a lot for working on this, looks like good job! First of all this needs test coverage. Then some other minor things:
FALSE, TRUE :)
Seems like T_CONSTRAINT is something we made up :) I think we should name this something very specific to our situation, so we don't mix it up with the PHP built-in tokens.
Would be important to have a doc block for this explaining what this does, the structure it is looking for, etc. like other functions.
Comment #13
herom CreditAttribution: herom commentedpatch update.
Comment #15
herom CreditAttribution: herom commentedhow did that get there?
EDIT: I just realized the 10-15 interdiff is wrong. Instead, read the 10-13 interdiff, just without the strange "extends Range" that got in there.
Comment #16
herom CreditAttribution: herom commentedComment #18
herom CreditAttribution: herom commenteduhh. I failed at my own tests!
Comment #19
Gábor HojtsyYay, thanks again! I committed this patch with the attached minor changes :) Now to be ported to 7.x-2.x. (including the changes in the interdiff).
Comment #20
Gábor HojtsyThis change is now rolled out to localize.drupal.org! Reparssed 8.0-alpha3 with this. It did find constraint messages :) https://localize.drupal.org/translate/languages/hu/translate?sid=1864953
Comment #21
fagoAwesome!
Comment #21.0
fagoUpdated issue summary.
Comment #24
SebCorbin CreditAttribution: SebCorbin commentedPorted to 7.x-3.x as it has been branched directly from 6.x-3.x