Problem/Motivation
Follow-up to #2557113: Make t() return a TranslationWrapper object to remove reliance on a static, unpredictable safe list. Now that this is done TranslationWrapper
does not make much sense. Since it is no longer wrapping t() - t() is wrapping it :).
Proposed resolution
We should create a new TranslatedString
class and deprecate TranslationWrapper for Drupal 9.
Remaining tasks
Review & commit patch
User interface changes
None
API changes
API addition
Data model changes
None
Beta phase evaluation
Issue category | Task because just replacing a class and deprecating another one. |
---|---|
Issue priority | Major because followup to a critical which changes the meaning of the TranslationWrapper class |
Unfrozen changes | Unfrozen because it is a followup to a critical was is only separated to keep scope sane. |
Disruption | Not disruptive TranslationWrapper will extend TranslatedString and it will be deprecated. |
Comment | File | Size | Author |
---|---|---|---|
#28 | interdiff.txt | 6.15 KB | mr.baileys |
#28 | 2569069-28-rename-translation-wrapper.patch | 84.4 KB | mr.baileys |
#24 | 2569069-24-rename-translation-wrapper.patch | 83.79 KB | mr.baileys |
#22 | 2569069-22-rename-translation-wrapper.patch | 83.71 KB | mr.baileys |
| |||
#6 | 2569069-5.patch | 73.98 KB | stefan.r |
Comments
Comment #2
alexpottComment #3
alexpottComment #4
stefan.r CreditAttribution: stefan.r commentedComment #5
stefan.r CreditAttribution: stefan.r commentedComment #6
stefan.r CreditAttribution: stefan.r commentedComment #7
stefan.r CreditAttribution: stefan.r commentedCR: https://www.drupal.org/node/2571255
Comment #8
stefan.r CreditAttribution: stefan.r commentedComment #11
stefan.r CreditAttribution: stefan.r commentedCannot reproduce this failure locally :/
Comment #12
stefan.r CreditAttribution: stefan.r commentedComment #13
lauriiiHmm, has there been discussion somewhere about the name TranslatedString or should we include that in this issue?
Comment #14
stefan.r CreditAttribution: stefan.r commented@lauriii I had added it in the parent after @dawehner or @alexpott's suggestion and @joelpittet +1ed, but then took it out so it could be its own issue.
TranslatedString or TranslatableString works for me, considering we already have SafeString as well and we may have more *String classes later on
Comment #15
lauriiiBut isn't that more like a TranslatableString because on string will be only translated when its actually being printed? So its not always necessarily translated.
Comment #16
stefan.r CreditAttribution: stefan.r commentedYes, if I had to pick between the two I'd go with that as well.
Comment #17
alexpottWell it always translated when you print it but I guess TranslatableString is more correct so let's do that.
Comment #18
lauriiiYeah TranslatedString is super confusing when creating new instance
Comment #19
alexpottComment #20
alexpottLet's also fix the param name on
TranslationInterface::translateString()
The param should be
$translatable_string
Comment #21
mr.baileysWorking on this.
Comment #22
mr.baileys* Now using TranslatableString instead of TranslatedString
* No interdiff since that doesn't make sense in this case
* Also manually renamed TranslationWrapper to TranslatableString in "core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php" (both class names have the same string lenght and are essentially the same object, so I'm assuming this is won't screw up the serialized data).
Comment #24
mr.baileysPatch didn't apply since
core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php
is a binary file, and the patch was created without the--binary
flag.Comment #26
cpj CreditAttribution: cpj commentedI've reviewed the changes and it looks fine to me. So I'm going to mark it RTBC
Comment #27
stefan.r CreditAttribution: stefan.r commentedtranslatedString
getUntranslatedString
Comment #28
mr.baileysThx, fixed.
Comment #30
lauriiiWhat is this change?
Comment #31
mr.baileys@lauriii
/fixtures/update/drupal-8.language-enabled.php
contains a couple of references to TranslationWrapper that have been renamed to TranslatableString. The file is marked as binary though (contains null bytes in an otherwise plain-text file), hence the strange output in the patch.Comment #32
mr.baileysComment #33
stefan.r CreditAttribution: stefan.r commentedPatch looks good to me! The change in fixtures/update/drupal-8.language-enabled.php shouldn't technically be needed, but if tests are green it's fine to keep anyway.
Comment #34
lauriiiLooked the changes inside the fixtures/update/drupal-8.language-enabled.php and there actually is something about the TranslationWrapper so it makes sense. DrupalCI is green so RTBC!
Comment #35
alexpottA simple rename leaving the original class as a deprecated BC later. Looks great. Committed 5c943b5 and pushed to 8.0.x. Thanks!
Comment #37
stefan.r CreditAttribution: stefan.r commentedPublished the CR at https://www.drupal.org/node/2571255
Comment #39
lauriiiComment #41
Gábor HojtsyNot sure how this lost all its tags in #4, restoring :)