Summery Summery
Get installed translations.
Syntax Syntax
Description Description
Looks in the wp-content/languages directory for translations of plugins or themes.
Parameters Parameters
- $type
-
(Required) What to search for. Accepts 'plugins', 'themes', 'core'.
Return Return
(array) Array of language data.
Source Source
File: wp-includes/l10n.php
* Since the role names are in the database and not in the source there * are dummy gettext calls to get them into the POT file and this function * properly translates them back. * * The before_last_bar() call is needed, because older installations keep the roles * using the old context format: 'Role name|User role' and just skipping the * content after the last bar is easier than fixing them in the DB. New installations * won't suffer from that problem. * * @since 2.8.0 * @since 5.2.0 Added the `$domain` parameter. * * @param string $name The role name. * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. * Default 'default'. * @return string Translated role name on success, original name on failure. */ function translate_user_role( $name, $domain = 'default' ) { return translate_with_gettext_context( before_last_bar( $name ), 'User role', $domain ); } /** * Get all available languages based on the presence of *.mo files in a given directory. * * The default directory is WP_LANG_DIR. * * @since 3.0.0 * @since 4.7.0 The results are now filterable with the {@see 'get_available_languages'} filter. * * @param string $dir A directory to search for language files. * Default WP_LANG_DIR. * @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. */ function get_available_languages( $dir = null ) { $languages = array(); $lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' ); if ( $lang_files ) { foreach ( $lang_files as $lang_file ) { $lang_file = basename( $lang_file, '.mo' ); if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && 0 !== strpos( $lang_file, 'admin-' ) ) { $languages[] = $lang_file; }
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.7.0 | Introduced. |