This is an offshoot of #997884: t() documentation overhaul
Basically, the problem is that as things are currently in Drupal 7, some of the UI text we have in Drupal Core is difficult to translate. The reason is that we are using too much variable substitution. This example from dashboard.module will illustrate the problem.
'description' => t('Customizing the dashboard requires the !permission-name permission.', array(
'!permission-name' => l(t('Administer blocks'), 'admin/people/permissions', array('fragment' => 'module-block')),
The problem here is that the text "Administer blocks" is taken out of the string, and the person attempting to translate the string
"Customizing the dashboard requires the !permission-name permission."
might have to use different words for "the" and maybe other things (depending on the language), depending on what the text in !permission name is. For instance, according to kiamlaluno (posted on that other issue, comment #25), if the permission name was Administer Blocks, it would translate in Greek to
Προσαρμογή του ταμπλό απαιτεί την άδεια διαχείριση μπλοκ.
And if the permission name was Create new book pages, it would be
Προσαρμογή του ταμπλό απαιτεί τη Δημιουργία νέας άδειας βιβλίο σελίδες.
So the "the" is either την or τη depending on the first letter of the permission. This kind of thing also happens in Spanish, French, and other languages, and certainly some other languages have even more complicated things happening than just picking a version of "the" to use. Even in English, we use "a" before a consonant and "an" before a vowel, so you can see why something like this could be important.
I will note that the reason these strings were done this way was in an attempt to make sure that the permission name "Administer blocks" was translated the same way everywhere it occurs on the site. But given that it screws up the ability to translate the longer text, we can't do this.
So for cases like this where a variable substitution is being used but the text doesn't vary (it is always "Administer blocks" in this case), it should not be pulled out into a variable. We will still need to continue to use variables for cases where we're substituting in something that is really variable, like a user name, and there is no way around it, even though those may also have translation problems.
So this example should be doing:
'description' => t('Customizing the dashboard requires the <a href="!permission-url">Administer blocks</a> permission.', array(
'!permission-url' => url('admin/people/permissions', array('fragment' => 'module-block')),
There are many other similar spots in Core that need to be fixed. This should really be done for D7, but so many strings would need to be changed that I'm filing it against D8 instead.
Comments
Comment #3
jhodgdonThere is still a link left to this spam tag above. Is there some way that can be removed?
Comment #5
apadernoThe problem is also for languages where the article is appended to the substantive, and the postfix part depends from the word, which is what happen in Swedish.
For example, the Swedish word for apple is äpple, but "the apple is red" is translated with äpplet är rött (litterally, "apple-the is red").
The problem in this case is that %permission-name could be a single word, and in that case the definitive article is translated with a postfix that changes basing on the word to which the article is added, or it is a quote, or a phrase that works as noun.
With Italian, the problem would not be with the sentence taken as example, where "the %permission-name permission" would be translated with il permesso %permission-name. Still, there would be a problem with "the %object-name," as in Italian there isn't just a definite article, but 6 (il, lo, la, i, gli, le).
For this case, the only workaround I can think of is to avoid using the article before a placeholder. If the sentence would be "Customizing the dashboard requires the right permission (%permission-name)." the problem would be resolved.
Comment #12
apadernoComment #18
catchThis issue was opened ten years ago, we don't have the string in the issue summary in core any more, and a lot of other strings have been overhauled. Going to go ahead and close this out without extant examples to refer to.
The proper way to add links to strings is already documented at https://www.drupal.org/docs/7/api/localization-api/dynamic-or-static-lin... and elsewhere.
Comment #19
catch