Problem/Motivation
When using the number field, eg. with the decimal formatter, and adding a prefix and suffix, the prefix and suffix do not get translated.
Proposed resolution
In code, the number.module uses the format_plural()-function to format multiple prefixes and suffixes. For single prefix/suffix, it simply returns the prefix/suffix value. There should be a t-function on that value.
Code in number.module, line 298:
Original code:
$prefix = (count($prefixes) > 1) ? format_plural($item['value'], $prefixes[0], $prefixes[1]) : $prefixes[0];
$suffix = (count($suffixes) > 1) ? format_plural($item['value'], $suffixes[0], $suffixes[1]) : $suffixes[0];
Code in attached patch:
$prefix = (count($prefixes) > 1) ? format_plural($item['value'], $prefixes[0], $prefixes[1]) : t($prefixes[0]);
$suffix = (count($suffixes) > 1) ? format_plural($item['value'], $suffixes[0], $suffixes[1]) : t($suffixes[0]);
Remaining tasks
Verify and commit patch to core dev-channel.
Comments
Comment #1
avr commentedRerolled for Drupal 8.
Comment #2
gábor hojtsyThe format_plural()'s presence in itself is a bug. User provided data should not be translated with t(), if you look at the field label, etc. are not translated either. See #1664272: Singular prefix/suffix on number field do not get translated. for removing the format_plural from there.
Comment #3
tim.plunkettI think you meant #1220964: Number field prefix/suffix get t()'ed through format_plural(), thanks for the information!
Comment #4
gábor hojtsyYes, that one, clipboard error :)