User:OldBee/Translate.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
//<source lang=javascript>
//<pre><nowiki>
// ---------------------------- VARIABLES ----------------------------------- //
var LinkTranslate_SubPagePath = "/Traduction/Encours"
var LinkTranslate_AllLanguages = ["de","en","es","fr","it","pt","ru"];
var LinkTranslate_DefaultLanguage = "fr";
var LinkTranslate_DebugOn = false;
// ---------------------------- FONCTIONS ----------------------------------- //
///////////////// AJAX ////////////////////////////////////
var LinkTranslate_ajax = {
http:function(bundle){ var xmlhttp; try{ xmlhttp = new XMLHttpRequest(); }catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ xmlhttp = false; }}}; if(xmlhttp){ xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4){ LinkTranslate_ajax.httpComplete(xmlhttp,bundle);}}; xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true); if (bundle.headers) { for (var field in bundle.headers){ try{ xmlhttp.setRequestHeader(field,bundle.headers[field]); }catch(err){}}}; xmlhttp.send(bundle.data ? bundle.data : null); }; return xmlhttp;},
httpComplete: function(xmlhttp,bundle){ if(xmlhttp.status == 200 || xmlhttp.status == 302){ if(bundle.onSuccess) bundle.onSuccess(xmlhttp,bundle); }else if(bundle.onFailure){ bundle.onFailure(xmlhttp,bundle); }else{ }}
};
///////////////// CREATION LIEN ////////////////////////////////////
function LinkTranslate_AddLink(){
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(!Titre) return;
if(typeof(LinkTranslate_UserCustom)=="function") LinkTranslate_UserCustom();
var Small = document.createElement("small");
Small.setAttribute("style", "text-size:40% !important");
var Link = document.createElement("a");
Link.title="Afficher le menu de traduction";
Link.href="javascript:LinkTranslate_MakeMenu();";
Link.innerHTML = "[Traduire]";
Small.setAttribute("style", "text-size:40% !important");
Small.appendChild(Link);
var Sup = document.createElement("sup");
Sup.setAttribute("style", "font-size:10px !important");
var SupLink = document.createElement("a");
SupLink.title="Voir ou modifier l'outil de traduction";
SupLink.href="//meta.wikimedia.org/wiki/User:OldBee/Translate.js";
SupLink.innerHTML = "(outil)";
Sup.appendChild(SupLink);
Small.appendChild(Link);
Small.appendChild(document.createTextNode(" "));
Small.appendChild(Sup);
Titre.appendChild(document.createTextNode(" - "));
Titre.appendChild(Small);
}
///////////////// CREATION MENU ////////////////////////////////////
function LinkTranslate_MakeMenu(){
if(document.getElementById("LinkTranslate_Menu")) return;
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(!Titre) return;
var MenuPages = document.createElement('div');
MenuPages.id = "LinkTranslate_Menu";
var CurrentLanguage = mw.config.get('wgContentLanguage');
var LangToTranslate = document.createElement("select");
LangToTranslate.id = "LangToTranslate_Select";
LangToTranslate.title = "Langue d'origine";
var LangToTranslateOption = document.createElement('option');
LangToTranslateOption.value = CurrentLanguage;
LangToTranslateOption.innerHTML = CurrentLanguage;
LangToTranslateOption.disabled = "disabled";
LangToTranslateOption.selected = "selected";
LangToTranslate.appendChild(LangToTranslateOption);
var PageToTranslate = document.createElement("input");
PageToTranslate.type = "text";
PageToTranslate.size = 50;
PageToTranslate.id = "PageToTranslate_Input";
PageToTranslate.title = "Page d'origine";
PageToTranslate.value = mw.config.get('wgPageName').replace(/_/g, " ");
var TranslatedLang = document.createElement("select");
TranslatedLang.id = "TranslatedLang_Select";
TranslatedLang.title = "Langue d'arrivée";
for(var a=0;a<LinkTranslate_AllLanguages.length;a++){
if(LinkTranslate_AllLanguages[a]!=CurrentLanguage){
var NewOption = document.createElement('option');
NewOption.value = LinkTranslate_AllLanguages[a];
NewOption.innerHTML = LinkTranslate_AllLanguages[a];
if(LinkTranslate_AllLanguages[a]==LinkTranslate_DefaultLanguage) NewOption.selected = "selected";
TranslatedLang.appendChild(NewOption);
}
}
var TranslatedPage = document.createElement("input");
TranslatedPage.type = "text";
TranslatedPage.size = 50;
TranslatedPage.id = "TranslatedPage_Input";
TranslatedPage.title = "Page d'arrivée";
TranslatedPage.value = mw.config.get('wgFormattedNamespaces')[2]+":"+mw.config.get('wgUserName')+LinkTranslate_SubPagePath
var OKInput = document.createElement("input");
OKInput.type = "button";
OKInput.value = "Valider";
OKInput.onclick = function(){ LinkTranslate_CheckMenu(); };
OKInput.onselect = function(){ LinkTranslate_CheckMenu(); };
var CancelInput = document.createElement("input");
CancelInput.type = "button";
CancelInput.value = "Annuler";
CancelInput.onclick = function(){ LinkTranslate_HideMenu(); };
CancelInput.onselect = function(){ LinkTranslate_HideMenu(); };
var ControlPanel = document.createElement("div");
ControlPanel.id = "MenuControlPanel";
MenuPages.appendChild(LangToTranslate);
MenuPages.appendChild(PageToTranslate);
MenuPages.appendChild(document.createElement("br"));
MenuPages.appendChild(TranslatedLang);
MenuPages.appendChild(TranslatedPage);
MenuPages.appendChild(document.createElement("br"));
MenuPages.appendChild(OKInput);
MenuPages.appendChild(CancelInput);
MenuPages.appendChild(ControlPanel);
Titre.parentNode.insertBefore(MenuPages, Titre.nextSibling);
PageToTranslate.focus();
}
function LinkTranslate_HideMenu(){
var MenuPages = document.getElementById("LinkTranslate_Menu");
if(MenuPages) MenuPages.parentNode.removeChild(MenuPages);
}
///////////////// VERIF MENU ////////////////////////////////////
var MenuChoices = {};
var ElementsToTranslateListParams = {};
ElementsToTranslateListParams["Links"] = {"prop" : "links",
"limit" : "gpllimit",
"text" : "Listage des liens",
"items" : [],
"done" : false
};
ElementsToTranslateListParams["Templates"] = {"prop" : "templates",
"limit" : "gtllimit",
"text" : "Listage des modèles",
"items" : [],
"done" : false
};
ElementsToTranslateListParams["Categories"] = {"prop" : "categories",
"limit" : "gcllimit",
"text" : "Listage des catégories",
"items" : [],
"done" : false
};
ElementsToTranslateListRedirects = {}
function LinkTranslate_CheckMenu(){
var PageToTranslateElement = document.getElementById('PageToTranslate_Input');
var LangToTranslateElement = document.getElementById('LangToTranslate_Select');
var TranslatedPageElement = document.getElementById('TranslatedPage_Input');
var TranslatedLangElement = document.getElementById('TranslatedLang_Select');
if((!PageToTranslateElement)||(!LangToTranslateElement)||(!TranslatedPageElement)||(!TranslatedLangElement)) return;
var PageToTranslate = PageToTranslateElement.value;
var LangToTranslate = LangToTranslateElement.value;
var TranslatedPage = TranslatedPageElement.value;
var TranslatedLang = TranslatedLangElement.value;
MenuChoices["PageToTranslate"] = PageToTranslate;
MenuChoices["LangToTranslate"] = LangToTranslate;
MenuChoices["TranslatedPage"] = TranslatedPage;
MenuChoices["TranslatedLang"] = TranslatedLang;
var Menu = document.getElementById("LinkTranslate_Menu");
if(Menu){
var Inputs = Menu.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
if(Inputs[a].type == "button") Inputs[a].disabled = "disabled";
}
}
for(var Type in ElementsToTranslateListParams){
if(ElementsToTranslateListParams.hasOwnProperty(Type)){
LinkTranslate_GetAllLinks(Type);
}
}
}
///////////////// LISTAGE ////////////////////////////////////
function LinkTranslate_GetAllLinks(TYPE, LinkContinue){
if(!ElementsToTranslateListParams[TYPE]) return;
if(!LinkContinue) LinkContinue = "";
// var APILimit = 499;
// var GR = mw.config.get('wgUserGroups');
// if( GR.indexOf("bot")!=-1 || GR.indexOf("sysop")!=-1 ) APILimit = 4999;
var APILimit = 5;
var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml'
+ '&action=query&generator='+ElementsToTranslateListParams[TYPE]["prop"]+'&prop=langlinks|info'
+ '&lllang=' + encodeURIComponent(MenuChoices["TranslatedLang"])
+ '&titles='+encodeURIComponent(MenuChoices["PageToTranslate"])
+ '&'+ElementsToTranslateListParams[TYPE]["limit"]+'='+APILimit
+ '&redirects'
+ LinkContinue;
LinkTranslate_ajax.http({
url: URL,
onSuccess:LinkTranslate_GetAllLinksDone,
type:TYPE,
});
}
function LinkTranslate_GetAllLinksDone(Req, data){
var TYPE = data.type;
var ObjetXML = Req.responseXML;
if(!ObjetXML) return;
var Redirects = ObjetXML.getElementsByTagName("r");
if(Redirects.length>0){
for(var a=0,l=Redirects.length;a<l;a++){
var From = Redirects[a].getAttribute("from");
var To = Redirects[a].getAttribute("to");
ElementsToTranslateListRedirects[From] = To;
}
}
var Pages = ObjetXML.getElementsByTagName("page");
for(var a=0;a<Pages.length;a++){
var ThisItem = {};
var ThisPage = Pages[a];
var Title = ThisPage.getAttribute('title');
var Missing = ThisPage.getAttribute('missing');
ThisItem.title = Title;
ThisItem.missing = (Missing === "");
var langlinks = ThisPage.getElementsByTagName("ll")
if(langlinks.length>0){
for(var b=0;b<langlinks.length;b++){
var thisLL = langlinks[b].getAttribute('lang');
if(thisLL == MenuChoices["TranslatedLang"]){
ThisItem.translatedtitle = langlinks[b].firstChild.nodeValue;
}
}
}
ElementsToTranslateListParams[TYPE]["items"].push(ThisItem);
}
var MustContinue = ObjetXML.getElementsByTagName('continue')[0];
if(MustContinue){
var LinkContinue = "";
var Attr = MustContinue.attributes;
for (var j=0,lenj=MustContinue.attributes.length;j<lenj; j++) {
var genname = MustContinue.attributes[j].name;
var genvalue = MustContinue.attributes[j].value;
LinkContinue += "&" + genname + "=" + encodeURIComponent(genvalue);
}
LinkTranslate_GetAllLinks(TYPE, LinkContinue);
}else{
ElementsToTranslateListParams[TYPE]["done"] = true;
LinkTranslate_IsAllInterwikiOK();
}
}
function LinkTranslate_IsAllInterwikiOK(){
var AllOK = true;
for(var Type in ElementsToTranslateListParams){
if(ElementsToTranslateListParams[Type]["done"] !== true) AllOK = false;
}
if(!AllOK) return;
var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title='+encodeURIComponent(MenuChoices["PageToTranslate"])+'&action=raw';
LinkTranslate_ajax.http({
url: URL,
onSuccess:LinkTranslate_DoTranslation["Global"]
});
}
///////////////// TRADUCTION ////////////////////////////////////
LinkTranslate_DoTranslation = new Array();
LinkTranslate_DoTranslation["Global"] = function(Req, data){
var ControlPanel = document.getElementById("MenuControlPanel");
if(ControlPanel) ControlPanel.innerHTML = "Traduction";
var PageToTranslateContent = Req.responseText;
PageToTranslateContent = LinkTranslate_DoTranslation["Images"](PageToTranslateContent);
PageToTranslateContent = LinkTranslate_DoTranslation["Redirects"](PageToTranslateContent);
for(var TYPE in ElementsToTranslateListParams){
if(LinkTranslate_DebugOn){
var Items = ElementsToTranslateListParams[TYPE]["items"];
var text = TYPE + " :\n"
for(var a=0,l=Items.length;a<l;a++){
text += a + " " + Items[a].title + " (" + Items[a].missing + ") -> " + (Items[a].translatedtitle ? Items[a].translatedtitle : "XxX") + "\n"
}
alert(text)
}
if(typeof(LinkTranslate_DoTranslation[TYPE])=="function")
PageToTranslateContent = LinkTranslate_DoTranslation[TYPE](PageToTranslateContent);
}
var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title='+encodeURIComponent(MenuChoices["TranslatedPage"])+'&action=edit';
LinkTranslate_ajax.http({
url: URL,
onSuccess:LinkTranslate_SavePage,
text:PageToTranslateContent
});
}
function LinkTranslate_SavePage(Req, data){
while(document.body.firstChild){ document.body.removeChild(document.body.firstChild); }
document.body.innerHTML = Req.responseText;
var TextArea = document.getElementById("wpTextbox1");
if(!TextArea){ alert('Pas trouvé la zone d\'édition'); return; }
TextArea.value = data.text;
var Sum = "Traduction [["+MenuChoices["PageToTranslate"]+"]] : "
+ MenuChoices["LangToTranslate"] + " -> " + MenuChoices["TranslatedLang"];
document.getElementById("wpSummary").value = Sum;
}
LinkTranslate_DoTranslation["Images"] = function(PageToTranslateContent){
var ImageRegExp = new RegExp("\\[\\[[ ]*"+mw.config.get('wgFormattedNamespaces')[6]+"[ ]*:", "ig");
var AllImages = PageToTranslateContent.match(ImageRegExp);
if(AllImages==null) return PageToTranslateContent;
for(var a=0,l=AllImages.length;a<l;a++){
PageToTranslateContent = PageToTranslateContent.replace(AllImages[a], "[[File:");
}
return PageToTranslateContent;
}
LinkTranslate_DoTranslation["Redirects"] = function(PageToTranslateContent){
for(var VALfrom in ElementsToTranslateListRedirects){
var VALto = ElementsToTranslateListRedirects[VALfrom];
PageToTranslateContent = PageToTranslateContent.split("[["+VALfrom.ucFirst()+"|").join("[["+VALto.ucFirst()+"|");
PageToTranslateContent = PageToTranslateContent.split("[["+VALfrom.lcFirst()+"|").join("[["+VALto.lcFirst()+"|");
PageToTranslateContent = PageToTranslateContent.split("[["+VALfrom.ucFirst()+"]]").join("[["+VALto.ucFirst()+"]]");
PageToTranslateContent = PageToTranslateContent.split("[["+VALfrom.lcFirst()+"]]").join("[["+VALto.lcFirst()+"]]");
VALto = VALto.split(mw.config.get('wgFormattedNamespaces')[10]+":").join("")
VALfrom = VALfrom.split(mw.config.get('wgFormattedNamespaces')[10]+":").join("")
var TemplatesRegExp1 = new RegExp("\\{\\{( |_)*("+VALfrom.ucFirst()+"|"+VALfrom.lcFirst()+")( |_)*\n", "g");
var TemplatesRegExp2 = new RegExp("\\{\\{( |_)*("+VALfrom.ucFirst()+"|"+VALfrom.lcFirst()+")( |_)*\\|", "g");
var TemplatesRegExp3 = new RegExp("\\{\\{( |_)*("+VALfrom.ucFirst()+"|"+VALfrom.lcFirst()+")( |_)*\\}", "g");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp1, "{{"+VALto+"\n");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp2, "{{"+VALto+"|");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp3, "{{"+VALto+"}");
}
return PageToTranslateContent;
}
LinkTranslate_DoTranslation["Links"] = function(PageToTranslateContent){
var TYPE = "Links";
var PageToTranslate = MenuChoices["PageToTranslate"];
var LangToTranslate = MenuChoices["LangToTranslate"];
var TranslatedPage = MenuChoices["TranslatedPage"];
var TranslatedLang = MenuChoices["TranslatedLang"];
var ItemsToTranslate = ElementsToTranslateListParams[TYPE]["items"];
for(var a=0;a<ItemsToTranslate.length;a++){
var ThisItem = ItemsToTranslate[a];
if(ThisItem.missing) continue;
var oldtitle = ThisItem.title;
var newtitle = ThisItem.translatedtitle;
if(newtitle){
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.ucFirst()+"|").join("[["+newtitle.ucFirst()+"|");
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.lcFirst()+"|").join("[["+newtitle.lcFirst()+"|");
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.ucFirst()+"]]").join("[["+newtitle.ucFirst()+"]]");
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.lcFirst()+"]]").join("[["+newtitle.lcFirst()+"]]");
}else{
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.ucFirst()+"]]").join("{{subs"+"t:Lien/Conversion automatique|"+oldtitle.ucFirst() + (LangToTranslate!="en" ? "|lang="+LangToTranslate : "") + "}}");
PageToTranslateContent = PageToTranslateContent.split("[["+oldtitle.lcFirst()+"]]").join("{{subs"+"t:Lien/Conversion automatique|"+oldtitle.lcFirst() + (LangToTranslate!="en" ? "|lang="+LangToTranslate : "") + "}}");
var LinkRegExp = new RegExp("\\[\\["+oldtitle+"[^\\]]+\\]\\]", "ig");
var Links = PageToTranslateContent.match(LinkRegExp);
if(Links!=null){
for(var b=0;b<Links.length;b++){
var ThisLink = Links[b];
var ThisLinkContent = ThisLink.split('[[').join('').split(']]').join('');
var TextLink = ThisLinkContent.replace(/.*\|/g, "");
var PageLink = ThisLinkContent.replace(/\|.*/g, "");
var ReplacedLink = ThisLink.split("[["+ThisLinkContent+"]]").join("{{subs"+"t:Lien/Conversion automatique|" +PageLink + (TextLink!="" ? "|texte="+TextLink : "") + "|trad="+ PageLink + (LangToTranslate!="en" ? "|lang="+LangToTranslate : "") + "}}");
PageToTranslateContent = PageToTranslateContent.replace(ThisLink, ReplacedLink);
}
}
}
}
return PageToTranslateContent;
}
LinkTranslate_DoTranslation["Templates"] = function(PageToTranslateContent){
var TYPE = "Templates";
var PageToTranslate = MenuChoices["PageToTranslate"];
var LangToTranslate = MenuChoices["LangToTranslate"];
var TranslatedPage = MenuChoices["TranslatedPage"];
var TranslatedLang = MenuChoices["TranslatedLang"];
var ItemsToTranslate = ElementsToTranslateListParams[TYPE]["items"];
for(var a=0;a<ItemsToTranslate.length;a++){
var ThisItem = ItemsToTranslate[a];
if(ThisItem.missing) continue;
var oldtitle = ThisItem.title;
var newtitle = ThisItem.translatedtitle;
if(newtitle){
try{
var Template = oldtitle.split(mw.config.get('wgFormattedNamespaces')[10]+":").join("");
var Interwiki = newtitle.substring((newtitle.indexOf(":")+1));
var TemplatesRegExp1 = new RegExp("\\{\\{( |_)*("+Template.ucFirst()+"|"+Template.lcFirst()+")( |_)*\n", "g");
var TemplatesRegExp2 = new RegExp("\\{\\{( |_)*("+Template.ucFirst()+"|"+Template.lcFirst()+")( |_)*\\|", "g");
var TemplatesRegExp3 = new RegExp("\\{\\{( |_)*("+Template.ucFirst()+"|"+Template.lcFirst()+")( |_)*\\}", "g");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp1, "{{"+Interwiki+"\n");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp2, "{{"+Interwiki+"|");
PageToTranslateContent = PageToTranslateContent.replace(TemplatesRegExp3, "{{"+Interwiki+"}");
}catch(e){ }
}
}
PageToTranslateContent = LinkTranslate_DoTranslation["BiblioTemplates"](PageToTranslateContent);
return PageToTranslateContent;
}
var LinkTranslate_BiblioTemplates = {};
LinkTranslate_BiblioTemplates["Ouvrage"] = {};
LinkTranslate_BiblioTemplates["Ouvrage"]["langue"] = {"es":"idioma"};
LinkTranslate_BiblioTemplates["Ouvrage"]["prénom1"] = {"es":"nombre"};
LinkTranslate_BiblioTemplates["Ouvrage"]["nom1"] = {"es":["apellidos", "apellido"]};
LinkTranslate_BiblioTemplates["Ouvrage"]["lien auteur1"] = {"es":"enlaceautor"};
LinkTranslate_BiblioTemplates["Ouvrage"]["titre"] = {"es":"título"};
LinkTranslate_BiblioTemplates["Ouvrage"]["numéro d'édition"] = {"es":"edición"};
LinkTranslate_BiblioTemplates["Ouvrage"]["éditeur"] = {"es":"editorial"};
LinkTranslate_BiblioTemplates["Ouvrage"]["lieu"] = {"es":"ubicación"};
LinkTranslate_BiblioTemplates["Ouvrage"]["année"] = {"es":"año"};
LinkTranslate_BiblioTemplates["Ouvrage"]["volume"] = {"es":"volumen"};
LinkTranslate_BiblioTemplates["Ouvrage"]["pages totales"] = {"es":"páginas"};
LinkTranslate_BiblioTemplates["Ouvrage"]["passage"] = {"es":"capítulo"};
LinkTranslate_BiblioTemplates["Ouvrage"]["consulté le"] = {"es":"fechaacceso"};
LinkTranslate_BiblioTemplates["Article"] = {};
LinkTranslate_BiblioTemplates["Article"]["langue"] = {"es":"idioma"};
LinkTranslate_BiblioTemplates["Article"]["prénom1"] = {"es":"nombre"};
LinkTranslate_BiblioTemplates["Article"]["nom1"] = {"es":["apellidos", "apellido"]};
LinkTranslate_BiblioTemplates["Article"]["lien auteur1"] = {"es":"enlaceautor"};
LinkTranslate_BiblioTemplates["Article"]["titre"] = {"es":"título"};
LinkTranslate_BiblioTemplates["Article"]["périodique"] = {"es":["revista","publicación"]};
LinkTranslate_BiblioTemplates["Article"]["éditeur"] = {"es":"editor"};
LinkTranslate_BiblioTemplates["Article"]["volume"] = {"es":"volumen"};
LinkTranslate_BiblioTemplates["Article"]["numéro"] = {"es":"número"};
LinkTranslate_BiblioTemplates["Article"]["année"] = {"es":"año"};
LinkTranslate_BiblioTemplates["Article"]["date"] = {"es":"fecha"};
LinkTranslate_BiblioTemplates["Article"]["pages"] = {"es":"páginas"};
LinkTranslate_BiblioTemplates["Article"]["consulté le"] = {"es":"fechaacceso"};
LinkTranslate_BiblioTemplates["Lien web"] = {};
LinkTranslate_BiblioTemplates["Lien web"]["url"] = {"es":"url"};
LinkTranslate_BiblioTemplates["Lien web"]["titre"] = {"es":"título"};
LinkTranslate_BiblioTemplates["Lien web"]["auteur"] = {"es":"autor"};
LinkTranslate_BiblioTemplates["Lien web"]["lien auteur"] = {"es":"enlaceautor"};
LinkTranslate_BiblioTemplates["Lien web"]["date"] = {"es":"fecha"};
LinkTranslate_BiblioTemplates["Lien web"]["année"] = {"es":"año"};
LinkTranslate_BiblioTemplates["Lien web"]["mois"] = {"es":"mes"};
LinkTranslate_BiblioTemplates["Lien web"]["éditeur"] = {"es":"editor"};
LinkTranslate_BiblioTemplates["Lien web"]["page"] = {"es":"página"};
LinkTranslate_BiblioTemplates["Lien web"]["citation"] = {"es":"cita"};
LinkTranslate_BiblioTemplates["Lien web"]["consulté le"] = {"es":"fechaacceso"};
LinkTranslate_DoTranslation["BiblioTemplates"] = function(PageToTranslateContent){
for(var Template in LinkTranslate_BiblioTemplates){
if(!LinkTranslate_BiblioTemplates.hasOwnProperty(Template)) continue;
var TemplateRegExp = new RegExp("\\{\\{[ ]*"+Template+"[ ]*\\|[^\\}]*\\}\\}", "ig");
var Matches = PageToTranslateContent.match(TemplateRegExp);
if(Matches==null) continue;
for(var a=0,l=Matches.length;a<l;a++){
var ThisTemplate = Matches[a];
for(var Param in LinkTranslate_BiblioTemplates[Template]){
if(LinkTranslate_BiblioTemplates[Template].hasOwnProperty(Param)){
var ThisParam = LinkTranslate_BiblioTemplates[Template][Param][MenuChoices["LangToTranslate"]];
if(ThisParam){
if(typeof(ThisParam)==="object") ThisParam = "("+ThisParam.join("|")+")";
var ParamRegExp = new RegExp("\\|[ ]*"+ThisParam+"[ ]*=", "g");
var ParamMatches = ThisTemplate.match(ParamRegExp);
if(ParamMatches!=null){
ThisTemplate = ThisTemplate.replace(ParamRegExp, "|"+Param+"=");
}
}
}
}
PageToTranslateContent = PageToTranslateContent.replace(Matches[a], ThisTemplate);
}
}
return PageToTranslateContent;
}
LinkTranslate_DoTranslation["Categories"] = function(PageToTranslateContent){
var TYPE = "Categories";
var PageToTranslate = MenuChoices["PageToTranslate"];
var LangToTranslate = MenuChoices["LangToTranslate"];
var TranslatedPage = MenuChoices["TranslatedPage"];
var TranslatedLang = MenuChoices["TranslatedLang"];
var ItemsToTranslate = ElementsToTranslateListParams[TYPE]["items"];
for(var a=0;a<ItemsToTranslate.length;a++){
var ThisItem = ItemsToTranslate[a];
if(ThisItem.missing) continue;
var oldtitle = ThisItem.title;
var newtitle = ThisItem.translatedtitle;
if(newtitle){
var CategoriesRegExp = new RegExp("\\[\\[[ ]*"+oldtitle, "ig");
PageToTranslateContent = PageToTranslateContent.replace(CategoriesRegExp, "[["+newtitle);
}
}
return PageToTranslateContent;
}
///////////////// PREMIÈRE LETTRE EN MAJUSCULE ////////////////////////////////////
String.prototype.ucFirst = function () {
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
///////////////// PREMIÈRE LETTRE EN MINUSCULE ////////////////////////////////////
String.prototype.lcFirst = function () {
return this.substr(0,1).toLowerCase() + this.substr(1,this.length);
}
///////////////// LANCEMENT ////////////////////////////////////
if((mw.config.get('wgNamespaceNumber')>-1)&&( ["view","purge"].indexOf(mw.config.get('wgAction'))!= -1)){
$(LinkTranslate_AddLink);
}
//</nowiki></pre></source>