Hello, I would like to know if it is possible to hide certain elements on the english site, show them on the dutch site and the other way around. is there any way to do this with code? Or is there an easy trick?
Please let me know.
Hello, I would like to know if it is possible to hide certain elements on the english site, show them on the dutch site and the other way around. is there any way to do this with code? Or is there an easy trick?
Please let me know.
$w(“#myChoosenElement”).show()
$w(“#myChoosenElement”).hide()
for example with BUTTONS —> $w(“#button1”).show()
or tables -----------------------------> §w("#table1).hide()
Thanks a lot!
But how does the code determine whether it show on the english site or dutch site?
Perhaps, you will find your answer in this post.
Just found it a few seconds ago…
https://www.wix.com/corvid/forum/community-discussion/auto-detect-language-based-off-browser-solved
Hi,
I see you want to hide certain elements on a page depending on what language is chosen.
You could achieve this using the multilingual API which is a part of the wix-window API. Please click here for more information about this.
Assuming that you are using a database collection and dataset to hold and display the elements you mentioned.
You could set up a collection which contains the elements you would like displayed in each language. Within this collection you could create a language field that indicates each item’s language. This example filters a dataset connected to the collection so it only contains items that correspond to the site’s current language.
import wixWindow from 'wix-window';
import wixData from 'wix-data';
// ...
$w.onReady( function () {
let language = wixWindow.multilingual.currentLanguage;
$w("#myDataset").setFilter( wixData.filter().eq("language", language) );
} );
If this doesn’t help you achieve what you want please send us a link to your site and let us know which elements exactly that you would like displayed on what languages, and we will see if we can help further.
Dara | Corvid Team
Hi, leonmissoul ![]()
Start by importing the Wix-Window module:
import wixWindow from 'wix-window';
Now define a new variable called “language” or whatever you want:
let language = wixWindow.multilingual.currentLanguage;
Now you can perform any action depending on the current language, for example:
if (language === 'en') {
$w('#enButton').expand();
hideOtherButtons('en');
console.log(`The current language is (${language})`)
} else {
$w('#enButton').collapse();
showCurrentButton('en');
console.log(`The current language is (${language})`)
}
I’ve demonstrated how you can expand(), collapse() or even run different functions depending on the current language.
Hope that helped ~!
Ahmad
Thanks a lot! I tried it but didn’t work.
My code:
import wixWindow from 'wix-window';
let language = wixWindow.multilingual.currentLanguage;
if (language === 'en') {
$w('#input7').expand();
$w('#dropdown2').expand();
$w('#text29').expand();
$w('#input6').collapse();
$w('#dropdown1').collapse();
$w('#text12').collapse();
} else {
$w('#input7').collapse();
$w('#dropdown2').collapse();
$w('#text29').collapse();
$w('#input6').expand();
$w('#dropdown1').expand();
$w('#text12').expand();
}
Can you help me why it isn’t working?
Thanks in advance
Hi, you need to include the if statement inside the page’s onReady() function.
Hi,
It’s not working because you’re not calling the if statement, you need to include it inside the page’s onReady() function, or inside any event that triggers the if statement.
thank you so much, it worked!
You’re welcome, glad that it worked! ![]()
Could you help me out on this question? I would really appreciate it.
I’ll check it out …
Hi,
I want to make audio player hidden when turkish language is selected. I tried so hard but could not make it work. Can you please tell me what is wrong with that code. Thank you so so much:
// Velo API Reference: Introduction - Velo API Reference - Wix.com
import wixWindow from ‘wix-window’ ;
$w . onReady ( function () {
let language = wixWindow . multilingual . currentLanguage ;
if ( language === “TR” ) {
$w ( “#audioPlayer1” ). hide ();
} else {
$w ( “#audioPlayer1” ). show ();
// Write your Javascript code here using the Velo framework API
// Print hello world:
// console.log("Hello world!");
// Call functions on page elements, e.g.:
// $w("#button1").label = "Click me!";
// Click "Run", or Preview your site, to execute your code
});
Please open your own post instead of bumping-up old ones.
Hi Dara, I am trying to implement your suggested solution to my website and can’t seem to be able to do so. Can you help me out?