• Resolved nadine

    (@ninablue)


    Hello,

    I want to create a custom language switch which only displays the language codes (EN and DE) and not the full names. Therefore I used the “print_custom_language_switch” filter, see here https://www.faboba.com/wordpress/falang-for-wordpress/documentation/119-how-to-configure-language-switcher.html . However, it doesn’t seem to get applied. I have a language switcher in my main menu in the header and a language switcher embedded via a widget. How can my changes be applied to the language switchers?

    And a suggestion from my side is to add the option to display only language codes to the options in the default language switcher.

    Thanks for the help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author sbouey

    (@sbouey)

    Hi, the easier way for that is probably by shortcode , look in the documenation and use

    [falangsw display_name="1" display_flags="0" ]

    and put EN or DE in your language name

    Thread Starter nadine

    (@ninablue)

    Thank you for your fast reply @sbouey. I changed the language names to the language codes. Anyway, I would prefer an option in the language switcher to only display language codes instead of language names.

    There is one other topic. My client wants to have a separation between the languages in the language switcher, such as EN | DE | FR . I manually added the “|” with JavaScript as single list items between the language names. I was just wondering if there is a cleaner way to achieve this? Perhaps for this goal the filter would be useful. Still curious about how it’s supposed to work. Can you give further explanation?

    Plugin Author sbouey

    (@sbouey)

    Hi,

    In your case custom code is better , i use this on my Falang for Divi Demo site

    
    function et_header_top_hook_falang() {
    	add_action('print_custom_language_switch', 'custom_language_switch', 10, 2);
    	do_action('falang_print_language_switch');
    }
    
    function custom_language_switch($languages, $falang) {
    //test
    	?>
    	<ul class="falang-language-switcher nav">
    		<?php
    		foreach ($languages as $language) {
    			$file = FALANG_DIR.'/flags/' . $language->flag_code . '.png';
    			if ( ! empty( $language->flag_code ) && file_exists( $file) ) {
    				$flag_url = plugins_url( 'flags/'.$language->flag_code . '.png', FALANG_FILE );
    			}
    			?>
    			<li class="<?php echo $language->slug; ?><?php if ($falang->is_default($language)) echo ' current'; ?>">
    				<a href="<?php echo $falang->get_translated_url($language); ?>"><img src="<?php echo $flag_url; ?>" alt="<?php echo $language->name;?>"/> </a>
    			</li>
    		<?php } ?>
    	</ul>
    	<?php
    
    }
    

    you can remove the flag code and use the code (slug) and your | in the loop

    Thread Starter nadine

    (@ninablue)

    Here too. I forgot to mark this topic as resolved. I made some customizations to the filter you suggested and it worked. Thank you!

    Plugin Author sbouey

    (@sbouey)

    Thanks to put it as resolved even if it’s 2 months after.

    Stéphane

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom language switch not applied’ is closed to new replies.