Skip to content

Commit

Permalink
Display error message if manual gettext-update fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mweimerskirch committed Apr 2, 2015
1 parent 4f259d0 commit 2391333
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions admin/qtx_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,14 @@ function qtranxf_conf() {

qtranxf_updateSetting('header_css', QTX_STRING, qtranxf_front_header_css_default());

if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtranxf_updateGettextDatabases(true))
$message[] = __('Gettext databases updated.', 'qtranslate');
if ( isset( $_POST['update_mo_now'] ) && $_POST['update_mo_now'] == '1' ) {
$result = qtranxf_updateGettextDatabases( true );
if ( $result === true ) {
$message[] = __( 'Gettext databases updated.', 'qtranslate' );
} elseif ( is_wp_error( $result ) ) {
$message[] = __( 'Gettext databases <strong>not</strong> updated:', 'qtranslate' ) . ' ' . $result->get_error_message();
}
}

$import_migration = preg_grep( '/import/', $_POST );
foreach($import_migration as $key => $value){
Expand Down
7 changes: 4 additions & 3 deletions admin/qtx_update_gettext_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ function qtranxf_updateGettextDatabases($force = false, $only_for_language = '')
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
$result = translations_api( 'core', array( 'version' => $wp_version ));

if ( ! is_wp_error( $result = translations_api( 'core', array( 'version' => $wp_version ) ) ) ) {
if ( is_wp_error( $result ) ) {
return $result;
} else {
foreach ( $result['translations'] as $translation ) {
$locale = substr($translation['language'], 0, 2);
if (
Expand All @@ -33,6 +36,4 @@ function qtranxf_updateGettextDatabases($force = false, $only_for_language = '')
}
return true;
}
else
return false;
}

0 comments on commit 2391333

Please sign in to comment.