Translations::translate() WordPress Method

The Translations::translate() Wordpress method is used to translate a string of text from one language to another. This is useful for creating multilingual websites or for providing translations of content for international audiences. The Translations::translate() method accepts two parameters: the string to be translated and the desired language code for the translation. The method will then return the translated string. If you need to translate a string of text on your Wordpress site, then you can use the Translations::translate() method. Simply pass in the string of text to be translated and the desired language code for the translation, and the method will return the translated string.

Translations::translate( string $singular, string $context = null ) #


Parameters

$singular

(string)(Required)

$context

(string)(Optional)

Default value: null


Top ↑

Return

(string)


Top ↑

Source

File: wp-includes/pomo/translations.php

		public function translate( $singular, $context = null ) {
			$entry      = new Translation_Entry(
				array(
					'singular' => $singular,
					'context'  => $context,
				)
			);
			$translated = $this->translate_entry( $entry );
			return ( $translated && ! empty( $translated->translations ) ) ? $translated->translations[0] : $singular;
		}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.