Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

how to display language choices when logged out?

This discussion is related to the Multilingual addon.

I'd like my visitors to have the option to choose language even when they are not logged in.

Is this possible?

p.s. using multilingual V1.1

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited December 2014

    It looks like the plugin checks for session and blocks the view unless signed in , I wonder why ....

    here

         // Block guests until guest sessions are restored
                  if ($Sender->MasterView == 'admin' || !CheckPermission('Garden.SignIn.Allow'))
                     return;
    

    and here

     if ($Locale) {
                    Gdn::Session()->Stash('Locale', $Locale);
                    if (CheckPermission('Garden.SignIn.Allow'))
                       $this->SetUserMeta(Gdn::Session()->UserID, 'Locale', $Locale);
                 }
    
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Or try the plugin TranslateThis and make it only show for logged out users.

  • I understand. Guest id = 0 makes sense to me.

  • kopnakopna Coimbra Portugal ☯

    @vrijvlinder написал:
    It looks like the plugin checks for session and blocks the view unless signed in , I wonder why ....

    here

    // Block guests until guest sessions are restored
    if ($Sender->MasterView == 'admin' || !CheckPermission('Garden.SignIn.Allow'))
    return;

    and here

    if ($Locale) {
    Gdn::Session()->Stash('Locale', $Locale);
    if (CheckPermission('Garden.SignIn.Allow'))
    $this->SetUserMeta(Gdn::Session()->UserID, 'Locale', $Locale);
    }

    Hi @vrijvlinder

    I commented all here:

    // Block guests until guest sessions are restored
    //if ($Sender->MasterView == 'admin' || !CheckPermission('Garden.SignIn.Allow'))
    //return;

    Fine. Now Language bar is available for translation:

    but the translation is not working. Question - what needs to be done to make the plugin work properly?
    P.S: plugin TranslateThis in my case - is not working.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
     !CheckPermission('Garden.SignIn.Allow')
    

    The ! in front means, if it does not have permission to sign in , then it won't show.

    try without the !

    do not comment stuff out without knowing what it does first.

  • kopnakopna Coimbra Portugal ☯

    @vrijvlinder написал:
    !CheckPermission('Garden.SignIn.Allow')

    The ! in front means, if it does not have permission to sign in , then it won't show.

    try without the !

    do not comment stuff out without knowing what it does first.

    Thank you for the hint. Choosing language page just rebooted and everything remains unchanged.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    The answer has already given by peregrine: the language is a user setting: it is saved in the UserMeta and taken from there. Since there is no UserMeta for a guest, the plugin couldn't work for guests.

    You would have to add an additional way to store and retrieve language settings for guests (maybe a cookie like peregrine suggested)

    Storing must be added here:
    https://github.com/vanilla/addons/blob/master/plugins/Multilingual/class.multilingual.plugin.php#L145

    Retrieval must be added here:
    https://github.com/vanilla/addons/blob/master/plugins/Multilingual/class.multilingual.plugin.php#L110

    And you would have to search for all is-user-signed-in-checks and bypass them, so that the plugin is usable for guests

    kopna
  • kopnakopna Coimbra Portugal ☯

    @R_J

    I could not understand the code to make changes to it correctly display languages. If you can offer help, please contact to P.M I will be grateful

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    There is no code given that you can understand. Doing that changes is non-trivial. I'm afraid I will not find time to do the work. I could advice, however.

    Go through the plugins code and look out for everything which looks like that:

            if (!Gdn::Session()->UserID) {
                throw PermissionException('Garden.SignIn.Allow');
            } 
    

    At those places you would have to try to read a cookie which identifies a guest. If there is no such cookie, you would have to set it.

    Maybe you should start by writing such a method.

Sign In or Register to comment.