Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The "Other" option is not translatable. In src/Element/ElementBase.php, "Other" text is static instead of being added using the "t" function.
Instead of:
protected static function addOtherOption($options) {
$options['select_or_other'] = 'Other';
return $options;
}
it should be
protected static function addOtherOption($options) {
$options['select_or_other'] = t('Other');
return $options;
}
Comment | File | Size | Author |
---|---|---|---|
#17 | 2926786-17.patch | 3.3 KB | Takuma Shimabukuro |
#15 | 2926786-15.patch | 510 bytes | hmendes |
| |||
#8 | make_other_option_translatable-2926786-8.patch | 746 bytes | mariusilie |
#4 | make_other_option_translatable-2926786-4.patch | 466 bytes | mariusilie |
|
Comments
Comment #2
mariusilie CreditAttribution: mariusilie commentedComment #3
legolasboThanks for reporting the issue @mariusilie. Feel free to supply a patch for a quick resolution of the issue.
Comment #4
mariusilie CreditAttribution: mariusilie as a volunteer commentedI think this should do the trick.
Comment #5
legolasbo8.x-3.x is not being developed
Comment #6
mariusilie CreditAttribution: mariusilie as a volunteer commentedComment #7
legolasboSince this is part of a class it should use $this->t(). If $this->t() isn't available, the class should use StringTranslationTrait.
Comment #8
mariusilie CreditAttribution: mariusilie as a volunteer commentedSince this is an abstract class and
$this
can't be used, I had to use a TranslatableMarkup object as per StringTranslationTrait's documentation:Comment #9
legolasboYou should be able to do something like this:
And then $this->t() should become available.
Side note: The issue status should be 'Needs review" when an issue has a patch that needs review.
Comment #10
mariusilie CreditAttribution: mariusilie as a volunteer commentedI tried the exact thing but when I used
$this->t()
, I got an error:That's why I used a TranslatableMarkup object.
Comment #11
legolasboAllright, RTBC then.
Comment #13
mariusilie CreditAttribution: mariusilie as a volunteer commentedI think the test needs to be updated also. Looks like it checks for static "Other" string.
Comment #14
legolasboYou're right, the test does need updating :)
Comment #15
hmendes CreditAttribution: hmendes at CI&T commentedAdding a patch for the comment #13. The initial problem seems to be fixed on #2997264: Translation support for the "Other" option.
Comment #16
Takuma Shimabukuro CreditAttribution: Takuma Shimabukuro at CI&T commentedComment #17
Takuma Shimabukuro CreditAttribution: Takuma Shimabukuro at CI&T commentedHI, I reviewed #15's patch and it's looks fine, but i ran the phpcs command, it shows some errors so i fixed it and attached the new patch for someone can review
Comment #18
daften CreditAttribution: daften at Dropsolid commented@Takuma Can you open a new issue for coding standards next time. It becomes harder to evaluate functional changes if you mix them with coding standards that are not related to the functional change. I will evaluate it with the changes incorporated to not lose work this time. Thanks :)
Comment #20
daften CreditAttribution: daften at Dropsolid commentedCommited, thanks for the patch all!
Comment #21
daften CreditAttribution: daften at Dropsolid commented