Shadman
Shadman

Reputation: 775

Globalization and Localization in PHP by __() function

I am working on globalization and localization..

I got interesting thing in a blog that is __() function, and heared many of people utlizing this function for globalization.. I read its PHP built in function but some of people using this by including some objects files .. but havn't got actual solution for this ..

I test __() function first by write this:

<?php
echo __("some text");
?>

PHP gives me this error:

Fatal error: Call to undefined function __() in D:\wamp\www\test\globalization.php on line 3

then I used this with use_helper() function like this:

<?php
use_helper('I18N');
echo __("some text");
?>

but it gives error again ..

Fatal error: Call to undefined function use_helper() in D:\wamp\www\test\globalization.php on line 2

so basically; what I need to know is .. is there any simplest way for globalization and localization in PHP? and how above __() php function works .. what i need to include in this more?

Upvotes: 0

Views: 3176

Answers (2)

St. John Johnson
St. John Johnson

Reputation: 6660

This is only if you are using frameworks that implement this method: Wordpress, Kohana, etc. See this SO answer.

Upvotes: 2

deceze
deceze

Reputation: 521995

__() is not a function included in PHP. PHP has the _() function, which is an alias for gettext, which uses the Gettext system for localization. __() is a popular name for a localization helper, which a lot of frameworks use to implement their own localization function.

In other words: go with PHP's gettext functions, or roll your own.

Upvotes: 3

Related Questions