• Resolved ste_yeu

    (@ste_yeu)


    Hi,

    I’m using this great plugin but I need to translate my website in 2 languages, so Pie-Register should be translated in each specific page of each specific language.

    How can I add lang in shortcode?

    Generally most of plugins use this in their shortcodes:

    [pie_register_form lang="en"]

    [pie_register_form lang="it"]

    ...

    I’ll translate all the plugin in my language (italian) and after I’ll upload it in GitHub… but first I need your help, please! 🙂

    Thanks in advance.

    https://ww.wp.xz.cn/plugins/pie-register/

Viewing 1 replies (of 1 total)
  • Thread Starter ste_yeu

    (@ste_yeu)

    I resolved by myself.

    First of all, I suggest to use the plugin called “Polylang”, a great plugin to translate any part of your site.

    With Polylang you can create a page for each language and after you can “connect” every specific page in every specific language.

    So, you can put the shortcode of Pie Register in each registration page (one for each language):

    [pie_register_form]

    Then you need to translate every label field, example:

    “Your Name” > “Il tuo Nome”.

    To do this you can use if else in php to change css display=inherit/none.

    So, in WP backend go to Form Editor, create your form and use <span> for each text, example:

    <span>Last Name</span><span>Cognome</span>

    <span>English text</span><span>Testo Italiano</span>

    Then go to header.php of your theme and put this code in tag <head>:

    <?php
    
    		$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; // url page
    
    			if (false !== strpos($url,'en')) { // find str 'en' in url
        			echo '<style type="text/css">
    				label span:nth-child(1) { display:inherit; }
    				label span:nth-child(2) { display:none; }
    				</style>';
    		} else {
    			echo '<style type="text/css">
    				label span:nth-child(1) { display:none; }
    				label span:nth-child(2) { display:inherit; }
    				</style>';
    			}
    	?>

    Now you’ll see the specific text for each language. 🙂

    Sorry for my English, I hope it’s clear.

Viewing 1 replies (of 1 total)

The topic ‘Set lang in shortcode’ is closed to new replies.