Usually when people write programs, they write words that die in the program, such as: echo "Hello world!"; , if you want to change to the language of the country, write the internationalization of the program, it is necessary to open one by one to modify, the procedure is relatively short, if the program has tens of thousands or more, it is not so easy to change. Recently, with the gradual standardization of i18n, I also talk about how to achieve internationalization support in PHP. As with other programming languages, you can also use the GetText suite to write i18n programs in PHP to implement the NLS (Native Language Support) internationalization support, please refer to the official documentation (Http://www.gnu.org/manual/get text/index.html).
Implementation process: The Program designer writes the information to be displayed in the code, does not directly display the information that the programmer writes when running the program, but first goes to find a set of information file of the language family. If it is not found, the information in the code is displayed.
Installation Set GetText Kit:
1) *nix System:
1, from the http://www.gnu.org/software/gettext/gettext.html download GetText package, to install
2, compile PHP when adding "--with-gettext[=dir]", where DIR for GetText installed
Directory, defaults to:/usr/local
3, save, and then restart server.
2) WIN32 System:
1, need to copy the Gnu_gettext.dll file to the system directory (Ex:c:\winnt\system32 or C:\WINDOWS\SYSTEM32), PHP 4.2.3 file name after Libintl-1.dll, can be in the php4\ DLLs under the access.
2, open php.ini file, find Extension=php_gettext.dll, remove the front of the ";"
3, save, and then restart server.
If all goes well, you can see the word gettext in Phpinfo (), which is now set.
Second, the Php_gettext.dll kit has several functions, specifically see the relevant manual. Here we can just memorize 3 functions, as follows:
String Bindtextdomain (string domain, string directory)
String Textdomain (String text_domain)
String GetText (String message)