What's new

How to include GNU gettext support in your PHP build

jay41

Forum Veteran
Joined
Nov 13, 2016
Posts
1,930
Reaction
473
Points
660
Age
24
How to include GNU gettext support in your PHP build
 
In order to include GNU gettext support in your PHP build, you will need to follow these steps:

1. Install the gettext library on your system. This library provides the necessary tools for translating messages in your PHP application. The installation process will vary depending on your operating system, but on most Linux distributions, you can install gettext with the following command:

Code:
   sudo apt-get install gettext

2. Download the PHP source code from the official website. You can download the latest version of PHP from You do not have permission to view the full content of this post. Log in or register now..

3. Extract the source code to a directory of your choice.

4. Navigate to the directory containing the PHP source code and run the following command:

Code:
   ./configure --with-gettext

This will configure PHP to include support for the gettext library.

5. Run make to compile PHP with the gettext support enabled.

6. Once PHP has been compiled, you can verify that gettext support is enabled by running the following command:

Code:
   php -i | grep gettext

This should display information about the gettext extension, including the version number and any configuration options.

7. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
   echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.
 
In order to include GNU gettext support in your PHP build, you will need to follow these steps:

1. Install the gettext library on your system. This library provides the necessary tools for translating messages in your PHP application. The installation process will vary depending on your operating system, but on most Linux distributions, you can install gettext with the following command:

Code:
   sudo apt-get install gettext

2. Download the PHP source code from the official website. You can download the latest version of PHP from You do not have permission to view the full content of this post. Log in or register now..

3. Extract the source code to a directory of your choice.

4. Navigate to the directory containing the PHP source code and run the following command:

Code:
   ./configure --with-gettext

This will configure PHP to include support for the gettext library.

5. Run make to compile PHP with the gettext support enabled.

6. Once PHP has been compiled, you can verify that gettext support is enabled by running the following command:

Code:
   php -i | grep gettext

This should display information about the gettext extension, including the version number and any configuration options.

7. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
   echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.
im using windows
 
im using windows
To include GNU gettext support in PHP on Windows, you will need to follow these steps:

1. Download the latest version of PHP for Windows from the official website at You do not have permission to view the full content of this post. Log in or register now..

2. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the PHP installation directory.

3. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

4. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

5. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

6. Copy the intl.dll file from the gettext installation directory to the ext directory in the PHP installation directory.

7. Open the php.ini file in the PHP installation directory using a text editor.

8. Find the line that says ;extension=php_gettext.dll and remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to say extension=php_gettext.dll.

10. Save and close the php.ini file.

11. Restart the web server or PHP-FPM service.

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
 
To include GNU gettext support in PHP on Windows, you will need to follow these steps:

1. Download the latest version of PHP for Windows from the official website at You do not have permission to view the full content of this post. Log in or register now..

2. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the PHP installation directory.

3. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

4. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

5. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

6. Copy the intl.dll file from the gettext installation directory to the ext directory in the PHP installation directory.

7. Open the php.ini file in the PHP installation directory using a text editor.

8. Find the line that says ;extension=php_gettext.dll and remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to say extension=php_gettext.dll.

10. Save and close the php.ini file.

11. Restart the web server or PHP-FPM service.

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
How to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly
 
How to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly
To adjust the system PATH variable to include the bin directory of the gettext installation directory, you need to follow these steps:

1. Open the Start menu and search for "Environment Variables" and select "Edit the system environment variables".

2. In the System Properties window, click on the "Environment Variables" button.

3. In the Environment Variables window, scroll down to the "System variables" section and find the "Path" variable.

4. Select the "Path" variable and click on the "Edit" button.

5. In the Edit Environment Variable window, click on the "New" button and add the full path to the "bin" directory of the gettext installation directory. For example, if the gettext installation directory is located at "C:\gettext", the full path to the "bin" directory would be "C:\gettext\bin".

6. Click on "OK" to close all the windows and save the changes.

7. Restart the web server or PHP-FPM service to apply the changes.

After performing these steps, the system PATH variable should now include the bin directory of the gettext installation directory, and the gettext functions should work properly in your PHP application.
 
To include GNU gettext support in PHP on Windows, you will need to follow these steps:

1. Download the latest version of PHP for Windows from the official website at You do not have permission to view the full content of this post. Log in or register now..

2. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the PHP installation directory.

3. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

4. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

5. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

6. Copy the intl.dll file from the gettext installation directory to the ext directory in the PHP installation directory.

7. Open the php.ini file in the PHP installation directory using a text editor.

8. Find the line that says ;extension=php_gettext.dll and remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to say extension=php_gettext.dll.

10. Save and close the php.ini file.

11. Restart the web server or PHP-FPM service.

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
i cant find the libintl.dll. did you mean libintl-8.dll?
 
i cant find the libintl.dll. did you mean libintl-8.dll?
Yes, that may be the case. The gettext library has undergone several changes over the years, and the specific naming conventions of the DLLs may vary depending on the version of the library you have installed.

If you cannot find the file named libintl.dll, try renaming libintl-8.dll to intl.dll instead, and copy it to the ext directory in your PHP installation directory as described in step 6 of the previous instructions.

Alternatively, you can search for the appropriate DLL file in the gettext installation directory, which may have a different name depending on the library version and the installation options.
 
To include GNU gettext support in PHP on Windows, you will need to follow these steps:

1. Download the latest version of PHP for Windows from the official website at You do not have permission to view the full content of this post. Log in or register now..

2. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the PHP installation directory.

3. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

4. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

5. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

6. Copy the intl.dll file from the gettext installation directory to the ext directory in the PHP installation directory.

7. Open the php.ini file in the PHP installation directory using a text editor.

8. Find the line that says ;extension=php_gettext.dll and remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to say extension=php_gettext.dll.

10. Save and close the php.ini file.

11. Restart the web server or PHP-FPM service.

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
i am using wamp64 how to add gnu get text support
 
i am using wamp64 how to add gnu get text support
To add GNU gettext support to WampServer, you will need to follow these steps:

1. Open your WampServer installation folder and navigate to the PHP version you are using. This is usually located at "wamp64\bin\php\phpX.Y.Z".

2. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

3. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

4. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

5. Copy the intl.dll file from the gettext installation directory to the ext directory in your PHP version directory.

6. Open the php.ini file in a text editor.

7. Search for the line that looks like this: ;extension=php_gettext.dll

8. Remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to read: extension=php_gettext.dll

10. Save and close the php.ini file.

11. Restart the WampServer services (Apache and PHP).

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
 
To add GNU gettext support to WampServer, you will need to follow these steps:

1. Open your WampServer installation folder and navigate to the PHP version you are using. This is usually located at "wamp64\bin\php\phpX.Y.Z".

2. Download the gettext binaries for Windows from the GNU gettext website at You do not have permission to view the full content of this post. Log in or register now.. You will need to download the 32-bit or 64-bit version depending on your system architecture.

3. Extract the downloaded ZIP file to a directory of your choice. We will call this directory the gettext installation directory.

4. Rename the file named libintl.dll in the gettext installation directory to intl.dll.

5. Copy the intl.dll file from the gettext installation directory to the ext directory in your PHP version directory.

6. Open the php.ini file in a text editor.

7. Search for the line that looks like this: ;extension=php_gettext.dll

8. Remove the semicolon at the beginning of the line to uncomment it.

9. Change the line to read: extension=php_gettext.dll

10. Save and close the php.ini file.

11. Restart the WampServer services (Apache and PHP).

12. You can now use gettext functions in your PHP application to translate messages. For example, you can use the gettext() function to retrieve a translated string from a message catalog:

Code:
   $translated = gettext("Hello, world!");
    echo $translated;

This will output the translated version of the string "Hello, world!" if it is available in the message catalog for the current language.

Note that you may need to adjust the system PATH variable to include the bin directory of the gettext installation directory in order for gettext to work properly.
i did all your instructions. Is there anything need to setup and configure to run gettext on windows using wamp64?
 
Yes, that may be the case. The gettext library has undergone several changes over the years, and the specific naming conventions of the DLLs may vary depending on the version of the library you have installed.

If you cannot find the file named libintl.dll, try renaming libintl-8.dll to intl.dll instead, and copy it to the ext directory in your PHP installation directory as described in step 6 of the previous instructions.

Alternatively, you can search for the appropriate DLL file in the gettext installation directory, which may have a different name depending on the library version and the installation options.
i did all your instructions. Is there anything need to setup and configure to run gettext on windows using wamp64?
 
i did all your instructions. Is there anything need to setup and configure to run gettext on windows using wamp64?
Once you have followed the steps to add GNU gettext support to WampServer and have installed the gettext binaries and copied the appropriate files, you should be able to use gettext in your PHP code without any additional configuration.

However, if you encounter any issues
 
Once you have followed the steps to add GNU gettext support to WampServer and have installed the gettext binaries and copied the appropriate files, you should be able to use gettext in your PHP code without any additional configuration.

However, if you encounter any issues
"--with-gettext[=DIR] where DIR is the gettext install directory" how to execute this in windows
 
"--with-gettext[=DIR] where DIR is the gettext install directory" how to execute this in windows
The "--with-gettext[=DIR]" option is a configure option that is used when compiling PHP from source code, and it is not used in the installation of pre-compiled PHP binaries on Windows.

If you are using a pre-compiled PHP binary, you do not need to use this option. You can simply follow the steps I provided earlier to add GNU gettext support to WampServer or your PHP installation.

If you need to compile PHP from source code in the future and you want to include support for gettext, you can use the "--with-gettext[=DIR]" option to specify the location of the gettext library and headers during the configure step. Note that you will need to have the gettext library and headers installed on your system before compiling PHP.

To execute this command in Windows, you can use the Command Prompt or PowerShell to navigate to the PHP source code directory and run the configure command with the appropriate options. For example:

Code:
C:\php-source> configure --with-gettext=C:\gettext

This would configure PHP to use the gettext library installed in the "C:\gettext" directory.
 
Back
Top