Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/313962
Change subject: Links: Keep original and redirect resolved source title in
linkpair cache
......................................................................
Links: Keep original and redirect resolved source title in linkpair cache
Bug: T145691
Change-Id: I4c9f7a17b5e169468e21e512c9fd2970422f888a
---
M modules/tools/ext.cx.tools.link.js
1 file changed, 18 insertions(+), 9 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/62/313962/1
diff --git a/modules/tools/ext.cx.tools.link.js
b/modules/tools/ext.cx.tools.link.js
index 5ea1427..ddad7f7 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -98,25 +98,34 @@
redirects = jQuery.extend( {}, response.query.redirects
);
$.each( response.query.pages, function ( pageId, page )
{
- var i, key, title;
+ var i, redirectedSourceTitle, title;
+
+ if ( !page.langlinks ) {
+ return;
+ }
for ( i in redirects ) {
// Locate the title in redirects, if
any.
if ( redirects[ i ].to === page.title )
{
- key = redirects[ i ].from;
+ redirectedSourceTitle =
redirects[ i ].from;
break;
}
}
- if ( !key ) {
- key = page.title;
+ // Add the redirected source title in link pair
mapping.
+ if ( redirectedSourceTitle ) {
+ title = mw.Title.newFromText(
redirectedSourceTitle );
}
-
- title = mw.Title.newFromText( key );
-
if ( title ) {
- linkPairs[ title.toText() ] =
page.langlinks &&
- page.langlinks[ 0 ][ '*' ];
+ linkPairs[ title.toText() ] =
page.langlinks[ 0 ][ '*' ];
+ }
+ // Irrespective of redirect or not, add the
original source title in link pair mapping.
+ // So if a paragraph has link to LuaJIT and Lua
(programming language),
+ // both get resolved to Lua (programming
language) mapped to hewiki:"לואה (שפת תכנות)"
+ // linkPairs will have keys for LuaJIT and Lua
(programming language).
+ title = mw.Title.newFromText( page.title );
+ if ( title ) {
+ linkPairs[ title.toText() ] =
page.langlinks[ 0 ][ '*' ];
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/313962
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c9f7a17b5e169468e21e512c9fd2970422f888a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits