Documentation > Developers > Custom Language Switcher

Custom Language Switcher

Browse Docs
Search Documentation
If you wish to design a custom TranslatePress language switcher, there is a function you can implement to help you with all the necessary information when using the plugin.

Create a TranslatePress Custom Language Switcher

The function that needs to be called is trp_custom_language_switcher().
The function returns an array with the following parameters:
  • $custom_ls_array[$language_code]['language_name'] – the full language name
  • $custom_ls_array[$language_code]['language_code'] – the language code of the respective language
  • $custom_ls_array[$language_code]['short_language_name'] –  the language code of the language, the slug which will be used in the url
  • $custom_ls_array[$language_code]['flag_link'] – a link to the flag of the respective language
  • $custom_ls_array[$language_code]['current_page_url'] – the URL of the current language with the language slug added

 

Here is an example of a custom-made language switcher:

TranslatePress custom language switcher

While here you can see the code snippet:

Note: You need to have data-no-translation on the wrapper with the links or TranslatePress will automatically translate them in a secondary language.​

You can also create a custom language switcher shortcode that you can then use like [custom-language-switcher]

If you just need to quickly create a classic language switcher, check out TranslatePress’ default language switcher settings.

TranslatePress Multilingual

The best website localization service for WordPress websites. Manage everything from a visual interface.