Title: gettext
Published: April 25, 2014
Last modified: August 20, 2026

---

# apply_filters( ‘gettext’, string $translation, string $text, string $domain )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#wp--skip-link--target)

Filters text with its translation.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#parameters)󠁿

 `$translation`string

Translated text.

`$text`string

Text to translate.

`$domain`string

Text domain. Unique identifier for retrieving translated strings.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#more-information)󠁿

This filter hook is applied to the translated text by the internationalization functions(`
[__()](https://developer.wordpress.org/reference/functions/__/)`, `[_e()](https://developer.wordpress.org/reference/functions/_e/)`,
etc.).

**IMPORTANT:** This filter is always applied even if internationalization is not
in effect, and if the text domain has not been loaded. If there are functions hooked
to this filter, they will always run. This could lead to a performance problem.

For singular/plural aware translation functions such as `[_n()](https://developer.wordpress.org/reference/functions/_n/)`,
see `[ngettext()](https://developer.wordpress.org/reference/hooks/ngettext/)`.

For context-specific translation functions such as `[_x()](https://developer.wordpress.org/reference/functions/_x/)`,
see filter hook [`gettext_with_context()`](https://developer.wordpress.org/reference/hooks/gettext_with_context/)
and `[ngettext_with_context()](https://developer.wordpress.org/reference/hooks/ngettext_with_context/)`.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#source)󠁿

    ```php
    $translation = apply_filters( 'gettext', $translation, $text, $domain );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/l10n.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/l10n.php#L207)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/l10n.php#L207-L207)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#related)󠁿

| Used by | Description | 
| [translate()](https://developer.wordpress.org/reference/functions/translate/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.11](https://developer.wordpress.org/reference/since/2.0.11/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 8 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-5073)
 2.    [rochow](https://profiles.wordpress.org/rochow/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-5073)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5073)
     Vote results for this note: 11[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5073)
 4.  This filter is ideally avoided as the performance aspect can be huge. If you do
     need it, be aware with a common suite of plugins installed this can easily run
     _thousands_ of times on one page! WooCommerce and similar make everything translatable.
 5.  It’s far improved to check the domain right away and return the translation instantly
     if it’s not the domain you’re wanting to translate. This minimises the overhead,
     rather than some of these examples that are running str_replace(), [is_single()](https://developer.wordpress.org/reference/functions/is_single/)
     etc over and over unnecessarily which adds up due to the sheer quantity of times
     this code will run.
 6.      ```php
         add_filter( 'gettext', 'wpdocs_translate_text', 10, 3 );
         function wpdocs_translate_text( $translated_text, $untranslated_text, $domain ) {
         	if ( 'blah' !== $domain ) {
         		return $translated_text;
         	}
     
         	// Now do your checking for your string within the 'blah' domain
         }
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D5073%23feedback-editor-5073)
 8.   [Skip to note 9 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-3441)
 9.    [Abdul Wahab](https://profiles.wordpress.org/abdulwahab610/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-3441)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3441)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3441)
 11. Change the “Register” text on the WordPress default login page.
 12.     ```php
         add_action( 'login_head', 'default_login_page_head' );
     
         /**
          * Customise the login form using login_head.
          */
         function default_login_page_head() {
         	add_filter( 'gettext', 'change_login_form_register_keyword');
         }
         /**
           * Change Register text from the bottom of login form.
           *
           * @param $text string 
           * @return $text string
           * * * * * * * * * * * * * * * * * * */
         function change_login_form_register_keyword( $text ) {
     
         	$text = str_ireplace( 'Register',  'Sign Up',  $text );
             return $text;
         }
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D3441%23feedback-editor-3441)
 14.  [Skip to note 10 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-3402)
 15.   [leogermani](https://profiles.wordpress.org/leogermani/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-3402)
 16. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3402)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3402)
 17. **Change the Comment Form**
 18. Change the default field names of the comment form. Assumes the current form includes
     field names “Name” and “Email” and that ‘theme_text_domain’ is the name of your
     theme’s text domain.
 19.     ```php
         add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 );
         /**
          * Change comment form default field names.
          *
          * @link https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
          */
         function theme_change_comment_field_names( $translated_text, $text, $domain ) {
     
             if ( is_singular() ) {
     
                 switch ( $translated_text ) {
     
                     case 'Name' :
     
                         $translated_text = __( 'First Name', 'theme_text_domain' );
                         break;
     
                     case 'Email' :
     
                         $translated_text = __( 'Email Address', 'theme_text_domain' );
                         break;
                 }
     
             }
     
             return $translated_text;
         }
         ```
     
 20.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D3402%23feedback-editor-3402)
 21.  [Skip to note 11 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-3403)
 22.   [leogermani](https://profiles.wordpress.org/leogermani/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-3403)
 23. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3403)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3403)
 24. **Remove Text from Admin Form**
 25.     ```php
         add_filter('gettext', 'remove_admin_stuff', 20, 3);
         /**
          * Remove the text at the bottom of the Custom fields box in WordPress Post/Page Editor.
          *
          * @link https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
          */
         function remove_admin_stuff( $translated_text, $untranslated_text, $domain ) {
     
             $custom_field_text = 'Custom fields can be used to add extra metadata to a post that you can <a href="https://codex.wordpress.org/Using_Custom_Fields&quot; target="_blank">use in your theme</a>.';
     
             if ( is_admin() && $untranslated_text === $custom_field_text ) {
                 return '';
             }
     
             return $translated_text;
         }
         ```
     
 26.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D3403%23feedback-editor-3403)
 27.  [Skip to note 12 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-5060)
 28.   [Muhammad Arslan](https://profiles.wordpress.org/wparslan/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-5060)
 29. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5060)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5060)
 30.     ```php
         add_filter( 'gettext', 'wpdocs_change_login_form_register_keyword' );
     
         /**
           * Change Register link text on the login form
           *
           * @param $text string 
           * @return $text string
           * * * * * * * * * * * * * * * * * * */
         function wpdocs_change_login_form_register_keyword( $text ) {
     
             $text = str_ireplace( 'Register', 'Sign Up Now', $text );
     
             return $text;
         }
         ```
     
 31.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D5060%23feedback-editor-5060)
 32.  [Skip to note 13 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-3404)
 33.   [leogermani](https://profiles.wordpress.org/leogermani/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-3404)
 34. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3404)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-3404)
 35. **Change Text in Custom Post Admin Form**
 36.     ```php
         add_filter('gettext', 'change_admin_cpt_text_filter', 20, 3);
         /*
          * Change the text in the admin for my custom post type
          * 
         **/
         function change_admin_cpt_text_filter( $translated_text, $untranslated_text, $domain ) {
     
           global $typenow;
     
           if( is_admin() && 'MY_CPT' == $typenow )  {
     
             //make the changes to the text
             switch( $untranslated_text ) {
     
                 case 'Featured Image':
                   $translated_text = __( 'NEW FEATURED IMAGE TEXT','text_domain' );
                 break;
     
                 case 'Enter title here':
                   $translated_text = __( 'NEW TITLE COPY','text_domain' );
                 break;
     
                 //add more items
              }
            }
            return $translated_text;
         }
         ```
     
 37.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D3404%23feedback-editor-3404)
 38.  [Skip to note 14 content](https://developer.wordpress.org/reference/hooks/gettext/?output_format=md#comment-content-5061)
 39.   [Muhammad Arslan](https://profiles.wordpress.org/wparslan/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/gettext/#comment-5061)
 40. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5061)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%23comment-5061)
 41.     ```php
         add_filter( 'gettext', 'wpdocs_change_login_form_register_keyword' );
         /**
           * Change Register success after text message.
           *
           * @param $text string 
     
           * @return $text string
           * * * * * * * * * * * * * * * * * * */
         function wpdocs_change_login_form_register_keyword( $text ) {
     
             $text = str_ireplace( 'Registration complete. Please check your email, then visit the', ' Custom Message',  $text );
     
             return $text;
         }
         ```
     
 42.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F%3Freplytocom%3D5061%23feedback-editor-5061)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fgettext%2F)
before being able to contribute a note or feedback.