Problem/Motivation

#2454859: Not possible to format plural an already translated string introduced TranslationInterface::formatPluralTranslated and StringTranslationTrait::formatPluralTranslated
#2570107: Make format_plural() return a PluralTranslatableString object to remove reliance on a static, unpredictable safe list removed TranslationInterface::formatPluralTranslated but not StringTranslationTrait::formatPluralTranslated

So, as StringTranslationTrait is widely used in Core, there is a risk that someone tries to use that function that obviously throws a Fatal.

Proposed resolution

Remove StringTranslationTrait::formatPluralTranslated

Remaining tasks

Patch, Review, Commit.

User interface changes

None.

API changes

StringTranslationTrait::formatPluralTranslated will not exist anymore.

Data model changes

None.

RC target triage

That change only removes unused code that would throw a fatal if used by a contrib module. That change is only about code cleanup and is not disruptive at all.

CommentFileSizeAuthor
#2 2584797-2.patch1 KBduaelfr

Comments

DuaelFr created an issue. See original summary.

duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Active » Needs review
StatusFileSize
new1 KB
dawehner’s picture

Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community

Good catch, but by far this is not major.

duaelfr’s picture

Issue summary: View changes
Issue tags: +rc target triage
jhodgdon’s picture

This needs an update to the change record at least, or perhaps a new one.

duaelfr’s picture

Here is the closest existing change record I found : https://www.drupal.org/node/2571563
I'm not sure it needs to be updated as it's clearly explaining that this method should not be used anymore.

jhodgdon’s picture

Yeah, that's probably OK. Thanks for the research!

gábor hojtsy’s picture

Issue tags: +D8MI, +language-ui, +sprint

Yeah looks like this is dead code that was not removed recently. From the change notice at https://www.drupal.org/node/2571563 linked by @DuaelFr:

Previously plural strings could be created from previously translated strings (such as those from config) using TranslationInterface::formatPluralTranslated(). This has been replaced by using the PluralTranslatableMarkup::createFromTranslatedString() static method.

gábor hojtsy’s picture

Priority: Normal » Major
alexpott’s picture

Issue tags: -rc target triage +rc target

Discussed with @effulgentsia we agree that this is an RC target. It is dead and broken code. The replacement for this is PluralTranslatableMarkup::createFromTranslatedString(). The issue that introduced this was among the last to be committed during beta and therefore I think it is acceptable to remove during RC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Less confusing methods added by StringTranslationTrait - nice. Committed 19adf84 and pushed to 8.0.x. Thanks!

  • alexpott committed 19adf84 on 8.0.x
    Issue #2584797 by DuaelFr: \Drupal\Core\StringTranslation\...
gábor hojtsy’s picture

Issue tags: -sprint

Yay!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.