views:

35

answers:

2

I use gettext to translate my web site.

It would be nice to have link in text translated but I don't want to write html tags in gettext files because these translations may be used elsewhere.

I could create text for web site only (with links) and text for all purpose.
I'll have to maintain 2 versions. :-(

I could also write a custom parser to insert links in text but it seems overkill and I'm affraid of The Danger of Naïveté

For those who had the same problem, how did you handle that ?

A: 

I honestly wouldn't be too concerned about using some basic HTML (or use bbCode, textile, markdown, etc.) directly into your translation files. URL's might appear to be the only problem right now, but what about other text markup?

Not to mention that the URL's themselves could potentially be different depending on the language.

I do agree that translation files do have their issues though.

evolve
+1  A: 

I used to put links as parameters. Most of the time the whole <a> -tag is a parameter. Like Please see %s this link %s for more information. The first %s is passed the link tag, and the second one is passed the closing </a> tag.

Now I use only whole phrases as links when a link text must be translated. So we have just text like 'Please see this link for more information', get it translated and put the link tags around it. It's much easier to manage the translations, and you don't have a confused translator, or need to spend time explaining what you're trying to do.

jmz