Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 14 replies, has 4 voices.

Last updated by Susan 9 years, 6 months ago.

Author Posts
October 3, 2011 at 8:17 pm #37339

B.

Hello,
We are using the WordPress plugin "Nivo Slider for WordPress v0.3.3" to create and display an image slider with captions on the homepage of our site. The plugin allows image captions to be entered via the wp-admin and stores these captions in custom database tables. How do we translate the contents of these database tables with WPML and display the translated versions on the spanish version of the site?
Thanks,
Aaron

October 3, 2011 at 9:28 pm #37341

Anonymous

Does the plugin store them in a custom table? as post meta? as wp_options entry?

October 3, 2011 at 9:43 pm #37342

B.

The plugin stores them in a custom table called _nivoslider4wp in a column (text) called nivoslider4wp_text_headline

October 4, 2011 at 1:20 pm #37343

Anonymous

Can you look for the code that prints the caption and post it here?

October 4, 2011 at 6:08 pm #37344

B.

this is from nivo.sider.js
<pre>

//Create caption
slider.append(
     $('<div class="nivo-caption"></div>').css({ display:'none' })
);

// Process caption function
var processCaption = function(settings){
     var nivoCaption = $('.nivo-caption', slider);
	if(vars.currentImage.attr('title') != ''){
		var title = vars.currentImage.attr('title');
		if(title.substr(0,1) == '#') title = $(title).html();	

		if(nivoCaption.css('display') == 'block'){
			nivoCaption.find('p').fadeOut(settings.animSpeed, function(){
				$(this).html(title);
				$(this).fadeIn(settings.animSpeed);
			});
		} else {
			nivoCaption.find('p').html(title);
		     }
		nivoCaption.fadeIn(settings.animSpeed);
		} else {
		     nivoCaption.fadeOut(settings.animSpeed);
		     }
		}

</pre>
the slider is then called with this single line on the home page:

<?php if (function_exists('nivoslider4wp_show')) { nivoslider4wp_show(); } ?>
October 4, 2011 at 6:52 pm #37345

Anonymous

B., I need to see the php code where the plugin query the database and get the captions, and create the html elements with them. That JS seems to be using the title attribute of an image.

October 4, 2011 at 7:26 pm #37346

B.

Daniel,
There are 4 php files within the plugin directory. These portions from nivoslider4wp-panel.php seem to be storing data inputted via the back end:
<pre>

<form name="nivoslider4wp_coords" method="post" id="edit_form" action="">
    <label for="nivoslider4wp_file_text_headline"><?php _e('Image caption(optional)','nivoslider4wp'); ?></label>
		<textarea name="nivoslider4wp_file_text_headline" id="nivoslider4wp_file_text_headline" class="edit"><?php echo stripslashes(@$ns4wp_file_text_headline); ?></textarea>
	<label for="nivoslider4wp_image_link"><?php _e('Image link, please use <strong><em><u>hidden link</u></em>)', 'nivoslider4wp'); ?></label>
		<input type="text" name="nivoslider4wp_image_link" id="nivoslider4wp_image_link" value="<?php echo stripslashes(@$ns4wp_image_link); ?>" class="edit" />

</pre>
And here is the portion from nivoslider4wp-show.php which appears to query the database:
<pre>

<div id="slider">
				<?php $items = $wpdb->get_results("SELECT nivoslider4wp_id,nivoslider4wp_type,nivoslider4wp_text_headline,nivoslider4wp_image_link FROM {$wpdb->prefix}nivoslider4wp ORDER BY nivoslider4wp_order,nivoslider4wp_id"); ?>
				<?php foreach($items as $item) : ?>
						<?php
						if(!$item->nivoslider4wp_image_link){ ?>
						<img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>" title="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>"/>
						<?php } else { ?>
						<a href="<?php echo $item->nivoslider4wp_image_link;?>"><img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>" title="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>"/></a>
						<?php } ?>
				<?php endforeach; ?>
		</div>

</pre>

October 4, 2011 at 7:29 pm #37347

Anonymous

replace each apparence of $item->nivoslider4wp_text_headline
for:
_e($item->nivoslider4wp_text_headline, "nivo_headlines")
in this lines:
<?php
if(!$item->nivoslider4wp_image_link){ ?>
<img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>" title="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>"/>
<?php } else { ?>
<a>nivoslider4wp_image_link;?>"><img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>" title="<?php echo stripslashes($item->nivoslider4wp_text_headline); ?>"/></a>
<?php } ?>
then navigate the site (you should see the original captions), and once you did this, go to WPML->String Translation and check for the captions there to translate

October 4, 2011 at 8:09 pm #37348

B.

Daniel, thank you for your replies. I will try that solution.
I also have a thread with you regarding Events Calendar Pro which is a main priority for us at the moment. I am emailing you the plugin folder and the theme folder per your request from aaron [at] laneandlane. Any help you can provide is greatly appreciated.
Thanks!
Aaron

October 5, 2011 at 12:24 am #37349

B.

Daniel,
I inserted the _e() where you described and rescanned the theme, but wpml is still not recognizing the text. did I add the tags correctly?
<pre>

<?php foreach($items as $item) : ?>
	                                <?php
						if(!$item->nivoslider4wp_image_link){ ?>
						<img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes(_e($item->nivoslider4wp_text_headline, "nivo_headlines")); ?>" title="<?php echo stripslashes(_e($item->nivoslider4wp_text_headline, "nivo_headlines")); ?>"/>
						<?php } else { ?>
						<a href="<?php echo $item->nivoslider4wp_image_link;?>"><img src="<?php echo $ns4wp_filesurl.$item->nivoslider4wp_id.'_s.'.$item->nivoslider4wp_type; ?>" alt="<?php echo stripslashes(_e($item->nivoslider4wp_text_headline, "nivo_headlines")); ?>" title="<?php echo stripslashes(_e($item->nivoslider4wp_text_headline, "nivo_headlines")); ?>"/></a>
						<?php } ?>
				<?php endforeach; ?>

</pre>

October 5, 2011 at 2:30 pm #37350

Matias Montes

Aaron,
The code you posted is correct. I believe that you are only missing the navigation of the site. You need to navigate the front end of the site (where this captions show) logged in as the site administrator. When you do so, you will see the original captions, but when you go back to the string translator (WPML->String Translation) you will be able to translate them.

October 5, 2011 at 6:14 pm #37351

B.

Matias,
I followed the directions you provided, but without any luck. The strings are not appearing on the String Translation page. I've even rescanned the theme for strings from the WPML > Theme and Plugins Localization menu without any luck. Any other ideas?
Thanks,
Aaron

October 5, 2011 at 8:49 pm #37352

Anonymous

Ok, I was trying to resolve this without modifying your original plugin. But let's try this:
1) In nivoslider4wp-panel.php add " icl_register_string('NivoSlider', $_POST['nivoslider4wp_file_text_headline'], $_POST['nivoslider4wp_file_text_headline']); " after "$values" array (line 100 aprox).
2) Go to Admin panel, WPML-> String translation -> Select strings within context: "NivoSlider"-> Search.
3) Do the translations
4) In nivoslider4wp-show.php update both img title attribute width "<?php echo icl_t('NivoSlider', $item->nivoslider4wp_text_headline, $item->nivoslider4wp_text_headline) ?>" (line 20 & 22 aprox)

October 13, 2011 at 6:15 pm #37353

B.

Daniel,
Thanks for your reply. I will try that solution and let you know how it goes.
Aaron

March 13, 2012 at 7:25 pm #51901

Susan

<blockquote cite="">Ok, I was trying to resolve this without modifying your original plugin. But let's try this:
1) In nivoslider4wp-panel.php add " icl_register_string('NivoSlider', $_POST['nivoslider4wp_file_text_headline'], $_POST['nivoslider4wp_file_text_headline']); " after "$values" array (line 100 aprox).
2) Go to Admin panel, WPML-> String translation -> Select strings within context: "NivoSlider"-> Search.
3) Do the translations
4) In nivoslider4wp-show.php update both img title attribute width "<?php echo icl_t('NivoSlider', $item->nivoslider4wp_text_headline, $item->nivoslider4wp_text_headline) ?>" (line 20 & 22 aprox) <cite>

Hey Daniel, I tired it, and I think it translated my captions in slider and its very cool. But what about the links on slider images? I have 3 languages, each languages has slider of 3 images. And now they get their own translated captions. But also those URLs to pages (each image takes to specific page), I don't get how to make those translated in Nivo Slider for WP? The plugin interface only has field for one URL per image.

The topic ‘[Closed] Translating custom database tables (Nivo Slider for WordPress v0.3.3)’ is closed to new replies.