• Resolved Galegri

    (@galegri)


    Hi all,
    I’m using the module qTranslate to get my site in two languages, catalan and spanish. Now i have all the site translated but the slider images that contain text.
    I thought i could use a php conditional using a qTranslate variable $q_config[‘language’] and image’s name as image1_ca.png and image1_es.png. But i can’t find the right place to put this code on and the variable that contains image’s name.

    Please someone tell me where should i do that or if you know any solution can help me.

    Sorry for my poor english, i’m just a young scholarship holder but i’m the only web developer of the company so i really need that help, thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Galegri

    (@galegri)

    I have a new idea how to do that.
    If I could find the SQL query that selects the slides information I could modify it with something like:
    […] where image_name like ‘%_es%’;

    This way i shouldn’t modify my php.
    Waiting for an answer… while searching for it ??

    No, no, it’s much more simple. Edit the slide of the slider and change the title text to [:en]Your English text[:it]Your Italian text

    This assumes your language is Italian. Change to your own 2-letter qTranslate country code.

    Thread Starter Galegri

    (@galegri)

    I doesn’t mean that.
    Some of my images contain text so i need to show different images for each language.

    Did it like i was telling in the first post. Creating a function in functions.php that compares image name and $_GET[‘lang’]:

    function CheckSlideLang($image)
    {
        //Search for '__' in the image name and take the 2 next characters(CA/es)
        $lang = substr($image, strpos($image, "__")+2, 2);
        $imageIsRight=false;
        if(isset($_GET['lang']))
        {
            if($lang == $_GET['lang']) $imageIsRight = true;
        }
        //CA(catalan doesn't have GET so check this way)
        else if($lang =='CA') $imageIsRight = true;
    
        //returns true or false
        return $imageIsRight;
    }

    And a conditional in class-content-slider.php:

    if(CheckSlideLang($slide_background))
        {
            $slides[$id]       = array(
                               'title'               =>  $title,
                               'text'                =>  $text,
                               'button_text'         =>  $button_text,
                               'link_id'             =>  $link_id,
                               'link_url'            =>  $link_url,
                               'active'              =>  $active,
                               'color_style'         =>  $color_style,
                               'slide_background'    =>  $slide_background,
            );
    
            //increments active index
            $i++;
        }

    I know it isn’t the best way… but it works.

    You could filter the slider output and change any occurence of __XX to __YY.

    add_filter('tc_slider_display', 'apply_lang_filter');
    function apply_lang_filter($output) {
    	return ( qtrans_getLanguage()=='es' ?
    		preg_replace(
    			'%__CA%',
    			'__ES',
    			$output,
    			-1 ) :
    		$output );
    	}

    I assumed your catalan images have __CA in their name and the spanish ones have __ES in them. Change to actual strings if i assumed wrong. All this does is replacing any occurence of __CA with __ES in the html output of your slider, if current language is spanish.

    This code goes in functions.php of your child theme, you don’t have to touch Customizr files, so you may keep it up to date.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Diferent slider images for each lenguage’ is closed to new replies.