コード例 #1
0
ファイル: install.php プロジェクト: gcorral/hivequeen
/**
 * @global string    $hq_local_package
 * @global HQ_Locale $hq_locale
 */
$language = '';
if (!empty($_REQUEST['language'])) {
    $language = preg_replace('/[^a-zA-Z_]/', '', $_REQUEST['language']);
} elseif (isset($GLOBALS['hq_local_package'])) {
    $language = $GLOBALS['hq_local_package'];
}
switch ($step) {
    case 0:
        // Step 0
        // TODO: no translation
        //if ( hq_can_install_language_pack() && empty( $language ) && ( $languages = hq_get_available_translations() ) ) {
        if (false && empty($language) && ($languages = hq_get_available_translations())) {
            display_header('language-chooser');
            echo '<form id="setup" method="post" action="?step=1">';
            hq_install_language_form($languages);
            echo '</form>';
            break;
        }
        // Deliberately fall through if we can't reach the translations API.
    // Deliberately fall through if we can't reach the translations API.
    case 1:
        // Step 1, direct link or from language chooser.
        if (!empty($language)) {
            //TODO: Goyo not download languaje
            // $loaded_language = hq_download_language_pack( $language );
            //if ( $loaded_language ) {
            if (true) {
コード例 #2
0
/**
 * Download a language pack.
 *
 * @since 0.0.1
 *
 * @see hq_get_available_translations()
 *
 * @param string $download Language code to download.
 * @return string|bool Returns the language code if successfully downloaded
 *                     (or already installed), or false on failure.
 */
function hq_download_language_pack($download)
{
    // Check if the translation is already installed.
    if (in_array($download, get_available_languages())) {
        return $download;
    }
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return false;
    }
    // Confirm the translation is one we can download.
    $translations = hq_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 false;
    }
    $translation = (object) $translation;
    require_once ABSPATH . 'hq-admin/includes/class-hq-upgrader.php';
    $skin = new Automatic_Upgrader_Skin();
    $upgrader = new Language_Pack_Upgrader($skin);
    $translation->type = 'core';
    $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
    if (!$result || is_hq_error($result)) {
        return false;
    }
    return $translation->language;
}