nepenthe Posted April 26, 2007 Share Posted April 26, 2007 hello..I need to use different tag attributes for my multi language web project.for example <span textTranslation="welcome"></span> when i call the javascript function, it searches and finds the the tags with textTranslation attribute.and then changes the innerHTML of that tag with appropriate translation..it works well.. but what i want to ask is using undefined atrributes is a problem or not? also html validators can't recognize that attribute and give errors. what do you recommend? thanks Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 26, 2007 Share Posted April 26, 2007 This sounds like an ideal candidate for an ajax app.... How ever may I susggest this... just give each span that is going to be translated a class Like so <span class="translate">Welcome</span> NOW by having some text within the span when the page loads this will help you transloation app (it can always refer to englisjh in this case); Now you can do this in js function translateSpans() { els = document.getElementsByTagName('span); var text = null; for(var i = 0; i < els.length; i++) { if (els[i].className == 'translate') { text = els[i].innerHTML; // do the bit that finds the translation. els[i].innerHTML = 'text found in translation look up'; } } } all that will valdiate and then you won't need to worry about undefined attributes again!!!! Quote Link to comment Share on other sites More sharing options...
fenway Posted April 26, 2007 Share Posted April 26, 2007 Maybe, but isn't it "bad" somehow to have classes that do nothing? Granted, expando-properties aren't cross-browser (though I really don't see what the issue is). Quote Link to comment Share on other sites More sharing options...
nepenthe Posted April 26, 2007 Author Share Posted April 26, 2007 thanks for the answers.. I think this method is better than mine but I'm not sure, is it really "bad" to have classes that do nothing? I also have another question..I use xml files for language translations. I make an ajax request to get the translations to an array at the beginning while the page not loaded completely..At this time, visitors see the span's innerHTML for example: firstname,welcome, or err_invalid_name... Do you think should I display a loading info or making "translate" classes hidden in this period is a good solution? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 27, 2007 Share Posted April 27, 2007 classes don't 'do' anything anyway! On your second point - just hide the container until the ajax request is complete. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.