User talk:Ebrahim/ArticleTranslator.js: Difference between revisions
(30 intermediate revisions by 14 users not shown) | |||
Line 1: | Line 1: | ||
== JUST COPY THIS ON YOUR COMMON.JS == |
|||
==About this tool== |
|||
<syntaxhighlight lang="javascript"> |
|||
this tool is useful for translating wikipedia links according to interwikis also it has some statistics options |
|||
window.articleTranslatorConf = { |
|||
options: |
|||
'homeWiki': 'YOUR_HOME_WIKI_LANGUAGE_CODE' |
|||
#translating links in Read mode (adding target wiki links near the original) |
|||
}; |
|||
#translating links in edit mode (replacing target links instead of original one) |
|||
importScript('User:Ebrahim/ArticleTranslator.js'); |
|||
#counting number of interwikis that are linked to pages that are not in target wiki (by pressing + button near the page title) |
|||
</syntaxhighlight> |
|||
#search words translation in Google translation and Google search engine (by pressing = button near the page title) |
|||
#constructing list of pages that are not in target wiki and sort it according to number of interwikis and number of Special:WhatLinksHere (by pressing + button near the page title) |
|||
== About this tool == |
|||
for more information, if you know Persian see [[:fa:ویکیپدیا:راهنمای ابزار کمک مترجم]] otherwise use Google translation :) |
|||
This tool is useful for translating wikipedia links according to interwikis also it has some statistics options: |
|||
# Translating links in Read mode (adding target wiki links near the original) |
|||
# Translating links in edit mode (replacing target links instead of original one) |
|||
# Counting number of interwikis that are linked to pages that are not in target wiki (by pressing + button near the page title) |
|||
# Search words translation in Google translation and Google search engine (by pressing = button near the page title) |
|||
# Constructing list of pages that are not in target wiki and sort it according to number of interwikis and number of Special:WhatLinksHere (by pressing + button near the page title) |
|||
For more information, if you know Persian see [[:fa:ویکیپدیا:راهنمای ابزار کمک مترجم]] otherwise use [http://translate.google.com/?hl=en&tab=oT#fa/en/ Google translation] :) |
|||
== |
== Customizing == |
||
; |
;Using this code |
||
For using this code you can customize it with this variables and you should put this code in [[Special:Mypage/common.js]] |
For using this code you can customize it with this variables and you should put this code in [[Special:Mypage/common.js]] |
||
< |
<syntaxhighlight lang="javascript"> |
||
window.articleTranslatorConf = { |
|||
var fromLang = "en"; //the source language Aliases |
|||
'homeWiki': 'fa', |
|||
var translatorBarFormat = "$1translate $2 this link from $3 to $4"; // translate it to your language |
|||
'fromLang': 'en', |
|||
var templateTranslatorText = "Template translation"; // translate it to your language |
|||
'translatorBarFormat': '$1translate$2 links from $3 to $4 ($5)', |
|||
var removeLinksAliasesText = "Remove Links Aliases"; |
|||
'templateTranslatorText': 'Template translation', |
|||
var doneText = "Done!"; // translate it to your language |
|||
'removeLinksAliasesText': 'Remove Links Aliases', |
|||
importScriptURI("http://en.wikipedia.org/enwiki/w/index.php?title=User:Ebraminio/ArticleTranslator.js&action=raw&ctype=text/javascript"); |
|||
'doneText': 'Done!', |
|||
</source> |
|||
'enableTemplateTranslation': true, |
|||
'removeLinksAliases': true, |
|||
'enableNeedingShow': false, |
|||
'name': 'Name', |
|||
'interwikiCount': 'Interwiki Count', |
|||
'linkedTo': 'Linked to', |
|||
'listOfUnavailablePagesOn': 'List of not available pages on' |
|||
}; |
|||
</syntaxhighlight> |
|||
Every parameter (line) is optional and if you don't specify it, it will fallback to script defaults. For example if you just want to change the home wiki, this would be enough: |
|||
<syntaxhighlight lang="javascript"> |
|||
window.articleTranslatorConf = { |
|||
'homeWiki': 'fr' |
|||
}; |
|||
</syntaxhighlight> |
|||
[[:fa:مدیاویکی:Gadget-TranslationHelper.js|Here]] is a sample for this gadget translation/localization. |
|||
== Disable on special pages == |
|||
Hi {{U|Ebraminio}}! |
|||
Could you change the script so it is not enabled on special pages? [[User talk:Helder.wiki|Helder]] 11:16, 16 November 2013 (UTC) |
|||
:Hi {{U|Helder.wiki}}. It is very nice for me that you are using the script! :) IMHO special pages are also good to have the feature generally and disabling the script there is making users flexibility less so I think it is better to leave this on :) But if you don't like this enabled on a special special page(!) please bring a example about it. Thank you :) –[[User:Ebraminio|ebraminio]]<sup>[[User talk:Ebraminio|talk]]</sup> 23:48, 9 January 2014 (UTC) |
|||
== TfD that may be of interest == |
|||
This script is part of the discussion on [[Wikipedia:Templates for discussion/Log/2016 March 18#Template:English to urdu wikipedia]] <kbd>[[User:PC-XT|—PC]][[User talk:PC-XT|-XT]][[Special:Contribs/PC-XT|+]]</kbd> 05:23, 19 March 2016 (UTC) 22:42, 19 March 2016 (UTC) |
|||
== Script showing up in Category:Pages using invalid self-closed HTML tags == |
|||
Your script, and copies of it, are showing up in {{cl|Pages using invalid self-closed HTML tags}}. Can you please fix it by changing both instances of <code><nowiki><span id="..." /></nowiki></code> to <code><nowiki><span id="..."></span></nowiki></code>? Let me know if you have any questions. Thanks. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 20:17, 31 October 2017 (UTC) |
|||
:[[User:Jonesey95|Jonesey95]]: [https://en.wikipedia.org/?diff=776331022 Done]. Thanks :) −[[User:Ebrahim|ebrahim]]<sup>[[User talk:Ebrahim|talk]]</sup> 21:10, 27 November 2017 (UTC) |
|||
== Script Not working == |
|||
First, this script is nice, but there is a problem, we use it in sd.wikipedia, but suddenly it stopped working, don't know what happened, it will be great help if you solve this problem for us. if you want to search for the script in sd.wikipedia, just type, MediaWiki:Tourwiki - Thanks in advance. [[User:Arslanali|Arslanali]] ([[User talk:Arslanali|talk]]) 15:12, 25 October 2018 (UTC) |
|||
== Ar language == |
|||
Hello. I want to use this tool to translate links from en to ar, not fa. What should I write in [[User:Avocato/common.js]]?--<span style="text-shadow:-1px 0 lightblue,0 1px lightblue,1px 0 lightblue,0 -1px lightblue;">[[User:Avocato|<b style="color:#0645ad">Avocato</b>]]</span> <span style="font-family:Tahoma; font-size:x-small;">[[User talk:Avocato|<b style="color:#fb139e">(talk)</b>]]</span> 12:43, 17 May 2019 (UTC) |
|||
:[[User:Avocato]]: Hi! You will need something like this, |
|||
<syntaxhighlight lang="js"> |
|||
window.articleTranslatorConf = { |
|||
homeWiki: 'ar', // home wiki, which language you want links to be translated to by default |
|||
fromLang: mw.config.get('wgPageContentLanguage'), // from language, which language you want links to be translated from by default, usually the wiki you are in anyway |
|||
translatorBarFormat: '$1translate$2 links from $3 to $4 $5', // translate what is in quotes except $1 $2 $3 $4 $5 which are placeholders |
|||
templateTranslatorText: 'Template translation', // translate what is in quotes |
|||
removeLinksAliasesText: 'Remove Links Aliases', // translate what is in quotes |
|||
interwikiCount: 'Language links count', // translate what is in quotes |
|||
linkedTo: 'Linked to', // translate what is in quotes |
|||
listOfUnavailablePagesOn: 'List of not present pages on' // translate what is in quotes |
|||
}; |
|||
importScript('User:Ebrahim/ArticleTranslator.js'); |
|||
</syntaxhighlight> |
|||
But if you are using this in English Wikipedia anyway, what you got already is ok. Thanks :) −[[User:Ebrahim|ebrahim]]<sup>[[User talk:Ebrahim|talk]]</sup> 12:35, 11 May 2021 (UTC) |
|||
== user-select == |
|||
{{ping|Ebrahim}} when you enable, a phrase is added after the page the title threads something like "translate links from en to fa". If you triple-click on the page title to select it, this phrase is also selected which is not desirable. The solution is to make sure <code><nowiki><span id="translatorBar"></nowiki></code> has the <code>user-select</code> CSS property set to <code>none</code>. |
|||
I think the best approach is to create a page called [[User:Ebrahim/ArticleTranslator.css]] on enwiki, then use <code>importStylesheet</code> at the top of [[:fa:MediaWiki:Tofawiki.js]] to load this CSS page. The content of the CSS page should be: |
|||
<syntaxhighlight lang=css> |
|||
span#translatorBar, span#translatorBar * { |
|||
-moz-user-select: none; |
|||
-webkit-user-select: none; |
|||
-ms-user-select: none; |
|||
user-select: none; |
|||
} |
|||
</syntaxhighlight> |
|||
We use a similar one in [[:fa:MediaWiki:Gadget-close.css]] for that same reason. [[User:Huji|huji]]—[[User_talk:Huji|<small>TALK</small>]] 16:49, 11 March 2020 (UTC) |
|||
:This is fixed eventually however needed some more workaround in order to make it work in all the different browsers (this was alone was breaking Safari that's why I didn't apply it immediately). −[[User:Ebrahim|ebrahim]]<sup>[[User talk:Ebrahim|talk]]</sup> 12:35, 11 May 2021 (UTC) |
|||
== A tool with a similar function == |
|||
Hi, do you know about [[Wikipedia:Lacmus]]? [[User:JWBTH|JWBTH]] ([[User talk:JWBTH|talk]]) 17:01, 26 May 2023 (UTC) |
|||
:Interesting, thanks for sharing 😊 −[[User:Ebrahim|ebrahim]]<sup>[[User talk:Ebrahim|talk]]</sup> 06:13, 14 April 2024 (UTC) |
|||
== definedTemplatesfortemplates and definedTemplatesforcategories == |
|||
Hi, I made some changes to your code, to translate templates and categories link in templates like: |
|||
<syntaxhighlight lang=wikitext> |
|||
from {{clc|All country data templates}} to {{clc|جميع قوالب بيانات بلد}} |
|||
from {{t|reflist}} to {{t|مراجع}} |
|||
</syntaxhighlight> |
|||
<syntaxhighlight lang=js> |
|||
definedTemplatesfortemplates: [ |
|||
"T", |
|||
"Tl", |
|||
"Tla" |
|||
], |
|||
definedTemplatesforcategories: [ |
|||
"C", |
|||
"Category link with count", |
|||
"Category link" |
|||
], |
|||
</syntaxhighlight> |
|||
Here is the changed code: [[:meta:User:Mr._Ibrahem/ArticleTranslator_2024.js]]. |
|||
Thanks. [[User:Mr. Ibrahem|Mr. Ibrahem]] ([[User talk:Mr. Ibrahem|talk]]) 23:54, 13 June 2024 (UTC) |
|||
==not work in edit mood== |
|||
its not work in edit mood but work in some file have (viw source) mood [[User:Redaking|Redaking]] ([[User talk:Redaking|talk]]) 06:01, 16 July 2024 (UTC) |
Latest revision as of 06:01, 16 July 2024
JUST COPY THIS ON YOUR COMMON.JS
[edit]window.articleTranslatorConf = {
'homeWiki': 'YOUR_HOME_WIKI_LANGUAGE_CODE'
};
importScript('User:Ebrahim/ArticleTranslator.js');
About this tool
[edit]This tool is useful for translating wikipedia links according to interwikis also it has some statistics options:
- Translating links in Read mode (adding target wiki links near the original)
- Translating links in edit mode (replacing target links instead of original one)
- Counting number of interwikis that are linked to pages that are not in target wiki (by pressing + button near the page title)
- Search words translation in Google translation and Google search engine (by pressing = button near the page title)
- Constructing list of pages that are not in target wiki and sort it according to number of interwikis and number of Special:WhatLinksHere (by pressing + button near the page title)
For more information, if you know Persian see fa:ویکیپدیا:راهنمای ابزار کمک مترجم otherwise use Google translation :)
Customizing
[edit]- Using this code
For using this code you can customize it with this variables and you should put this code in Special:Mypage/common.js
window.articleTranslatorConf = {
'homeWiki': 'fa',
'fromLang': 'en',
'translatorBarFormat': '$1translate$2 links from $3 to $4 ($5)',
'templateTranslatorText': 'Template translation',
'removeLinksAliasesText': 'Remove Links Aliases',
'doneText': 'Done!',
'enableTemplateTranslation': true,
'removeLinksAliases': true,
'enableNeedingShow': false,
'name': 'Name',
'interwikiCount': 'Interwiki Count',
'linkedTo': 'Linked to',
'listOfUnavailablePagesOn': 'List of not available pages on'
};
Every parameter (line) is optional and if you don't specify it, it will fallback to script defaults. For example if you just want to change the home wiki, this would be enough:
window.articleTranslatorConf = {
'homeWiki': 'fr'
};
Here is a sample for this gadget translation/localization.
Disable on special pages
[edit]Hi Ebraminio!
Could you change the script so it is not enabled on special pages? Helder 11:16, 16 November 2013 (UTC)
- Hi Helder.wiki. It is very nice for me that you are using the script! :) IMHO special pages are also good to have the feature generally and disabling the script there is making users flexibility less so I think it is better to leave this on :) But if you don't like this enabled on a special special page(!) please bring a example about it. Thank you :) –ebraminiotalk 23:48, 9 January 2014 (UTC)
TfD that may be of interest
[edit]This script is part of the discussion on Wikipedia:Templates for discussion/Log/2016 March 18#Template:English to urdu wikipedia —PC-XT+ 05:23, 19 March 2016 (UTC) 22:42, 19 March 2016 (UTC)
Script showing up in Category:Pages using invalid self-closed HTML tags
[edit]Your script, and copies of it, are showing up in Category:Pages using invalid self-closed HTML tags. Can you please fix it by changing both instances of <span id="..." />
to <span id="..."></span>
? Let me know if you have any questions. Thanks. – Jonesey95 (talk) 20:17, 31 October 2017 (UTC)
- Jonesey95: Done. Thanks :) −ebrahimtalk 21:10, 27 November 2017 (UTC)
Script Not working
[edit]First, this script is nice, but there is a problem, we use it in sd.wikipedia, but suddenly it stopped working, don't know what happened, it will be great help if you solve this problem for us. if you want to search for the script in sd.wikipedia, just type, MediaWiki:Tourwiki - Thanks in advance. Arslanali (talk) 15:12, 25 October 2018 (UTC)
Ar language
[edit]Hello. I want to use this tool to translate links from en to ar, not fa. What should I write in User:Avocato/common.js?--Avocato (talk) 12:43, 17 May 2019 (UTC)
- User:Avocato: Hi! You will need something like this,
window.articleTranslatorConf = {
homeWiki: 'ar', // home wiki, which language you want links to be translated to by default
fromLang: mw.config.get('wgPageContentLanguage'), // from language, which language you want links to be translated from by default, usually the wiki you are in anyway
translatorBarFormat: '$1translate$2 links from $3 to $4 $5', // translate what is in quotes except $1 $2 $3 $4 $5 which are placeholders
templateTranslatorText: 'Template translation', // translate what is in quotes
removeLinksAliasesText: 'Remove Links Aliases', // translate what is in quotes
interwikiCount: 'Language links count', // translate what is in quotes
linkedTo: 'Linked to', // translate what is in quotes
listOfUnavailablePagesOn: 'List of not present pages on' // translate what is in quotes
};
importScript('User:Ebrahim/ArticleTranslator.js');
But if you are using this in English Wikipedia anyway, what you got already is ok. Thanks :) −ebrahimtalk 12:35, 11 May 2021 (UTC)
user-select
[edit]@Ebrahim: when you enable, a phrase is added after the page the title threads something like "translate links from en to fa". If you triple-click on the page title to select it, this phrase is also selected which is not desirable. The solution is to make sure <span id="translatorBar">
has the user-select
CSS property set to none
.
I think the best approach is to create a page called User:Ebrahim/ArticleTranslator.css on enwiki, then use importStylesheet
at the top of fa:MediaWiki:Tofawiki.js to load this CSS page. The content of the CSS page should be:
span#translatorBar, span#translatorBar * {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
We use a similar one in fa:MediaWiki:Gadget-close.css for that same reason. huji—TALK 16:49, 11 March 2020 (UTC)
- This is fixed eventually however needed some more workaround in order to make it work in all the different browsers (this was alone was breaking Safari that's why I didn't apply it immediately). −ebrahimtalk 12:35, 11 May 2021 (UTC)
A tool with a similar function
[edit]Hi, do you know about Wikipedia:Lacmus? JWBTH (talk) 17:01, 26 May 2023 (UTC)
- Interesting, thanks for sharing 😊 −ebrahimtalk 06:13, 14 April 2024 (UTC)
definedTemplatesfortemplates and definedTemplatesforcategories
[edit]Hi, I made some changes to your code, to translate templates and categories link in templates like:
from {{clc|All country data templates}} to {{clc|جميع قوالب بيانات بلد}}
from {{t|reflist}} to {{t|مراجع}}
definedTemplatesfortemplates: [
"T",
"Tl",
"Tla"
],
definedTemplatesforcategories: [
"C",
"Category link with count",
"Category link"
],
Here is the changed code: meta:User:Mr._Ibrahem/ArticleTranslator_2024.js. Thanks. Mr. Ibrahem (talk) 23:54, 13 June 2024 (UTC)
not work in edit mood
[edit]its not work in edit mood but work in some file have (viw source) mood Redaking (talk) 06:01, 16 July 2024 (UTC)