wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_available_translations › WordPress Function

Seit4.0.0
Veraltetn/v
wp_get_available_translations ( Keine Parameter )
Siehe:
Gibt zurück:
  • (array) { Array of translations keyed by the language code, each an associative array of data. If the API response results in an error, an empty array will be returned. @type array ...$0 { @type string $language Language code. @type string $version WordPress version. @type string $updated Date the translation was last updated, in MySQL datetime format. @type string $english_name English name of the language. @type string $native_name Native name of the language. @type string $package URL to download the translation package. @type string[] $iso Array of ISO language codes. @type array $strings Array of translated strings used in the installation process. } }
Definiert in:
Codex:

Get available translations from the WordPress.org API.



Quellcode

function wp_get_available_translations() {
	if ( ! wp_installing() ) {
		$translations = get_site_transient( 'available_translations' );
		if ( false !== $translations ) {
			return $translations;
		}
	}

	$api = translations_api( 'core', array( 'version' => wp_get_wp_version() ) );

	if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
		return array();
	}

	$translations = array();
	// Key the array with the language code.
	foreach ( $api['translations'] as $translation ) {
		$translations[ $translation['language'] ] = $translation;
	}

	if ( ! defined( 'WP_INSTALLING' ) ) {
		set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
	}

	return $translations;
}