From f2c5c5613bd4a15c5d403b6383b9e2bbca16bc2a Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 10 Aug 2015 17:57:09 +0200 Subject: [PATCH] Add translateable tooltip message for CodeMirror button Use a message, that explains a bit more, what CodeMirror is and indicate what the button do exactly. Change-Id: If8a0a8261cd811407cff4868dcf6475335b3f752 --- CodeMirror.php | 4 ++++ i18n/en.json | 4 +++- i18n/qqq.json | 4 +++- resources/ext.CodeMirror.js | 12 +++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CodeMirror.php b/CodeMirror.php index 6449c81d..acb43367 100644 --- a/CodeMirror.php +++ b/CodeMirror.php @@ -54,6 +54,10 @@ $wgResourceModules['ext.CodeMirror.init'] = $wgCodeMirrorResourceTemplate + arra 'scripts' => array( 'ext.CodeMirror.js' ), + 'messages' => array( + 'codemirror-enable-label', + 'codemirror-disable-label', + ), 'group' => 'ext.CodeMirror', ); diff --git a/i18n/en.json b/i18n/en.json index 94afa106..e6753ff9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -4,5 +4,7 @@ "pastakhov" ] }, - "codemirror-desc": "Provides syntax highlighting in wikitext editor" + "codemirror-desc": "Provides syntax highlighting in wikitext editor", + "codemirror-enable-label": "Enable CodeMirror (Syntaxhighlight)", + "codemirror-disable-label": "Disable CodeMirror (Syntaxhighlight)" } diff --git a/i18n/qqq.json b/i18n/qqq.json index 2f84689a..5fce41ed 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -7,5 +7,7 @@ "Shirayuki" ] }, - "codemirror-desc": "{{desc|name=Code Mirror|url=https://www.mediawiki.org/wiki/Extension:CodeMirror}}\n\nAdditional info: Discription of \"Syntax highlighting\" in wiki\n[[mw:Extension:SyntaxHighlight GeSHi]]" + "codemirror-desc": "{{desc|name=Code Mirror|url=https://www.mediawiki.org/wiki/Extension:CodeMirror}}\n\nAdditional info: Discription of \"Syntax highlighting\" in wiki\n[[mw:Extension:SyntaxHighlight GeSHi]]", + "codemirror-enable-label": "Title tooltip for button to enable CodeMirror in the editing toolbar.", + "codemirror-disable-label": "Title tooltip for button to disable CodeMirror in the editing toolbar." } diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js index 96fb1d04..a3e968ea 100644 --- a/resources/ext.CodeMirror.js +++ b/resources/ext.CodeMirror.js @@ -205,6 +205,8 @@ */ addCodeMirrorToWikiEditor = function () { if ( $( '#wikiEditor-section-main' ).length > 0 ) { + var msg = codeMirror ? 'codemirror-disable-label' : 'codemirror-enable-label'; + $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { @@ -213,7 +215,7 @@ 'codemirror':{ 'tools': { 'CodeMirror': { - label: 'CodeMirror', + label: mw.msg( msg ), type: 'button', // FIXME: There should be a better way? icon: mw.config.get( 'wgExtensionAssetsPath' ) + '/CodeMirror/resources/images/cm-' + ( codeMirror ? 'on.png' : 'off.png' ), @@ -269,11 +271,15 @@ codeMirror = false; $.fn.textSelection = origTextSelection; $src = mw.config.get( 'wgExtensionAssetsPath' ) + '/CodeMirror/resources/images/' + ( context ? 'cm-off.png' : 'old-cm-off.png' ); - $img.attr( 'src', $src ); + $img + .attr( 'src', $src ) + .attr( 'title', mw.msg( 'codemirror-enable-label' ) ); } else { enableCodeMirror(); $src = mw.config.get( 'wgExtensionAssetsPath' ) + '/CodeMirror/resources/images/' + ( context ? 'cm-on.png' : 'old-cm-on.png' ); - $img.attr( 'src', $src ); + $img + .attr( 'src', $src ) + .attr( 'title', mw.msg( 'codemirror-disable-label' ) ); setCodeEditorPreference( true ); } }