By mattyoung on
'You can now <a href="abc/def/ghi">change the settings</a>.'
the string should be properly translated, including "change the setting":
"You can now change the settings."
This version is no good:
t('You can now !link.', array('!link' => '<a href="abc/def/ghi">change the settings</a>');
because the string "change the settings" must to be translatable.
Or this:
t('You can now !open_tagchange the settings!close_tag', array('!open_tag' => '<a href="abc/def/ghi">', '!close_tag' => '</a>');
This is no good either because the translatable string is very confusing.
How do you do this?
Comments
Unless I am misunderstanding,
Unless I am misunderstanding, your best option is to use the l() function and a t() function with concatenation. Like this:
print t('You can now') . l('Change the settings', 'path/to/settings);Kenny S.
Follow me on Twitter
You misunderstand... ;)
A few problems with this:
a) you need
l(t('Change the settings'), 'path/to/settings')to make 'Change the settings' translatable, even if you use l().b) In a language that reads right to left ("RTL"), for example Arabic, this makes it impossible to translate correctly since you're forcing "you can now" to come to the left of "change the settings". You need the whole sentence in a single t() call to allow RTL languages to translate it.
So, you need the solution I provided in my other comment:
___________________
3281d Consulting
When in doubt, read the docs
http://api.drupal.org/api/function/t/6
Here is an example of t() used correctly:
___________________
3281d Consulting
The t() string: 'Go to the <a
The t() string:
will confuse my translator friend. They don't know HTML at all. So I will just edit the text to take out the HTML tags, send to translate. Then put the tags back.
Thank you very much.
Teach your friend
Core does it this way, so if you just try to hide this problem from your translator friend, it's just masking the problem. Instead, consider teaching your friend how to translate strings like this.
Alternatively, if you really must, you should do it like this:
but that's more clumsy for RTL languages, and it makes for shorter strings with less context to translate them...
___________________
3281d Consulting
Thanks for the replies to my
Thanks for the replies to my comment. Now I have a better understanding myself! I do love this community.
Kenny S.
Follow me on Twitter