• Hi.

    The ‘bpml_icl_ls_languages_filter’ removes items from the lang array if the requested slug is not part of BP’s active components and if the lang’s URL is home (lines 206 to 216 of frontend.php). The first issue is the following:

    • It doesn’t deal with Sitepress’s ‘icl_lso_link_empty’ option as it should
    • It “forgets” valid BP slugs like ‘register’ and ‘activate’ which are not BP active components (and maybe more)

    What is this code meant to as it’s been added only since the 1.2.0 release? Shouldn’t it be simply removed as Sitepress already deals with missing translations?

    Additionally, the new code for BP 1.5 (lines 218 to 238) recreates the lang array but not the same way as Sitepress:

    • It leaves several attributes that Sitepress removes (‘code’, ‘english_name’, ‘display_name’ and ‘translated_url’)
    • It doesn’t translate the name (‘translated_name’=’english_name’!)

    Finally, the condition on line 218 is not right: it should be 1.5 instead of 1.2.9.

    As a result in my opinion, this function should be deeply reviewed and fixed.

    Thanks.

    https://www.ads-software.com/extend/plugins/buddypress-multilingual/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi npetetin,

    Thanks for your good review, We’ll review and fix it in our secondly BPML release.

    Thread Starter npetetin

    (@npetetin)

    As I also posted in WPML forum (https://forum.wpml.org/topic.php?id=5585), it has to adjust the ‘active’ attribute too (all languages are currently left active).

    Thanks.

    I see npetetin, thanks

    Thread Starter npetetin

    (@npetetin)

    Hi.

    It hasn’t been fixed at all in 1.3.0 release, has it?

    Here is the code of the function as it should be:

    function bpml_icl_ls_languages_filter($langs) {
    	global $sitepress, $bp, $bp_unfiltered_uri;
    	$default_language = $sitepress->get_default_language();
    
    	if(!isset($bp_unfiltered_uri[0])){
    		$bp_unfiltered_uri[0] = '';
    	}
    
    	// Recreates language selector - the all components should have all languages
    	if(version_compare(BP_VERSION, '1.5') >= 0){
    		$langs = $sitepress->get_active_languages();
    		$url = '';
    		foreach($bp_unfiltered_uri as $key => $path){
    			$url .= '/' . $path;
    		}
    
    		$homepage = get_option('home');
    		$urlToFlags = ICL_PLUGIN_URL . '/res/flags/';
    		foreach ($langs as $key => $lang) {
    			$langs[$key]['country_flag_url'] = $urlToFlags . "$key.png";
    			$langs[$key]['language_code'] = $key;
    
    			if($translated_name = $sitepress->get_display_language_name($key, $sitepress->get_current_language())){
    				$langs[$key]['translated_name'] = $translated_name;
    			} else {
    				$langs[$key]['translated_name'] = $lang['english_name'];
    			}
    
    			if($default_language == $key){
    				$langs[$key]['url'] =  $homepage . $url;
    			} else {
    				$langs[$key]['url'] =  $homepage . '/' . $lang['code'] . $url;
    			}
    
    			if($sitepress->get_current_language() == $key){
    				$langs[$key]['active'] =  '1';
    			} else {
    				$langs[$key]['active'] =  0;
    			}
    
    			unset($langs[$key]['code']);
    			unset($langs[$key]['english_name']);
    			unset($langs[$key]['display_name'] );
    		}
    	} else {
    		if (!in_array($bp_unfiltered_uri[0], $bp->root_components)) {
    			return $langs;
    		}
    
    		foreach ($langs as $key => $lang) {
    			$langs[$key]['url'] = $sitepress->convert_url(get_option('home')
    					. '/' . implode('/', $bp_unfiltered_uri), $lang['language_code']);
    		}
    	}
    	return $langs;
    }

    You can copy-paste it, it works pretty well!

    Thanks.

    Hi,

    I see that your solution is better, I’ll test/review it thoroughly and I think it will be added to next release of BPML

    Thanks

    Jonas

    (@wieseljonas)

    Hi,

    I tried but it’s not working for me…

    If I switch to my secondary language it redirects me to the homepage.
    It even breaks buddypress pages that used to work.

    Thanks in advance for advice,

    Jonas

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: BuddyPress Multilingual] Language filter bug in 1.2.1’ is closed to new replies.