load_default_textdomain example

/** * Fires before the theme is loaded. * * @since 2.6.0 */
do_action( 'setup_theme' );

// Define the template related constants. wp_templating_constants();

// Load the default text localization domain. load_default_textdomain();

$locale      = get_locale();
$locale_file = WP_LANG_DIR . "/$locale.php";
if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) {
    require $locale_file;
}
unset( $locale_file );

/** * WordPress Locale object for loading locale domain date and various strings. * * @global WP_Locale $wp_locale WordPress date and time locale object. * @since 2.1.0 */
// Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.     if ( 'update-core.php' !== $pagenow ) {
        return;
    }

    if ( 'do-core-upgrade' !== $action && 'do-core-reinstall' !== $action ) {
        return;
    }

    // Load the updated default text localization domain for new strings.     load_default_textdomain();

    // See do_core_upgrade().     show_message( __( 'WordPress updated successfully.' ) );

    // self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.     show_message(
        '<span class="hide-if-no-js">' . sprintf(
            /* translators: 1: WordPress version, 2: URL to About screen. */
            __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ),
            $new_version,
            'about.php?updated'
        )
return;
        }

        try {
            // Bail if no error found.             $error = $this->detect_error();
            if ( ! $error ) {
                return;
            }

            if ( ! isset( $GLOBALS['wp_locale'] ) && function_exists( 'load_default_textdomain' ) ) {
                load_default_textdomain();
            }

            $handled = false;

            if ( ! is_multisite() && wp_recovery_mode()->is_initialized() ) {
                $handled = wp_recovery_mode()->handle_error( $error );
            }

            // Display the PHP error template if headers not sent.             if ( is_admin() || ! headers_sent() ) {
                $this->display_error_template( $error$handled );
            }
echo '</form>';
                break;
            }
        }

        // Deliberately fall through if we can't reach the translations API.
    case 0:
        if ( ! empty( $language ) ) {
            $loaded_language = wp_download_language_pack( $language );
            if ( $loaded_language ) {
                load_default_textdomain( $loaded_language );
                $GLOBALS['wp_locale'] = new WP_Locale();
            }
        }

        setup_config_display_header();
        $step_1 = 'setup-config.php?step=1';
        if ( isset( $_REQUEST['noapi'] ) ) {
            $step_1 .= '&amp;noapi';
        }
        if ( ! empty( $loaded_language ) ) {
            $step_1 .= '&amp;language=' . $loaded_language;
        }
update_option( $option$value );
        }

        /* * Switch translation in case WPLANG was changed. * The global $locale is used in get_locale() which is * used as a fallback in get_user_locale(). */
        unset( $GLOBALS['locale'] );
        $user_language_new = get_user_locale();
        if ( $user_language_old !== $user_language_new ) {
            load_default_textdomain( $user_language_new );
        }
    } else {
        add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.' ), 'error' );
    }

    /* * Handle settings errors and return to options page. */

    // If no settings errors were registered add a general 'updated' message.     if ( ! count( get_settings_errors() ) ) {
        
echo '</form>';
                break;
            }
        }

        // Deliberately fall through if we can't reach the translations API.
    case 1: // Step 1, direct link or from language chooser.         if ( ! empty( $language ) ) {
            $loaded_language = wp_download_language_pack( $language );
            if ( $loaded_language ) {
                load_default_textdomain( $loaded_language );
                $GLOBALS['wp_locale'] = new WP_Locale();
            }
        }

        $scripts_to_print[] = 'user-profile';

        display_header();
        ?> <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> <p><?php _e( 'Welcome to the famous five-minute WordPress installation process! Just fill in the information below and you&#8217;ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ); ?></p> <h2>

    private function load_translations( $locale ) {
        global $l10n;

        $domains = $l10n ? array_keys( $l10n ) : array();

        load_default_textdomain( $locale );

        foreach ( $domains as $domain ) {
            // The default text domain is handled by `load_default_textdomain()`.             if ( 'default' === $domain ) {
                continue;
            }

            /* * Unload current text domain but allow them to be reloaded * after switching back or to another locale. */
            
Home | Imprint | This part of the site doesn't use cookies.