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?
intalik
New
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
0
Comments
It looks like the plugin checks for session and blocks the view unless signed in , I wonder why ....
here
and here
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
my guess:
because if someone is not logged in they essentially have no userid.
so it would set usermeta for a guest of id 0
therefore any other guest would set userid 0 to their own locale and it would conflict with any other guest who is also a userid 0.
maybe a cookie would be the way to go in the case of userid 0
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Or try the plugin TranslateThis and make it only show for logged out users.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I understand. Guest id = 0 makes sense to me.
Hi @vrijvlinder
I commented all here:
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.
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.
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
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:
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.