WPML and NextGen Gallery Translation

September 29, 2010 § 6 Comments

I was searching on the net to see if anyone did some script to integrate both. At the end, nothing seems to work, I finally figure out a quick method to translate a dynamic string.

From here you can see the official site document about the string register
icl_register_string($context, $name, $value)
so basically you put

$content as The plugin name (name it the way you want, coz we are going to use it in front end later ) , in this case ,we ¬†use ‘NextGen’

$name as the Hook that we link to the string.

$value as the value of the string.

After we understand the usage of this function, it comes clear to us that we only need to put it to the place where the string appear.

From the first sense, I can think about the NextGen Admin Panel.

Backend

So go to the file in NextGen plugin called Manage.php in line about 364

if (isset ($_POST['updatepictures'])) {
// Update pictures

……
if ( nggGallery::current_user_can( ‘NextGEN Edit gallery options’ )) {
……

Following the line, put icl_register_string function on.

For example,
icl_register_string('NextGen', $_POST['title'], $_POST['title']);
In this way, we can capture the title value among the gallery if we ever update them.
Then we can go to WPML >String Translation to do the translation.

For sure, you could put the capture code to anyway in almost anywhere in the plugin

Front End

We can put icl_t($context, $name, $value) to call the string translation.

The function will find the string with combination of context and name, and if not the value given will be return.
in our example, icl_t(‘NextGen’, $gallery->title, $gallery->title) .

Please make sure you understand the usage of NextGen Gallery and WPML , it does help to peek at the coding as well.

Where Am I?

You are currently browsing entries tagged with wordpress plugin at Nick Wan L.K..