Title: [Plugin: Gengo] Select Language Hack
Last modified: August 19, 2016

---

# [Plugin: Gengo] Select Language Hack

 *  Resolved [timtak](https://wordpress.org/support/users/timtak/)
 * (@timtak)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-gengo-select-language-hack/)
 * If you have more than one language on your blog then it is possible to display
   all the languages as it seems sensible to do, to new visitors.
 * Alas however, the “gengo_display_languages” tag in gengo_template_functions.php
   only displays a link to select a language if the language is not already selected.
   It should display links if the language is not *UNIQUELY* selected
 * E.g. let us say you have 100 English posts and 10 French Posts on your blog and
   a French person comes to the splash page which is set to display blogs in both
   languages. “Quoi?” He says, because he is faced with a blog *mainly* in English,
   and he goes to select French ONLY but he can not, because French is already one
   of the languages selected.
 * In addition to “is_set_language” I guess there should be another function “is_uniquely_set_language”
   since it is only when this is true that we do not want links.
 * Anyway, I hacked gengo to always display the link to select language (even if
   uniqulely selected) by changing this code
 *     ```
       function gengo_list_languages($arguments = '') {
       	global $gengo, $wp_rewrite;
   
       	$default_args = array('pre' => '<li>', 'post' => '</li>', 'show_count' => 'true', 'show_current' => 'true', 'show_unreadable' => 'true', 'snippet' => '', 'content_type' => 'post');
         parse_str($arguments, $args);
         $args = array_merge($default_args, $args);
   
       	if (!$gengo->languages) {
       		echo $args['pre'] . __('No Languages Defined', GENGO_DOMAIN) . $args['post'];
       	} else {
       		$titles = ($args['snippet']) ? $gengo->get_synblocks($args['snippet']) : array();
       		$home = trailingslashit($gengo->site_home);
       		if ($wp_rewrite->using_index_permalinks()) $home .= $wp_rewrite->index;
       		$totals = $gengo->get_totals($args['content_type']);
       		asort($gengo->languages);
       		foreach ($gengo->languages as $language_id => $entry) {
       			if ($post_count = $totals[$language_id]) {
       			  if ('false' != $args['show_count']) $count_string = " ($post_count)";
       			  $gengo->forced_append = true;
       				if (('false' != $args['show_unreadable']) || (false !== strpos($gengo->viewable_code_string, $entry->code))) {
       	  			$title = $titles[$language_id] ? $titles[$language_id] : $entry->language;
       					if (false === $gengo->is_set_language($language_id)) {
       						echo "$args[pre]<a class=\"gengo_lang_$entry->code\" href=\"" . $gengo->append_link_language($home, $entry->code) . "\" hreflang=\"" . $entry->code . "\">$title</a>$count_string$args[post]";
       					} else {
       					  if ('false' != $args['show_current']) {
       							echo "$args[pre]<span class=\"gengo_lang_$entry->code\">$title$count_string</span>$args[post]";
       						}
       		 			}
       				}
       			}
       		}
       	}
       }
       ```
   
 * to this code
 *     ```
       function gengo_list_languages($arguments = '') {
       	global $gengo, $wp_rewrite;
   
       	$default_args = array('pre' => '<li>', 'post' => '</li>', 'show_count' => 'true', 'show_current' => 'true', 'show_unreadable' => 'true', 'snippet' => '', 'content_type' => 'post');
         parse_str($arguments, $args);
         $args = array_merge($default_args, $args);
   
       	if (!$gengo->languages) {
       		echo $args['pre'] . __('No Languages Defined', GENGO_DOMAIN) . $args['post'];
       	} else {
       		$titles = ($args['snippet']) ? $gengo->get_synblocks($args['snippet']) : array();
       		$home = trailingslashit($gengo->site_home);
       		if ($wp_rewrite->using_index_permalinks()) $home .= $wp_rewrite->index;
       		$totals = $gengo->get_totals($args['content_type']);
       		asort($gengo->languages);
       		foreach ($gengo->languages as $language_id => $entry) {
       			if ($post_count = $totals[$language_id]) {
       			  if ('false' != $args['show_count']) $count_string = " ($post_count)";
       			  $gengo->forced_append = true;
       				if (('false' != $args['show_unreadable']) || (false !== strpos($gengo->viewable_code_string, $entry->code))) {
       	  			$title = $titles[$language_id] ? $titles[$language_id] : $entry->language;
       	  			//timtak this is incorrect, since it only displays the links if the
       	  			//language is completely unset, even if it is one of several languages.
       				//	if (false === $gengo->is_set_language($language_id)) {
       						echo "$args[pre]<a class=\"gengo_lang_$entry->code\" href=\"" . $gengo->append_link_language($home, $entry->code) . "\" hreflang=\"" . $entry->code . "\">$title</a>$count_string$args[post]";
       				//	} else {
       				//	  if ('false' != $args['show_current']) {
       				//			echo "$args[pre]<span class=\"gengo_lang_$entry->code\">$title$count_string</span>$args[post]";
       				//		}
       		 		//	}
       				}
       			}
       		}
       	}
       }
       ```
   
 * [http://wordpress.org/extend/plugins/gengo/](http://wordpress.org/extend/plugins/gengo/)

The topic ‘[Plugin: Gengo] Select Language Hack’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [timtak](https://wordpress.org/support/users/timtak/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-gengo-select-language-hack/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
