In another thread I asked for a js solution to my problem with a multilingual website. I guess, adding something like ?set=it
or ?set=en
at the end of the link.
I have not many pages with three languages (Italia, Spanish, English) in the the same webpage, with this code
html
<span lang='it'>Pubblicazioni</span><span lang='es'>Publicaciones</span><span lang='en'>Publications</span>
css
body[lang=it] *[lang]:not([lang="it"]){display:none;}
body[lang=en] *[lang]:not([lang="en"]){display:none;}
body[lang=es] *[lang]:not([lang="es"]){display:none;}
js
I can add that with js I can change (temporarily) the body webpage language.
This is the js code:
//multilingual
function setEn() {
document.body.setAttribute("lang", "en");
}
function setIt() {
document.body.setAttribute("lang", "it");
}
function setEs() {
document.body.setAttribute("lang", "es");
}
//-->
Function possibly called in every webpage with a link (<span onclick="setIt()">ita</span><span onclick="setEs()">esp</span><span onclick="setEn()">eng</span>
).
And this was why I tried before with js (setting from a link in an external website page), as I said. But unsuccessfully (at least, so far).
php
Every page has a php variable as body lang:
<body lang="<?php if(empty($lang)) {echo "it";} else {echo"$lang";} ?>" >
and so far my links (from a webpage to another of my website) go to a small php (such as members-es.php), that contains only the lang variable and the include
the matching complete webpage (with <span>
multilingual as above, in this case members.php).
my question
My question is: it would be possible to avoid this two-files system, and use something like this (in Example 3) to open the (only, at this point) target webpage setting its body lang from the link (<a href
>) in the starting webpage of my website?
Maybe using match function?