Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
CivicActions is reviewing and upgrading multiple modules for use on client sites. Part of this work is a coding standards review of internationalization handling of strings. Attached you will find a patch based on a review with the coder module and a careful examination of the code. Thanks!
The changes are all related to the handling of links in strings passed to t(). Currently you are using the format:
t('some text !link ', array('!link' => l('my link text', 'http://www.drupal.org'))),
However this doesn't give any context to the translator and the following format should be used instead:
t('some text <a href="@link">my link text</a> ', array('@link' => url('http://www.drupal.org'))),
Cheers,
Stella
Comment | File | Size | Author |
---|---|---|---|
#8 | cck_strong.patch | 3.33 KB | stella |
#6 | cck_url.patch | 4.37 KB | stella |
#2 | cck_i18n.patch | 4.88 KB | stella |
cck_i18n.patch | 4.87 KB | stella |
Comments
Comment #1
catchVery minor, but I'm not sure about:
Core tries to avoid backslashes within t() for clarity where possible. I think we can do this without damaging the wording too much, or even slightly improving it i.e.:
Comment #2
stella CreditAttribution: stella commentedI've attached another version of the patch - the only difference is the slight adjustment to the wording as proposed by catch.
Cheers,
Stella
Comment #3
catchThanks Stella. Either of the two patches should be RTBC depending on the wording you want to use.
Comment #4
KarenS CreditAttribution: KarenS commentedCommitted. Thanks!
Comment #5
hass CreditAttribution: hass commentedDoes this url() really makes sense?
url('http://www.drupal.org/projects/schema')
I would remove it... aside<b>
should be changed into STRONG. And i wouldn't write.</b>
-></b>.
might be better.Comment #6
stella CreditAttribution: stella commentedHere's a patch to fix the url() bit. I agree
<b>
tags should be changed to strong but it's not really an internationalization issue, so I've omitted that from this patch.Cheers,
Stella
Comment #7
hass CreditAttribution: hass commentedI know STRONG is not an i18n issue, but getting the strings STABLE is a real issue for translators. So better we get them permanently stable than changing every few weeks :-(.
Comment #8
stella CreditAttribution: stella commentedOk well here's a patch that just changes
<b>
to<strong>
.Comment #9
hass CreditAttribution: hass commentedThe url('http://www.drupal.org/project/devel') bugfix is missing :-)
Comment #10
stella CreditAttribution: stella commentedhass: they're two separate patches, by design. Both will need to be applied.
Comment #11
KarenS CreditAttribution: KarenS commentedCommitted.
Comment #12
stella CreditAttribution: stella commentedOne more thing which you already know, but just for completeness, running the "interface text translatability" coder review provided by the potx module highlights additional internationalization issues.
The problem for all of these are the same. The t() function is not intended for use on $variables, constants, strings that have already been passed through t() or strings which have variables concatenated onto them. Running t() on $variables also prevents these strings from being extracted by the potx module for translation. This is why the i18nstrings module provides the tt() module, which you should consider using instead. However, it's not an ideal solution, see http://groups.drupal.org/node/15177 for a discussion.
Cheers,
Stella
Comment #13
hass CreditAttribution: hass commented@Stella: Not every t'ified string using a variable is wrong. I know potx complains, but "all" this strings are somewhere else defined correctly and I'm not aware about a string that is not extracted with potx... have you found one that is untranslatable?
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.