Title: Language and snippet code
Last modified: November 10, 2020

---

# Language and snippet code

 *  [sayedhussain96](https://wordpress.org/support/users/sayedhussain96/)
 * (@sayedhussain96)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/language-and-snippet-code/)
 * Hello friends, i have a snippet code i want it to be excuted only when the language
   is arabic, here is the code
 *     ```
       function translate_text( $translated ) {
   
         // The first parameter is the original text, the second parameter is the changed text.
         $translated = str_ireplace( 'First Name',  'الاسم الأول',  $translated );
         $translated = str_ireplace( 'Last Name',  'الاسم الأخير',  $translated );
       	$translated = str_ireplace( 'National ID',  'الرقم الشخصي',  $translated );
       	$translated = str_ireplace( 'Nationality',  'الجنسية',  $translated );
       	$translated = str_ireplace( 'Gender',  'الجنس',  $translated );
       	$translated = str_ireplace( 'Road Number',  'رقم الطريق',  $translated );
       	$translated = str_ireplace( 'House Number',  'رقم المنزل',  $translated );
       	$translated = str_ireplace( 'Block Number',  'رقم المجمع',  $translated );
       	$translated = str_ireplace( 'Male',  'ذكر',  $translated );
       	$translated = str_ireplace( 'Female',  'أنثى',  $translated );
   
   
         // Returns the translated text
         return $translated;
   
       }
   
       		add_filter( 'gettext',  'translate_text' );
               add_filter( 'ngettext',  'translate_text' );
       ```
   

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/language-and-snippet-code/#post-13645392)
 * You should be able to use `get_language_attributes()` or `get_locale()` to learn
   what language the page is using. The specifics depend on how the page comes to
   be Arabic in the first place. Temporarily echo out their return values on the
   page’s template to see what values you can check for.

Viewing 1 replies (of 1 total)

The topic ‘Language and snippet code’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/language-and-snippet-code/#post-13645392)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
