__() in Symfony Framework for PHP

When you work in PHP Symfony, many are the chances to see a statement like this

<?php echo link_to(__(‘String title’), $internal_uri, array(‘target’ => ‘_blank’, ‘title’ => __(‘String title’)) );

Ok! lets not worry about $internal_uri here.

Leaving that out, take a closer look at the above statement. there is a link_to() function and its out put is echo’d . Other than that there is a weird __() thingy!

Does it look like a operator? NO! Its a function in symfony  that takes care of translation.

what does it translate?  The string you pass Eg: In the snippet, __() would look for translations of the string  ‘string title’

How? Refer to Using Dictionary files in http://symfony.com/legacy/doc/book/1_0/en/13-I18n-and-L10n

C ya :*


One thought on “__() in Symfony Framework for PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s