I18n::get_i18n_strings_for_domains( array $strings, array $languages, array $domains = array('default'), int $flags = 7 )

Get all possible translations for a String based on the given Languages and Domains.

WARNING: This function is slow because it deals with files, so don’t overuse it! Differently from the get_i18n_strings method this will not use any domain that’s not specified.


Parameters

$strings

(array) (Required) An array of strings (required).

$languages

(array) (Required) Which l10n to fetch the string (required).

$domains

(array) (Optional) Possible domains to re-load.

Default value: array('default')

$flags

(int) (Optional) An integer resulting from the combination of compilation flags; defaults to static::COMPILE_ALL to compile all versions of the translations. static::COMPILE_INPUT will compile the translation for the string, as input. static::COMPILE_STRTOLOWER will compile the translation for the string in its lowercase version. static::COMPILE_UCFIRST will compile the translation for the string in its title version.

Default value: 7


Top ↑

Return

(TribeEventsarray<string,array|TribeEventsstring>) A multi level array with the possible translations for the given strings.


Top ↑

Source

File: src/Tribe/I18n.php

	public function get_i18n_strings_for_domains( $strings, $languages, $domains = array( 'default' ) ) {
		sort( $languages );
		$strings_buffer = [ $strings ];

		foreach ( $languages as $language ) {
			// Override the current locale w/ the one we need to compile the translations.
			$language_strings = $this->with_locale(
				$language,
				[ $this, 'compile_translations' ],
				[ $strings, $domains ]
			);
			$strings_buffer[] = $language_strings;
		}

		$strings = count( $strings_buffer ) > 1
			? array_merge_recursive( ... $strings_buffer )
			: reset( $strings_buffer );

		// Prevent empty strings and duplicates.
		foreach ( $strings as $key => $value ) {
			$strings[ $key ] = array_filter(
				array_unique(
					array_map( 'sanitize_title_with_dashes', (array) $value )
				)
			);
		}

		return $strings;
	}

Top ↑

Changelog

Changelog
Version Description
5.1.5 Add support for the $flags argument.
5.1.1 Introduced.