MediaWiki:Api-stylesheets/wiktPT.xsl

   ltr » Mais Erro:   © Wiktionary. Lançado em CC-BY-SA 3.0 

<xsl:variable name="pageName" select="concat('http://', $contentLang, '.wiktionary.org')"/>

<xsl:template match="/">

<html dir="{$dir}" lang="{$contentLang}" xml:lang="{$contentLang}"> <meta name="generator" content="Wiktionary Extract XSLT 1.09-EN"/> <base target='_blank' href="{$pageName}" /> Wiktionary extract a.wtif1 { color: black; text-decoration: none;} a.wtif1:hover {text-decoration: underline;} .disambig-see-also, .disambig-see-also-2 {display:inline;} a.new {color: red;}
 * 1) wordThisIsFor { font-weight:bold;}
 * 1) container {background-color:white; padding: 0.5em; border: solid black thin;}
 * 1) error {color: red;font-size:larger;}

div.exit {float:right;font-weight:bold;font-family:sans-serif;border:outset;padding:0.1em} div.exit a {color: black; text-decoration:none;} <script type='text/javascript'> /*<![CDATA[*/ function setup { //Stuff to translate: var preferLang = {'en': 'Inglês', 'fr': 'Francês', 'de': 'Alemão', 'es': 'Espanhol', 'it': 'Italiano', 'pt': 'Português', 'ja': 'Japonês', 'pl': 'Polaco', 'ru': 'Russo', 'nl': 'Holandês', 'qqqAny': null}; //for now. var extractSeeAlso = /<table\s[^>]*>\s* \s?<td\s?bgcolor="#f0eeff"\s?valign="top"\s?align="left"\s?>\s*<ul>([\s\S]*?)<\/table>/;

var see_also_process = function (sa) { var matches = sa[1].match(/<li[^>]>\s*<a[^>]*>([\s\S]*?)<\/a>/g); var text = 'Veja também: '; for (var i = 0; i < Math.min(5, matches.length);i++) { text += matches[i]; }  return 'Veja também: '+ sa[1];} var createLink = '» Criar'; // text only. var not_found = "Não pode recuperar definição de $1.";

//END stuff to translate (there is one more translation block below)

//Stuff not to translate in general (setup).

var rd = location.search.match(/\&rd\=([^&]*)/); //is this from redirect. + converts to numeric. rd = rd ? (+rd[1] + 1) : 1; //redirection level. var showWord = 0; //default to not showing. 0 = none, 1 = bold, 2 = bold link. var showWordRaw = location.search.match(/\&showWord\=([^&]*)/); showWordRaw = showWordRaw ? showWordRaw[1] : 'none'; if (showWordRaw !== "none") { showWord++; } if (showWordRaw === "link") { showWord++; } var useAudio = 0; if (location.search.match(/\&audio\=(?!none)/)) useAudio++; if (location.search.match(/\&audio\=autoplay/)) useAudio++; var closeLink = false; if (location.search.match(/&exit\=(?!false)/)) closeLink = true; var numbDfn = location.search.match(/\&count\=([^&]*)/); //count. + converts to numeric. numbDfn = numbDfn ? (parseInt(numbDfn[1])) : 1; //default to 1 var pageURL = '/w/index.php?title=' + encodeURIComponent(decodeURIComponent(location.search.match(/\&page\=([^&]*)/)[1])); var src = document.getElementById('src'); var display = document.getElementById('word-list'); var loc = location.search.match(/\&page\=([^&]*)/)[1]; //this is not escaped var escWord = decodeURIComponent(loc).replace(/&/, '&amp;').replace(/>/, '&lt;').replace(/</, '&gt;'); //note: wordEsc does not escape quotes. DO NOT PUT AS ATTRIBUTE VALUE var preferLangCode = location.search.match(/\&lang\=([^&]*)/); if (preferLangCode) { preferLangCode = preferLangCode[1]; } else {preferLangCode = 'qqqAny';} src.normalize; var html = src.firstChild.data; var def = html //may be redefined later.

//stuff you might need to translate, but hopefully won't var subSectRegex = new RegExp(' [^<]*?(?:<span[^<]*?<a[^<]*?<\/a[^<]*?</span[^<]*?\>)?\\s*<span class="mw-headline"[^>]*>' + 'Francês' + ' [\\s\\S]*$'); var extractCurLangName = /<span class="mw-headline" id[^>]*>([\s\S]*?)<\/span>/; //first subexpression //End stuff you hopefully won't need to translate. try { //this assumes attribute order doesn't change!!! html = html.replace(/ [\s\S]*?<\/div>/, ''); if (preferLangCode && preferLang[preferLangCode]) { try { //strip off all definitions before tagret lang. var subSect = html.match(subSectRegex)[0]; if (subSect.match(/<ol>[\s\S]*?<li>/)) { //if it has content def = subSect; }  } catch (e) { /*alert(e)*/} }  var lang = def.match(extractCurLangName)[1]; var intro = "(" + lang + ") ";

//Start testing to see if we can play audio. if (useAudio > 0) { var audioLink = html.match(/\<a\s*\S*?\s*href\=\"?(http:\/\/upload.wikimedia.org\/\S*.(?:oga|ogg))\"?[^>]*>/); if (!audioLink) audioLink = html.match(/\<button[\s\S]*?\sonclick=\"[\s\S]*?&quot;videoUrl&quot;:\s*&quot;(http:\/\/upload.wikimedia.org\/\S*?)&quot;[^"]*?&quot;isVideo&quot;:\sfalse[^"]*?".*?>/); if (audioLink) { audioLink = encodeURI(audioLink[1]); //should be already encoded, but better safe. intro += ' <audio controls src="' + audioLink + '" '; if (useAudio === 2) { intro += 'autoplay'; }   intro += ' /> '; } }

if (showWord) intro = '<a href="' + pageURL + '" id="wordThisIsFor" class="wtif' + showWord + '" >' + escWord + "</a> " + intro ;

var definitions_matched; //FIXME: in both cases the extraction method does not properly strip nested divs. This results in image thumbnails being left behind if (numbDfn === 1) { definitions_matched = def.match(/<ol>[\s\S]*?<\/ol>/)[0].replace(/<dl>[\s\S]*?<\/dl>/g, ).replace(/<div[^>]*>[\s\S]*?<\/div>/g, ).replace(/<\/div>/g, ).replace(/<ul>[\s\S]*?<\/ul>/g, ).replace(/<a href="(#[^"]*)">/g, '<a href="' + pageURL + '$1">').match(/<li>([\s\S]*?)<\/li>/); display.innerHTML = intro +  definitions_matched[1];  } else {   //this use not well supported...   definitions_matched = def.match(/<ol>[\s\S]*?<\/ol>/)[0].replace(/<dl>[\s\S]*?<\/dl>/g, ).replace(/<div[^>]*>[\s\S]*?<\/div>/g, ).replace(/<\/div>/g, ).replace(/<ul>[\s\S]*?<\/ul>/g, ).replace(/<a href="(#[^"]*)">/g, '<a href="' + pageURL + '$1">').match(/<li>([\s\S]*?)<\/li>/g); var tmp = intro + ' <ul>'; for (var i = 0; i < numbDfn && i < definitions_matched.length; i++) { tmp += definitions_matched[i]; }  display.innerHTML = tmp + '</ul>'; } } catch (e) { //alert(e) //page does not exist, not well formed, these regexs suck, etc

//note, this is appending a text node, thus it is ok, that loc is not escaped. display.appendChild(document.createTextNode(not_found.replace("$1", decodeURIComponent(loc)))); document.getElementById('more-link').firstChild.data = createLink; if (rd < 9) { //arbitrary to prevent infinite loops //make sure don't have loops. var newLoc; //this should not be urlEncoded. var remAlt = false; var dLoc = decodeURIComponent(loc);

newLoc = dLoc.charAt(0).toLowerCase + dLoc.substring(1, loc.length); //try some other redirections.

if (newLoc === dLoc) newLoc = dLoc.toLowerCase; if (newLoc === dLoc && location.search.match(/\&alt\=([^&]*)/)) { newLoc = decodeURIComponent(location.search.match(/\&alt\=([^&]*)/)[1]); remAlt = true; }  if (newLoc !== dLoc) { //redir var newURL = location.href.replace(/(^[\s\S]*?\&page\=)[^&]*([\s\S]*$)/, '$1'+ encodeURIComponent(newLoc) + '$2'); newURL = newURL.replace(/&rd\=[^&]*/, ''); //strip old redirect header. if (remAlt) { location.href.replace(/&alt\=[^&]*/, ''); }   location = newURL + '&rd=' + rd; } } } var sa = html.match(extractSeeAlso); if(sa) { document.getElementById('see-also').innerHTML = ' (' + see_also_process(sa) + ')' ; } if (closeLink) { var container = document.getElementById('container'); container.innerHTML = ' <a href="about:blank" title="Hide" target="_self">X</a> ' + container.innerHTML; } document.getElementById('more-link').href= pageURL; }

/*]]>*/ <body onload='setup'> <xsl:apply-templates select='api/error'/> <a id='more-link'><xsl:value-of select="$more"/></a> <small id="copyright-notice"> <xsl:copy-of select="$copyright"/> <xsl:value-of select='api/parse/text'/>

</xsl:template> <xsl:template match='api/error'> <xsl:value-of select="$error"/> <xsl:value-of select='@info'/> </xsl:template>

</xsl:stylesheet>