jenkins-bot has submitted this change and it was merged.
Change subject: [PagePreparation] Templates excluded outside <translate> tags
......................................................................
[PagePreparation] Templates excluded outside <translate> tags
The templates present in a wiki page are kept outside <translate>
tags as a part of the page template.
Bug: 66711
Change-Id: If47b5be24e64c206e30986029404777ea9c31223
---
M resources/js/ext.translate.pagepreparation.js
1 file changed, 18 insertions(+), 0 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
Nemo bis: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/resources/js/ext.translate.pagepreparation.js
b/resources/js/ext.translate.pagepreparation.js
index 0cd5fd0..64d0449 100644
--- a/resources/js/ext.translate.pagepreparation.js
+++ b/resources/js/ext.translate.pagepreparation.js
@@ -184,6 +184,21 @@
}
/**
+ * Keep templates outside <translate>....</translate> tags
+ * Does not deal with nested templates, needs manual changes.
+ * @param {string} pageContent
+ * @return {string} pageContent
+ */
+ function doTemplates( pageContent ) {
+ var templateRegex;
+ // Regex: http://regex101.com/r/wA3iX0
+ templateRegex = new RegExp( /^({{[\s\S]*?}})/gm );
+
+ pageContent = pageContent.replace( templateRegex,
'</translate>\n$1\n<translate>' );
+ return pageContent;
+ }
+
+ /**
* Cleanup done after the page is prepared for translation by the tool.
* @param {string} pageContent
* @return {string}
@@ -191,6 +206,8 @@
function postPreparationCleanup( pageContent ) {
// Removes any extra newlines introduced by the tool
pageContent = pageContent.replace( /\n\n+/gi, '\n\n' );
+ // Removes redundant <translate> tags
+ pageContent = pageContent.replace(
/\n<translate>(\n*?)<\/translate>/gi, '' );
return pageContent;
}
@@ -280,6 +297,7 @@
pageContent = addTranslateTags( pageContent );
pageContent = addNewLines( pageContent );
pageContent = fixInternalLinks( pageContent );
+ pageContent = doTemplates( pageContent );
doFiles( pageContent ).done( function(
pageContent ) {
pageContent = postPreparationCleanup(
pageContent );
pageContent = $.trim( pageContent );
--
To view, visit https://gerrit.wikimedia.org/r/140128
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If47b5be24e64c206e30986029404777ea9c31223
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: BPositive <[email protected]>
Gerrit-Reviewer: BPositive <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits