This thread is resolved. Here is a description of the problem and solution.
Problem:
Need to check in which language users viewing my website so I can show them different content in views and content templates. Just need to use a conditional in a content template so if wordpress changes to english then I should show different content to users. Is that possible?
Solution:
In a View or Content Template or Layout template you can detect language something like this:
[wpv-conditional if="( '[wpv-bloginfo show="language"]' eq 'en-US' )"]
Language is english
[/wpv-conditional]
[wpv-conditional if="( '[wpv-bloginfo show="language"]' eq 'ar' )"]
Language is Arabic
[/wpv-conditional]
I need to check in which language users viewing my website so I can show them different content in views and content templates. I have manually translated with poedit. Before header exists the tag <html lang=en_US> with the language code or <html lang=el>. Is there a way to check in a conditional which version of the website a user is viewing and show him different content in views and templates? How could I check the locale?
Thank you for contacting Toolset support. To translate Views and Content Template created with Toolset we recommend to use WPML plugin as it provides you with language switcher and natively support multilingual sites. Below are the docs explain this process:
Other than that falls into Custom coding & custom development and it is out of support policy (https://toolset.com/toolset-support-policy/). So we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/
I am sorry for the delayed response... What I am trying to achieve is to detect in which language wordpress is running and not to detect the user's browser language. If I use wp in my language the code in the beginning of html is <html lang=el>. If I change the language from the dashboard to english, the code changes to <html lang=en_US>. I just need to use a conditional in a content template so if wordpress changes to english then I should show different content to users. Is that possible?
In a View or Content Template or Layout template you can detect language something like this:
[wpv-conditional if="( '[wpv-bloginfo show="language"]' eq 'en-US' )"]
Language is english
[/wpv-conditional]
[wpv-conditional if="( '[wpv-bloginfo show="language"]' eq 'ar' )"]
Language is Arabic
[/wpv-conditional]
Please try it, I hope this will resolve the issue. Thank you