WordPress.org

Ready to get started?Download WordPress

Forums

012 Ps Multi Languages
[resolved] This is how i put language flags on my page (2 posts)

  1. dr_who20
    Member
    Posted 1 year ago #

    1) Copy the complete "flags" dir to your "img dir" or "images" dir in your theme.

    2) follow the normal install procedure of the plugin: http://wordpress.org/extend/plugins/012-ps-multi-languages/installation/

    3) Replace the following code in line 22: /wp-content/plugins/012-ps-multi-languages/config/functions.php

    $multilingual_snippet = $ps_multi_languages->ps_012_multilingual_list( $lang );
    		if ( !$echo ):
    			return $multilingual_snippet;
    		endif;
    
    		$html .= '<ul class="snippet">'. "\n";
    
    		foreach ( $multilingual_snippet as $key => $val ){
    			$current = $val['current'] ? ' class="'.$val['current'].'" ' : '';
    			$html .= '<li'. $current .'>' . "\n";
    			$html .= '<a href="'.$val['url'].'">'.$val['name'].'</a>' . "\n";
    			$html .= '</li>' . "\n";
    		}
    		$html .= '</ul>'. "\n";
    
    		echo $html;
    	}

    To:

    $multilingual_snippet = $ps_multi_languages->ps_012_multilingual_list( $lang );
    		if ( !$echo ):
    			return $multilingual_snippet;
    		endif;
    
    		$html .= '<ul class="snippet">'. "\n";
    
    		foreach ( $multilingual_snippet as $key => $val ){
    			$current = $val['current'] ? ' class="'.$val['current'].'" ' : '';
    			$flags_dir = get_bloginfo('template_directory');
       //Put correct flag dir Url here:
    		$flags_dir .= '/img/flags/';
    		$flag_icon = $flags_dir . $key . '.png';
    $flag_icon = '<img src="'.$flag_icon.'" style="float:right;margin:2px;padding:1px;border:1px solid #021a40;background-color:#ff0>"';
    			$html .= '<a href="'.$val['url'].'">'.$flag_icon.'</a>&nbsp';
    	}
    
    	echo $html;
    	}

    4) Put the following code in your theme "header.php" between <head>...</head> where you want the flags to display:

    <?php if ( function_exists( 'ps_012_multilingual_list' ) ) $gs = ps_012_multilingual_list() ; ?>

    That will do the trick.

  2. amonti
    Member
    Posted 1 year ago #

    Great, but just a small caution - if the plug-in is ever upgraded, the changes in function.php may be run-over. Users should remember to re-apply their changes to the new version of function.php.

    There a bunch of commented-out code for adding multi-language support for media files, so it's possible that an upgrade is in the works (hope so, anyway).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic