As reported here by @Chainy, the string $txt['package_will_fail_warning'] is "terrible" when it comes to translation.
The string is:
the %1$s may be $txt['package_install'], or $txt['package_uninstall'].
The two replacements may have to be translated differently, but the replacement at the moment is just one.
Option one would be to use two replacements %1$s and %2$s replaced with two different $txt like: $txt['package_install_1'], $txt['package_uninstall_1'] and $txt['package_install_2'] and $txt['package_uninstall_2'].
This is a solution, but is kind of inelegant to me.
Soooo... was thinking about a possible alternative:
so, the two strings would be already contained into the actual string and should be easier to translate (you see directly what you have to translate and what are the possible alternatives and you can adapt the translation) and much more flexible.
The code that would "pick" the correct choice could look like:
[...]
preg_replace('~\{([^|]*)\|([^}]*)\}~', $context['uninstalling'] ? '$2' : '$1', $txt['package_will_fail_warning'])
[...]
What would mean in terms of translating?
It would mean that the {|} remain, while the words inside are translated.
For example, in Italian that sentence would look something like:
or even:
So complete flexibility on how the string is translated.
Now, my opinion is biased (for me now that solution is the best thing after sliced bread), so it would be interesting have opinions from people that do translations.
What do you think?
Improvement?
Regression?
Do you prefer change the string?
Take in consideration this is an example and TBH I'm starting thinking that change the string would be the best option, tough this solution may help in several other places.