get_available_languages

Advertisement

Summery Summery

Get all available languages based on the presence of *.mo files in a given directory.

Syntax Syntax

get_available_languages( string $dir = null )

Description Description

The default directory is WP_LANG_DIR.

Parameters Parameters

$dir

(Optional) A directory to search for language files. Default WP_LANG_DIR.

Default value: null

Return Return

(string[]) An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.

Source Source

File: wp-includes/l10n.php

 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @return Translations|NOOP_Translations A Translations instance.
 */
function get_translations_for_domain( $domain ) {
	global $l10n;
	if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
		return $l10n[ $domain ];
	}

	static $noop_translations = null;
	if ( null === $noop_translations ) {
		$noop_translations = new NOOP_Translations;
	}

	return $noop_translations;
}

/**
 * Whether there are translations for the text domain.
 *
 * @since 3.0.0
 *
 * @global MO[] $l10n

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 The results are now filterable with the 'get_available_languages' filter.
3.0.0 Introduced.

Advertisement

Leave a Reply