Skip to main content
Le panier est vide

How to configure language switcher

This tutorial will guide you to configure the language switcher on your site with Falang for Wordpress.

The purpose of the language switcher is to create links to the translations of your current page. If the current page is untranslated, the default language is displayed. For post with a specific locale set the language switcher display an inactive flag or name.

Actually you have 3 ways to add the language switcher to your site and the fourth version will be available soon.

  1. Widget
  2. Menu
  3. by code
  4. Shortcode

1) Widget

You can add a language widget to your site to any posistion supported by your template. several widget can be added all widget can be configured Independently.

2) Menu

You can include the language switcher in your menu. If you don’t see the language switcher metabox, check that it is not disabled in the screen options.

In this case in the Menu page to to screen options on top right of your screen and check the “Language switcher” checkbox. You then should have a new metabox which allows you to add a language switcher the same way you add other menu items.

3) By code

You can add an action 

add_action(‘print_custom_language_switch’, ‘custom_language_switch’, 10, 2);

and the display can be changed like this

function custom_language_switch($languages, $falang) {

?>
<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’; ?>”>
get_translated_url($language); ?>”>” alt=”<?php echo $language->name;?>”/>

<?php } ?>

<?php

}
?>

4) Shortcode

You can add this shortcode [falangsw]

by default the name are displayed but this can be changed with this parameter's

  • dropdown (not yet working 1.3.25)
  • display_name
  • display_flags
  • hide_current
  • positioning h or v (default h)

Exemple if you want to have the flag displayed horizontaly you have to use this shortcode:
[falangsw display_name="0" display_flags="1" ]