• Resolved Thubten

    (@thubten)


    If you use WPML String with this pluggin, I propose two files change:

    In quotes-collection-admin.php:

    – Line 40, under $results = $wpdb->query( $insert );

    //WPML
    if (function_exists('icl_register_string')) {
    	$newid = $wpdb->insert_id;
    	icl_register_string('Quotes Collection', 'Quote ID '.$newid, trim(stripslashes($quote), "'"));
    	icl_register_string('Quotes Collection', 'Source ID '.$newid, trim(stripslashes($source), "'"));
    	icl_register_string('Quotes Collection', 'Author ID '.$newid, trim(stripslashes($author), "'"));
    }

    – Line 89, under $results = $wpdb->query( $update );

    // WPML
    if (function_exists('icl_register_string')) {
    	icl_register_string('Quotes Collection', 'Quote ID '.$quote_id, trim(stripslashes($quote), "'"));
    	icl_register_string('Quotes Collection', 'Source ID '.$quote_id, trim(stripslashes($source), "'"));
    	icl_register_string('Quotes Collection', 'Author ID '.$quote_id, trim(stripslashes($author), "'"));
    }

    – Line 109, under ” WHERE quote_id = ” . $quote_id;

    // WPML
    if (function_exists('icl_unregister_string')) {
    	icl_unregister_string('Quotes Collection', 'Quote ID '.$quote_id);
    	icl_unregister_string('Quotes Collection', 'Source ID '.$quote_id);
    	icl_unregister_string('Quotes Collection', 'Author ID '.$quote_id);
    }

    In quotes-collection.php:

    – Line 91, under $random_quote = $wpdb->get_row($sql, ARRAY_A);

    // WPML
    if (function_exists('icl_t')) {
    	$random_quote['quote'] = icl_t('Quotes Collection', 'Quote ID '.$random_quote['quote_id'], $random_quote['quote']);
    	$random_quote['source'] = icl_t('Quotes Collection', 'Source ID '.$random_quote['quote_id'], $random_quote['source']);
    	$random_quote['author'] = icl_t('Quotes Collection', 'Author ID '.$random_quote['quote_id'], $random_quote['author']);
    }

    Each time you add or edit a quote, it will add a new WPML string with Quote ID, Source and Author to translate.

    Yours

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks A LOT for this, it made my day!
    A question: how do you make the Quotes Collection (Random Quote) Widget title appear in the WPML strings?

    Thread Starter Thubten

    (@thubten)

    Hello,

    To add the Widget title in WPML String, please change the plugin’s code as follow:

    In quotes-collection-widget.php:

    – Line 13, under $options = get_option(‘quotescollection’);

    // WPML
    if (function_exists('icl_t')) {
    	$options['title'] = icl_t('Quotes Collection', 'Widget title', $options['title']);
    }

    – Line 71, under update_option(‘quotescollection’, $options);

    //WPML
    if (function_exists('icl_register_string')) {
    	icl_register_string('Quotes Collection', 'Widget title', $options['title']);
    }

    All the best

    Hello Thubten,

    The widget title is now registered as a string and can be translated but now the widgets in the translated languages do not appear anymore in the sidebar. But it is OK, don’t spend time on this, I will do without a title… Thanks again for your help!

    Thread Starter Thubten

    (@thubten)

    Your welcome…
    Hope it will be helpful for anyone who wants to use this plugin with WPML.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Make it work with WPML’ is closed to new replies.