0

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?

Shadman
  • 755
  • 2
  • 11
  • 19

2 Answers2

3

__() 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.

deceze
  • 510,633
  • 85
  • 743
  • 889
2

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

Community
  • 1
  • 1
St. John Johnson
  • 6,590
  • 7
  • 35
  • 56