This is a discussion on Gettext in php within the PHP Programming forums, part of the Web Development category; Hi, This is new and very interesting topic. The gettext functions implement an NLS (Native Language Support) API which can ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi, This is new and very interesting topic. The gettext functions implement an NLS (Native Language Support) API which can be used to internationalize your PHP applications.
__________________ Regards, Senraj.A |
|
#2
| |||
| |||
| Hi, I am very new to this topic. can you give me in brief?
__________________ With, J. Jeyaseelan Everything Possible |
|
#3
| |||
| |||
| Hi, If want use gettext mean you must install gettext.please read below. To include GNU gettext support in your PHP build you must add the option --with-gettext[=DIR] where DIR is the gettext install directory, defaults to /usr/local.
__________________ Regards, Senraj.A Last edited by senraj : 05-06-2008 at 11:04 PM. |
|
#4
| |||
| |||
| Hi, Localizing PHP web sites using gettext Developing multi language web sites using PHP is actually very easy. A common approach is having an include file for every supported language which contains an array that maps string ids to localized text (for example "WelcomeText" => "Welcome to our homepage." would be included using something like <?= $strings["WelcomeText"] >). However there are several problems with this approach. First of all, when the application is updated and additional strings are added, there is no way to determine which new strings were added and if they are present in every language (unless you write a script for it). What happens if a newly added string is not yet translated into a specific language?
__________________ Regards, Senraj.A |
|
#5
| |||
| |||
| Hi, Using gettext with PHP A widely used framework for internationalization is gettext. It can be used with a variety of programming languages, including PHP. There are basically two ways to use gettext in your PHP applications. You can use the native gettext PHP extension or you can use a library implemented in PHP that does not need any extension, such as php-gettext.
__________________ Regards, Senraj.A |
|
#6
| |||
| |||
| Hi, Using gettext in your application Using gettext to get translated strings couldn't be easier. Just call gettext("Text to be translated") and you get a localized version of "Text to be translated" if available, or "Text to be translated" otherwise. If you're lazy, you can use _() instead of gettext(). Let's try this out. Create a new PHP file (we'll call it test.php), and insert the following code: PHP Code:
__________________ Regards, Senraj.A |
|
#7
| |||
| |||
| Hi, I think this extension has no configuration directives defined in php.ini and this extension has no resource types defined and this extension has no constants defined.
__________________ Regards, Senraj.A |
|
#8
| |||
| |||
| Hi, bind_textdomain_codeset Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. This bind_textdomain_codeset used to PHP 4 >= 4.2.0, PHP 5
__________________ Regards, Senraj.A |
|
#9
| |||
| |||
| Hi, The bindtextdomain() function sets the path for a domain. It returns the full pathname for the domain currently being set. bindtextdomain() example PHP Code: /usr/share/myapp/locale
__________________ Regards, Senraj.A |
|
#10
| |||
| |||
| Hi, ngettext() returns correct plural form of message identified by msgid1 and msgid2 for count n. Some languages have more than one form for plural messages dependent on the count. ngettext() example PHP Code: 1 2 5
__________________ Regards, Senraj.A |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Our Partners |