wp_get_available_translations example

<?php _e( 'New User Default Role' ); ?></label></th> <td> <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select> </td> </tr> <?php }

$languages    = get_available_languages();
$translations = wp_get_available_translations();
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages, true ) ) {
    $languages[] = WPLANG;
}
if ( ! empty( $languages ) || ! empty( $translations ) ) {
    ?> <tr> <th scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th> <td> <?php             $locale = get_locale();
            if ( ! in_array( $locale$languages, true ) ) {
                
<?php                         /* translators: Hidden accessibility text. */
                        _e( 'Size in kilobytes' );
                        ?> </p> </td> </tr> </table> <?php         $languages    = get_available_languages();
        $translations = wp_get_available_translations();
        if ( ! empty( $languages ) || ! empty( $translations ) ) {
            ?> <h2><?php _e( 'Language Settings' ); ?></h2> <table class="form-table" role="presentation"> <tr> <th><label for="WPLANG"><?php _e( 'Default Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th> <td> <?php                         $lang = get_site_option( 'WPLANG' );
                        if ( ! in_array( $lang$languages, true ) ) {
                            $lang = '';
                        }
<?php                     _e( 'Site Title' );
                    echo ' ' . wp_required_field_indicator();
                    ?> </label> </th> <td><input name="blog[title]" type="text" class="regular-text" id="site-title" required /></td> </tr> <?php         $languages    = get_available_languages();
        $translations = wp_get_available_translations();
        if ( ! empty( $languages ) || ! empty( $translations ) ) :
            ?> <tr class="form-field form-required"> <th scope="row"><label for="site-language"><?php _e( 'Site Language' ); ?></label></th> <td> <?php                     // Network default.                     $lang = get_site_option( 'WPLANG' );

                    // Use English if the default isn't available.                     if ( ! in_array( $lang$languages, true ) ) {
                        
if ( ! empty( $_REQUEST['language'] ) ) {
    $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
    $language = $GLOBALS['wp_local_package'];
}

$scripts_to_print = array( 'jquery' );

switch ( $step ) {
    case 0: // Step 0.         if ( wp_can_install_language_pack() && empty( $language ) ) {
            $languages = wp_get_available_translations();
            if ( $languages ) {
                $scripts_to_print[] = 'language-chooser';
                display_header( 'language-chooser' );
                echo '<form id="setup" method="post" action="?step=1">';
                wp_install_language_form( $languages );
                echo '</form>';
                break;
            }
        }

        // Deliberately fall through if we can't reach the translations API.
function wp_download_language_pack( $download ) {
    // Check if the translation is already installed.     if ( in_array( $downloadget_available_languages(), true ) ) {
        return $download;
    }

    if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
        return false;
    }

    // Confirm the translation is one we can download.     $translations = wp_get_available_translations();
    if ( ! $translations ) {
        return false;
    }
    foreach ( $translations as $translation ) {
        if ( $translation['language'] === $download ) {
            $translation_to_load = true;
            break;
        }
    }

    if ( empty( $translation_to_load ) ) {
        
return;
    }

    // English (United States) uses an empty string for the value attribute.     if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) {
        $parsed_args['selected'] = '';
    }

    $translations = $parsed_args['translations'];
    if ( empty( $translations ) ) {
        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
        $translations = wp_get_available_translations();
    }

    /* * $parsed_args['languages'] should only contain the locales. Find the locale in * $translations to get the native name. Fall back to locale. */
    $languages = array();
    foreach ( $parsed_args['languages'] as $locale ) {
        if ( isset( $translations[ $locale ] ) ) {
            $translation = $translations[ $locale ];
            $languages[] = array(
                

$language = '';
if ( ! empty( $_REQUEST['language'] ) ) {
    $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
    $language = $GLOBALS['wp_local_package'];
}

switch ( $step ) {
    case -1:
        if ( wp_can_install_language_pack() && empty( $language ) ) {
            $languages = wp_get_available_translations();
            if ( $languages ) {
                setup_config_display_header( 'language-chooser' );
                echo '<h1 class="screen-reader-text">Select a default language</h1>';
                echo '<form id="setup" method="post" action="?step=0">';
                wp_install_language_form( $languages );
                echo '</form>';
                break;
            }
        }

        // Deliberately fall through if we can't reach the translations API.
Home | Imprint | This part of the site doesn't use cookies.