Support » Plugin: Age Gate » Multi-language Website

  • Resolved isabelk2j

    (@isabelk2j)


    Good day,
    Thanks for your quick response on my issue the other time, i really appreciate it.

    Please i’m working on a multi-language website (Chinese and English), in which Chinese is my default language, how can i translate the Headline text, Cookie Text and Validation text in Chinese and get it to show Chinese as Default (currently making English my default despite having Chinese as my default for the website) and maybe provide a hook to add the polylang Language switcher to the Age Verification Page (Footer hook will be nice) to switch between languages.

    Thank so much
    Izzy

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Phil

    (@philsbury)

    Hi Izzy,

    I’ll start with the easier of the two which is adding the language switcher. There’s a couple of filters you could use; age_gate_before and age_gate_after

    
    add_filter('age_gate_after', function($content){
    	return '<ul>' . pll_the_languages(array('echo' => false)). '</ul>';
    });
    

    There’s some reference for the hooks here:
    https://agegate.io/docs/hooks/filters/age_gate_after

    Next for the content, ideally this would be handled directly in the admin area, though I’m going to have to have a look into how I make that work unfortunately.

    In the meantime, there’s some other hooks you could use to get it to work until I work out how to support polylang fully

    For the messages, you could do (note I’m using French as the alternate language):

    
    add_filter('age_gate_messaging', function($html, $messages, $age){
    	$lang = pll_current_language();
    	if($lang === 'fr'){
    		$html = '<h2 class="age-gate-subheading">'. sprintf('Your custom message', $age) . '</h2>';
        $html .= '<p class="age-gate-message">' . sprintf('Your custom message', $age) .'</p>';
    	}
    
    	return $html;
    }, 10, 3);
    

    For the validation, are you using inputs or the buttons?

    Thanks
    Phil

    Plugin Author Phil

    (@philsbury)

    Hi again @isabelk2j,

    I’ve looked into the Polylang features and below is a link to a pre-release version if you want to try it. It adds support for translating all the messages plus setting a different default age for the language.

    As it’s pre release there may be the odd bug here and there as I’ve not fully tested everything yet, but feel free to try it and see it how it works for you.

    https://www.dropbox.com/s/8c174yv3dmxwisu/age-gate-2.1.0-beta3.zip?dl=0

    Thanks
    Phil

    Thread Starter isabelk2j

    (@isabelk2j)

    Thanks you so much Phil, you’ve been such a wonderful person… i will try out the pre-release code now

    Thread Starter isabelk2j

    (@isabelk2j)

    I have installed the beta version (and i can see a warning saying “You are using the beta3 version of Age Gate. This may not be suitable for production websites.” but i guess it doesn’t matter much right? i can use)

    I love the way we have option for polylang available languages and i have translated everything i wanted to translate in the plugin settings but one issue i have is even i access the website on the front end. it loads the secondary language (which is English).

    I’m working on a Chinese (primary language) website in which English is a secondary language but when i view the website on frontend, it launches the English (secondary language) instead of Spanish)

    Thread Starter isabelk2j

    (@isabelk2j)

    I can see that when i added the language switcher and changed the language to Chinese (which ought to be the default), the wording was translated as it should be but the age-gate-before and age-gate-after hook are showing up in the left and right side respectively (as seen in the image file (red box) ) and not top and bottom like in the green box locations as seen in the image file https://www.dropbox.com/s/mzakk4twd8b1qcc/screenshot-localhost-2018-08-22-14-29-46-438.png?dl=0

    What can i do Phil. Thanks so much for your help so far.

    What i need done.
    1. making chinese my Default load language
    2. making the before and after hook load on the green box location, so i can better style the language switcher

    Thanks

    Thread Starter isabelk2j

    (@isabelk2j)

    Please is the current plugin version fully compatible with WPML… i want to switch from Polylang to WPML.. the polyland is giving me hard time (i.e having to add pll__ to translate every string on the website, want to go with WPML which uses __, _x, _e out of the box.

    Does age gate fully compatible with WPML before i switch over?

    Plugin Author Phil

    (@philsbury)

    Hi Izzy,

    I’ll try and run through all your questions in one go.

    For the default language, age gate should detect the current language and use those settings. For Polylang/WMPL I think they’re both in the settings for those plugins.

    To use WPML and Age Gate you can just switch your language plugin and it’ll work.

    For the layout, you can add the following in the CSS editor in the advanced tab:

    
    .age-gate-wrapper {
     flex-flow: column;
     justify-content: center;
    }
    
    .age-gate {
     margin: 0 auto;
    }
    

    Hope that helps.

    Thanks,
    Phil

    Thread Starter isabelk2j

    (@isabelk2j)

    Thanks Phil, I will work with your instructions and get back to you on the result 🙂

    Thread Starter isabelk2j

    (@isabelk2j)

    After Adding this code;

    
    function add_switcher_to_age_gate(){
    	$wpml_short = do_shortcode('[wpml_language_selector_footer]');
    	return $wpml_short;
    }
    add_filter('age_gate_after', 'add_switcher_to_age_gate');
    
    

    The Switcher still appears at the top of the age verification page and not bottom… Not sure what’s going on but i have added the CSS. I even inspected element and disable the above code but yet same thing. Sorry if i’m a pain in the ass, just want to make it each for users to switch between languages

    Plugin Author Phil

    (@philsbury)

    Hi Izzy,

    Do you have any caching, might be worth clearing it if you do?

    I’ve just tried it on one of my local versions with wpml installed and it worked ok, here’s a screen shot:

    View post on imgur.com

    If you have a link I’d be happy to have a look

    Thanks,
    Phil

    Thread Starter isabelk2j

    (@isabelk2j)

    Wasn’t working with the previous version, i just updated to the newer version (which just notified me in the plugin page and the test “Hello Testing” working perfectly; as in;

    
    function add_switcher_to_age_gate(){
    	return 'Hello Testing';
    }
    add_filter('age_gate_after', 'add_switcher_to_age_gate');
    
    

    Let me now try it with the WPML shortcode

    Thread Starter isabelk2j

    (@isabelk2j)

    Worked perfectly … Thanks Phil for the help, you’re the best!

    • This reply was modified 5 years, 6 months ago by isabelk2j.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Multi-language Website’ is closed to new replies.