• Resolved marcreig

    (@marcreig)


    Morning!

    I need to know how to specify language names on the switcher for every language.

    So I have Spanish and English in my site, and I want to show “English | Spanish” when the site is in English and “Inglés | Espa?ol” when site is in Spanish.

    And even change the language order for every language as “English | Spanish” when in English, and “Espa?ol | Inglés” when in Spanish.

    Is it possible?
    How do I achieve this?

    Thank you so much!

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    It’s possible if you have some php knowledge to build your own custom language switcher. To help you in this, you can call pll_the_languages(array('raw'=>1)) to get all relevant data. See the documentation for more information.
    You will have to download the current development version as the ‘raw’ option is not available in the current stable version.
    https://downloads.www.ads-software.com/plugin/polylang.zip

    Thread Starter marcreig

    (@marcreig)

    Thank you!

    But I’ve finally decided to create a different way. I was waitting to your answer to see if there was a simply way to do that. As it required programming, I’ve done this:

    <div class="languages">
    	<ul>
    		<?php
    			$languages = pll_the_languages(array('echo'=>0));
    			echo preg_replace_callback('/(<a.+>)([^<]+)(<\/a>)/i', function($m){
    				return $m[1].pll__($m[2]).$m[3];
    			}, $languages);
    		?>
    	</ul>
    </div>

    And I’ve created the words “English” and “Espa?ol” in functions.php, and added the translations in Admin board.

    ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Switcher names and order: how to change'em and vary for every language?’ is closed to new replies.