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:
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?
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.
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:
And this is not something I have seen addressed anywhere. Also, the solution the W3C gives, does not work: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.
Code:
[LANG|=fr] > * { quotes: "«" "»" "‹" "›" }
[LANG|=en] > * { quotes: "“" "”" "‘" "’" }
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 = ["„", "”", "‚", "’"];
}
var QuoteTypes = ["«", "»", "‹", "›"];
var QuoteTypes = ["„", "“", "‚", "‘"];
var QuoteTypes = ["“", "”", "‘", "’"];
var QuoteTypes = ["”", "”", "’", "’"];
var QuoteTypes = ["»", "«", "›", "‹"];
var QuoteTypes = ["« ", " »", "« ", " »"];
var QuoteTypes = ["«", "»", "", ""];
var QuoteTypes = ["„", "“", "", ""];
var QuoteTypes = ["«", "»", "“", "”"];
var QuoteTypes = ["“", "”", "", ""];
var QuoteTypes = ["„", "“", "‘", "’"];
var QuoteTypes = ["„", "”", "»", "«"];
var QuoteTypes = ["«", "»", "„", "”"];
var QuoteTypes = ["«", "»", "‘", "’"];
var QuoteTypes = ["„", "”", "«", "»"];
var QuoteTypes = ["„", "“", "«", "»"];
var QuoteTypes = ["«", "»", "„", "“"];
var QuoteTypes = ["„", "“", "‚", "‚"];
var QuoteTypes = ["‘", "’", "“", "”"];
var QuoteTypes = ["“", "”", "‘", "’"];
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.