Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

how to display language choices when logged out?

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

  • 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);
                 }
    
  • Or try the plugin TranslateThis and make it only show for logged out users.

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

  • @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.

  •  !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.

  • @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 Admin

    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

  • @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 Admin

    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.