Title: Translation_Entry::__construct
Published: August 18, 2015
Last modified: April 28, 2025

---

# Translation_Entry::__construct( array $args = array() )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/Translation_Entry/__construct/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/Translation_Entry/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/Translation_Entry/__construct/?output_format=md#related)

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

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

 `$args`arrayoptional

Arguments array, supports the following keys:

 * `singular` string
 * The string to translate, if omitted an empty entry will be created.
 * `plural` string
 * The plural form of the string, setting this will set `$is_plural` to true.
 * `translations` array
 * Translations of the string and possibly its plural forms.
 * `context` string
 * A string differentiating two equal strings used in different contexts.
 * `translator_comments` string
 * Comments left by translators.
 * `extracted_comments` string
 * Comments left by developers.
 * `references` array
 * Places in the code this string is used, in relative_to_root_path/file.php:linenum
   form.
 * `flags` array
 * Flags like php-format.

Default:`array()`

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

    ```php
    public function __construct( $args = array() ) {
    	// If no singular -- empty object.
    	if ( ! isset( $args['singular'] ) ) {
    		return;
    	}
    	// Get member variable values from args hash.
    	foreach ( $args as $varname => $value ) {
    		$this->$varname = $value;
    	}
    	if ( isset( $args['plural'] ) && $args['plural'] ) {
    		$this->is_plural = true;
    	}
    	if ( ! is_array( $this->translations ) ) {
    		$this->translations = array();
    	}
    	if ( ! is_array( $this->references ) ) {
    		$this->references = array();
    	}
    	if ( ! is_array( $this->flags ) ) {
    		$this->flags = array();
    	}
    }
    ```

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

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

| Used by | Description | 
| [WP_Translations::make_entry()](https://developer.wordpress.org/reference/classes/wp_translations/make_entry/)`wp-includes/l10n/class-wp-translations.php` |

Builds a [Translation_Entry](https://developer.wordpress.org/reference/classes/translation_entry/) from original string and translation strings.

  | 
| [PO::read_entry()](https://developer.wordpress.org/reference/classes/po/read_entry/)`wp-includes/pomo/po.php` |  | 
| [Translations::add_entry()](https://developer.wordpress.org/reference/classes/translations/add_entry/)`wp-includes/pomo/translations.php` |

Adds an entry to the PO structure.

  | 
| [Translations::add_entry_or_merge()](https://developer.wordpress.org/reference/classes/translations/add_entry_or_merge/)`wp-includes/pomo/translations.php` |

Adds or merges an entry to the PO structure.

  | 
| [Translations::translate()](https://developer.wordpress.org/reference/classes/translations/translate/)`wp-includes/pomo/translations.php` |

Translates a singular string.

  | 
| [Translations::translate_plural()](https://developer.wordpress.org/reference/classes/translations/translate_plural/)`wp-includes/pomo/translations.php` |

Translates a plural string.

  | 
| [Translation_Entry::Translation_Entry()](https://developer.wordpress.org/reference/classes/translation_entry/translation_entry/)`wp-includes/pomo/entry.php` |

PHP4 constructor.

  | 
| [MO::make_entry()](https://developer.wordpress.org/reference/classes/mo/make_entry/)`wp-includes/pomo/mo.php` |

Build a [Translation_Entry](https://developer.wordpress.org/reference/classes/translation_entry/) from original string and translation strings, found in a MO file

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/Translation_Entry/__construct/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/Translation_Entry/__construct/?output_format=md#)

## User Contributed Notes

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