What does "echo t(...)" mean inside the code?

Permalink 2 users found helpful
I was looking through some code inside a concrete5 theme and say this...

<span class="powered-by"><a href="http://www.concrete5.org" title="<?php echo t('concrete5 - open source content management system for PHP and MySQL')?>"><?php echo t('concrete5 - open source CMS')?></a></span>

What is the t() function that is echoed out?

I've never seen this t() function and in trying to Google it I came up with nothing.

Thanks in advance.


View Replies: View Best Answer
cgrauer replied on at Permalink Best Answer Reply
The t() function is the interface to localization. If localization is active, t() returns the translation of the phrase passed to it. The translated phrases are stored in a so called .mo file in the language directory. If no localization is active t() just returns the original phrase.
carlos123 replied on at Permalink Reply
Thanks cgrauer!

Is this t() function a C5 unique creation or is this a standard PHP function used for such in other places?

I see now why C5 used the t() function inside a PHP construct.

I couldn't understand why C5 just didn't get rid of the PHP construct altogether and just HTML code whatever it was trying to spit out with the t() function until I read your response.

cgrauer replied on at Permalink Reply
As far as I remember it's a common library for localization, but the t-function, using this library, is part of the c5 code... However, it works fine ;-)
Mnkras replied on at Permalink Reply
c5 uses gettext, normally its _('text'); but t() seems nicer :P