Page 2 of 4

Posted: Sat 6. Aug 2005, 12:47
by Fexxx
navigation = site strucure (category title:) ?

Posted: Mon 5. Sep 2005, 00:11
by ChantalC
Hi Fulvio,

I tested your script. It's working good, but the switching is too slow.

When does your next Version come?

I could need it.

Posted: Wed 7. Sep 2005, 16:27
by Fulvio Romanin
sorry, here it is:
same usage, paste this code below in a file called languages.js

-------------------------------------------------------------------------

/*
* Shows document in specified language, via Javascript
* For use with phpwcms language extensions
*
* Remembers user preferred language via cookies. Language cookie expires at end of session (browser close)
*/
var strCurrentLanguage = 'IT'; // language to start with (default language)
var aAvailableLanguages = new Array('IT','EN','DE'); // array pf available languages in the document
var strLanguageCookieName = 'currentLanguage'; // name of the cookie where selected language is stored
var strInvisibleOnLoadClass = 'invisibleonload'; // name of the class wick marks elements invisible on page load (this script makes them visible)
var bLanguageDebug = false; // if set to true show alerts during transoformation steps


// ----------------------------------------------------------------------
// Do not edit below this line
// ----------------------------------------------------------------------
function addEventFunction(strEvent, fFunction, oObject)
{
if (!oObject) oObject = window;
if (oObject.addEventListener) {
oObject.addEventListener(strEvent, fFunction, true);
return true;
} else if (oObject.attachEvent) {
return oObject.attachEvent('on'+strEvent, fFunction);
} else {
return false;
}
}
function setLanguageCookie()
{
document.cookie = strLanguageCookieName+"="+strCurrentLanguage;
}
function getLanguageCookie() {
var strCookie=""+document.cookie;
var iPos=strCookie.indexOf(strLanguageCookieName);
if (iPos==-1) return "";
var iPos2=strCookie.indexOf(';',iPos);
if (iPos2==-1) iPos2=strCookie.length;
return unescape(strCookie.substring(iPos+strLanguageCookieName.length+1,iPos2));
}
function langTagOpen(strLanguage)
{
return '{'+strLanguage+'}';
}
function langTagClose(strLanguage)
{
return '{/'+strLanguage+'}';
}
function stripLanguage(strText,strLanguage)
{
var aSplittedText = strText.split(langTagOpen(strLanguage));
var strLanguageText = aSplittedText[0];
for (var i = 1; i < aSplittedText.length; i++) {
var aSplittedText2 = aSplittedText.split(langTagClose(strLanguage));
strLanguageText += aSplittedText2[1];
}
return strLanguageText;
}
function parseTextLanguage(strText)
{
var strLanguageText = strText;
for (var i = 0; i < aAvailableLanguages.length; i++) {
if (aAvailableLanguages != strCurrentLanguage) {
strLanguageText = stripLanguage(strLanguageText,aAvailableLanguages);
}
}
strLanguageText = strLanguageText.replace(new RegExp(langTagOpen(strCurrentLanguage),"g"),'');
strLanguageText = strLanguageText.replace(new RegExp(langTagClose(strCurrentLanguage),"g"),'');
return strLanguageText;
}
function parseLanguageDocument()
{
if (bLanguageDebug) alert('languages.js: Starting...');
var prefLanguage = getLanguageCookie();
var prefOk = false;
for (var i = 0; i < aAvailableLanguages.length; i++) {
if (aAvailableLanguages == prefLanguage) prefOk = true;
}
if (!prefOk)
setLanguageCookie();
else {
strCurrentLanguage = prefLanguage;
setLanguageCookie();
}
parseLanguageElements();
if (bLanguageDebug) alert('languages.js: Translation done.');
}
function parseLanguageElements(oNode)
{
if (!oNode) oNode = document.body;
if (strInvisibleOnLoadClass=="") return;
if (oNode.className == strInvisibleOnLoadClass) {
if (!oNode.innerHTML) return;
if (!oNode.originalHTML) oNode.originalHTML = oNode.innerHTML;
oNode.innerHTML = parseTextLanguage(oNode.originalHTML);
if (bLanguageDebug) alert('languages.js: Translated block.');
oNode.style.visibility = 'visible';
if (bLanguageDebug) alert('languages.js: Block made visible.');
}
if (!oNode.childNodes) return;
for (var i = 0; i < oNode.childNodes.length; i++)
parseLanguageElements(oNode.childNodes);
}
function changeLanguage(strLanguage)
{
if (strLanguage == strCurrentLanguage) return;
for (var i = 0; i < aAvailableLanguages.length; i++) {
if (aAvailableLanguages == strLanguage) {
strCurrentLanguage = strLanguage;
setLanguageCookie();
parseLanguageElements();
}
}
}
addEventFunction('load',parseLanguageDocument);

Posted: Thu 8. Sep 2005, 14:41
by ChantalC
Hi Fulvio,

First thanks for your new langague code.

I have uploaded your new languages.js file, but now the switch between the languages works not anymore. Now I see both Languages = DE and EN.

:cry:

Posted: Fri 9. Sep 2005, 14:13
by Fulvio Romanin
you should have links like

<a href="#" onmouseover="changeLanguage('IT');">link</a>

it's working on http://www.fieradellamusica.it - try to look at the source code... :?

Posted: Fri 9. Sep 2005, 21:57
by ChantalC
Yes, I had this links. I only changed the languages.js file.

But I don't understand it anymore, the new file will not work. I'm driving crasy. :cry:

Working with the old languages.js: http://www.artdeco-zeidler.de/index.php?tische

Not working the new languages.js: http://www.artdeco-zeidler.de/index.php?sofa

Do you have any idea?

Posted: Fri 9. Sep 2005, 22:12
by Fulvio Romanin
did you insert
<style type="text/css">.invisibleonload {visibility:hidden}</style>

before?

Posted: Fri 9. Sep 2005, 22:25
by ChantalC
Yes, I have seen this in your sourcecode.

Posted: Sun 18. Sep 2005, 18:56
by ChantalC
Fulvio Romanin wrote:did you insert
<style type="text/css">.invisibleonload {visibility:hidden}</style>

before?

Now it works great. Thanks for this script.

I found the required parts to set the "invisibleonloads".

Thanks.

Posted: Mon 19. Sep 2005, 02:20
by Fulvio Romanin
glad you liked it ;)

Posted: Sat 28. Jan 2006, 17:44
by sebby
Hello all-

For those beginners like me experiencing difficulties with the second version of this nice script from Fulvio, don't forget the following changes in your template:

(1) Add this line in your html head:
<style type="text/css">.invisibleonload {visibility:hidden}</style>

(2) your multilang content must be delimited by the "invisibleonload" class tag:

<div class="invisibleonload">{CONTENT}</div>

so open your header with: <div class="invisibleonload"> and close your tag in the footer section of your template '</div>').

Cheers !

Sebby

Posted: Sat 28. Jan 2006, 22:55
by Fulvio Romanin
thx sebby! :D

Posted: Tue 28. Mar 2006, 16:45
by Evoplure
brans wrote:I have added this mod to the dev forum:
--...--/index.php/topic,117.0.html
I found some problems installing the mod, so I made some changes in the code. They worked for me, but I don't know if they will be useful for other people. Anyway, I posted that changes in:

--...--/index.php/topic,185.0.html

Posted: Fri 8. Sep 2006, 08:20
by tsl
Thanks Fulvio for this excellent mod :D
It just made my week!

I have however a question:
Is it possible to make the switch to other laguages only when you actually click on a link or i.e an image? Now the switch is made just by moving the cursor over it (probably from the "onmouseover" tag). It's also set when you click off course.

Thank you
-tsl-

Posted: Sat 9. Sep 2006, 15:52
by tsl
Ok, just changed from onmouseover to onClick in the links did it!

Another question...
How can I limit the built in search content type in wcms v1.8 to only display the current lang content?
Possible?

Thanks
-tsl-