John Smith
John Smith

Reputation: 283

How to do translation elegant?

We are currently working on a custom php framework, with multilanguage feature. So far its easy to handle translations, but now we have more complex messages with links. For example, this:

"hello user <a href="/register">register</a> here!"

could be translated with included HTML tags?

"fkds vkelip <a href="/register">regiximi</a> fácő ea!"

Or I should do this in 3 steps:

"hello user" -> translation
"register" -> translation
"here" -> translation

?

Upvotes: 1

Views: 93

Answers (3)

Igor Evstratov
Igor Evstratov

Reputation: 709

You should put all text into the translate function because it's the whole sentence:

__('hello user <a href="/register">register</a> here!');

Upvotes: 1

Rupesh Patel
Rupesh Patel

Reputation: 3065

you should use gettext function which handles all your translation requirements. as most of the current cms and framework does .

"<?=__('hello user')?> <a href="/register"><?=__('register')?></a> <?=__('here!')?>"

Upvotes: 1

xdazz
xdazz

Reputation: 160833

You could use gettext extension.

Upvotes: 5

Related Questions