Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rendering multilingual quotes 1

Status
Not open for further replies.

LPent

Programmer
Oct 3, 2002
50
TR
Hello,

I need some help and/or advice.
Much is said about rendering quotes around <q>-elements even in regard to multi-languages.
A pure CSS solution is not viable at the moment because "quotes" and "content" are not supported by some browsers. Besides, the CSS-spec itself states:
If a quotation is in a different language than the surrounding text, it is customary to quote the text with the quote marks of the language of the surrounding text, not the language of the quotation itself.
And this is not something I have seen addressed anywhere. Also, the solution the W3C gives, does not work:
Code:
[LANG|=fr] > * { quotes: "«" "»" "‹" "›" }
[LANG|=en] > * { quotes: "“" "”" "‘" "’" }
Because a nested <q> would be rendered wrong (because it's <q>-parent has another language).

So I am trying to write a script in Javascript/jQuery that does this for me.
I collected information about quotes in other languages from Wikipedia and started scripting. It is not a big script, but I am stuck when it comes to storing and selecting the actual quote-marks. I was thinking about using an Array, but that feel wrong somehow. Can someone please look at my code and gice me some advice/help please?

Code:
$('.quotes').each(function() {
	   
		var NumberOfParents = $(this).parents().filter('.quotes').length;
		
		if (NumberOfParents > 0) {
		   var FirstQuote = $(this).parents().filter('.quotes').get(NumberOfParents - 1);
		}
		else {
			var FirstQuote = $(this);
		}
		
		var ParentLanguage = $(FirstQuote).parents('*[lang]').get(0);
		var Language = $(ParentLanguage).attr('lang');
		
		var isOuterMarks = isEven(NumberOfParents);
		var QuoteMarks = GetMark(Language, isOuterMarks);
		
		/* ?? */
		
		$(this).prepend(LeftMark);
		$(this).append(RightMark);
	});

function GetMark(aLang, aIsOuter) {
	
   var QuoteTypes = ["", "", "", ""];
	
	if (aLang.substr(0,2) == 'af' || aLang.substr(0,2) == 'nl') {
	   var QuoteTypes = ["&bdquo;", "&rdquo;", "&sbquo;", "&rsquo;"];
	}

   var QuoteTypes = ["&laquo;", "&raquo;", "&lsaquo;", "&rsaquo;"];

   var QuoteTypes = ["&bdquo;", "&ldquo;", "&sbquo;", "&lsquo;"];

   var QuoteTypes = ["&ldquo;", "&rdquo;", "&lsquo;", "&rsquo;"];

   var QuoteTypes = ["&rdquo;", "&rdquo;", "&rsquo;", "&rsquo;"];

   var QuoteTypes = ["&raquo;", "&laquo;", "&rsaquo;", "&lsaquo;"];

   var QuoteTypes = ["&laquo;&nbsp;", "&nbsp;&raquo;", "&laquo;&nbsp;", "&nbsp;&raquo;"];

   var QuoteTypes = ["&laquo;", "&raquo;", "", ""];

   var QuoteTypes = ["&bdquo;", "&ldquo;", "", ""];

   var QuoteTypes = ["&laquo;", "&raquo;", "&ldquo;", "&rdquo;"];

   var QuoteTypes = ["&ldquo;", "&rdquo;", "", ""];

   var QuoteTypes = ["&bdquo;", "&ldquo;", "&lsquo;", "&rsquo;"];

   var QuoteTypes = ["&bdquo;", "&rdquo;", "&raquo;", "&laquo;"];

   var QuoteTypes = ["&laquo;", "&raquo;", "&bdquo;", "&rdquo;"];

   var QuoteTypes = ["&laquo;", "&raquo;", "&lsquo;", "&rsquo;"];

   var QuoteTypes = ["&bdquo;", "&rdquo;", "&laquo;", "&raquo;"];

   var QuoteTypes = ["&bdquo;", "&ldquo;", "&laquo;", "&raquo;"];

   var QuoteTypes = ["&laquo;", "&raquo;", "&bdquo;", "&ldquo;"];

   var QuoteTypes = ["&bdquo;", "&ldquo;", "&sbquo;", "&sbquo;"];

   var QuoteTypes = ["&lsquo;", "&rsquo;", "&ldquo;", "&rdquo;"];

   var QuoteTypes = ["&ldquo;", "&rdquo;", "&lsquo;", "&rsquo;"];
	
	
   if (aIsOuter) {
		/*outer-marks*/		
	}
	else {
		/*inner-marks*/
	}
	return QuoteTypes;
}

function isEven(num) {
	if (num == 0) { return !0; }
   else { return !(num % 2); }
}

As it is right now it won't work obviously. I need some sort of construction whereby I can store the language-codes (en,nl,tr,etc.) in combination with the quotemarks.
 
wow... I hardly ever do major programming in JavaScript and I was totally unaware that it could handle data structures like that.

thanks!!!!
 
thanks again.

So if I understand correctly I can access the array of quotes from a specific language through
Code:
QuoteTypes.en

?
 
Hi

Yes, that is one way, but I bet you will have the language code in a variable, so better :
Code:
QuoteTypes['en']

[gray]# practically you will have it like :[/gray]

code='en'
QuoteTypes[code]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top