There are a lot of lazy uses of %s in language strings passed through sprintf. For example this string was just merged
COM_TEMPLATES_COPY_CHILD_TEMPLATE_STYLES="%s, copy of %s"
The problem here is that both instances of %s are not the same
$styleName = Text::sprintf('COM_TEMPLATES_COPY_CHILD_TEMPLATE_STYLES', ucfirst($template->element . '_' . $newName), $style->title);
This string should have been "%1$s, copy of %2$s" otherwise it is not possible to translate the string correctly where the language uses a different order of parts.
Labels |
Added:
No Code Attached Yet
|
This convention is already used throughout joomla (with just a few exceptions hence this issue).
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-06-22 22:05:56 |
Closed_By | ⇒ | brianteeman |
I disagree on principle.
The positional format of sprint arguments, e.g.
%1$s
, must ONLY be used when a. an argument is used more than once; or b. an argument is no longer used but the code is not updated for legacy reasons (e.g. supporting old language files); or c. the code passes the arguments in a certain order but the language string author needs them in another.The canonical language of the Joomla CMS is “English (United Kingdom)”. Therefore the developers need to provide language files in this language and code which passes the arguments in the correct order for this argument.
When a translator needs to transpose the elements of the string in their own language's strings they can do so by employing the aforementioned format.
Example in English (United Kingdom) and Greek (Greece).
As a translator I chose to rephrase this to make it read better in Greek, putting the counters where they need to be. I could have also gone for the direct but uglier translation:
So, no, Brian. Not including the position arguments in the canonical string DOES NOT make it impossible to translate. It is still absolutely and perfectly possible. The translator CAN use the positional arguments wherever they need to. Please read https://www.php.net/sprintf