MDL-45635 javascript: Make core dialogue translatable

This commit is contained in:
Andrew Nicols 2014-05-23 16:01:48 +08:00
parent 3e511ca50b
commit 0d1d542332
14 changed files with 34 additions and 22 deletions

View File

@ -146,6 +146,7 @@ $string['answer'] = 'Answer';
$string['any'] = 'Any';
$string['approve'] = 'Approve';
$string['appearance'] = 'Appearance';
$string['areyousure'] = 'Are you sure?';
$string['areyousuretorestorethis'] = 'Do you want to continue?';
$string['areyousuretorestorethisinfo'] = 'Later in this process you will have a choice of adding this backup to an existing course or creating a completely new course.';
$string['asc'] = 'Ascending';
@ -255,6 +256,7 @@ $string['clickhere'] = 'Click here ...';
$string['clicktohideshow'] = 'Click to expand or collapse';
$string['clicktochangeinbrackets'] = '{$a} (Click to change)';
$string['closewindow'] = 'Close this window';
$string['closebuttontitle'] = 'Close';
$string['collapse'] = 'Collapse';
$string['collapseall'] = 'Collapse all';
$string['collapsecategory'] = 'Collapse {$a}';
@ -1849,6 +1851,7 @@ $string['turneditingon'] = 'Turn editing on';
$string['undecided'] = 'Undecided';
$string['unfinished'] = 'Unfinished';
$string['unknowncategory'] = 'Unknown category';
$string['unknownerror'] = 'Unknown error';
$string['unlimited'] = 'Unlimited';
$string['unpacking'] = 'Unpacking {$a}';
$string['unsafepassword'] = 'Unsafe password - try something else';

View File

@ -1433,6 +1433,15 @@ class page_requirements_manager {
}
// Add all needed strings.
// First add core strings required for some dialogues.
$this->strings_for_js(array(
'confirm',
'yes',
'no',
'areyousure',
'closebuttontitle',
'unknownerror',
), 'moodle');
if (!empty($this->stringsforjs)) {
$strings = array();
foreach ($this->stringsforjs as $component=>$v) {

View File

@ -102,7 +102,7 @@ Y.extend(AJAXEXCEPTION, M.core.notification.info, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**

View File

@ -1 +1 @@
YUI.add("moodle-core-notification-ajaxexception",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var f="Moodle AJAX exception",l;l=function(e){e.name=e.name||"Error",e.closeButton=!0,l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_keypress:null,initializer:function(t){var n,i=this,s=this.get("hideTimeoutDelay");this.get(r).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+t.name+"</h1>",e.WidgetStdMod.REPLACE),n=e.Node.create('<div class="moodle-ajaxexception"></div>').append(e.Node.create('<div class="moodle-exception-message">'+this.get("error")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get("reproductionlink")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get("debuginfo")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get("stacktrace")+"</pre></div>")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),s&&(this._hideTimeout=setTimeout(function(){i.hide()},s)),this.after("visibleChange",this.visibilityChanged,this),this._keypress=e.on("key",this.hide,window,"down:13, 27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){var t=this;this._keypress.detach(),setTimeout(function(){t.destroy()},1e3)}}},{NAME:f,CSS_PREFIX:n,ATTRS:{error:{validator:e.Lang.isString,value:"Unknown error"},debuginfo:{value:null},stacktrace:{value:null},reproductionlink:{setter:function(e){return e!==null&&(e='<a href="'+e+'">'+e.replace(M.cfg.wwwroot,"")+"</a>"),e},value:null},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),M.core.ajaxException=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
YUI.add("moodle-core-notification-ajaxexception",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var f="Moodle AJAX exception",l;l=function(e){e.name=e.name||"Error",e.closeButton=!0,l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_keypress:null,initializer:function(t){var n,i=this,s=this.get("hideTimeoutDelay");this.get(r).addClass("moodle-dialogue-exception"),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+t.name+"</h1>",e.WidgetStdMod.REPLACE),n=e.Node.create('<div class="moodle-ajaxexception"></div>').append(e.Node.create('<div class="moodle-exception-message">'+this.get("error")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get("reproductionlink")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get("debuginfo")+"</div>")).append(e.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get("stacktrace")+"</pre></div>")),M.cfg.developerdebug&&n.all(".moodle-exception-param").removeClass("hidden"),this.setStdModContent(e.WidgetStdMod.BODY,n,e.WidgetStdMod.REPLACE),s&&(this._hideTimeout=setTimeout(function(){i.hide()},s)),this.after("visibleChange",this.visibilityChanged,this),this._keypress=e.on("key",this.hide,window,"down:13, 27",this),this.centerDialogue()},visibilityChanged:function(e){if(e.attrName==="visible"&&e.prevVal&&!e.newVal){var t=this;this._keypress.detach(),setTimeout(function(){t.destroy()},1e3)}}},{NAME:f,CSS_PREFIX:n,ATTRS:{error:{validator:e.Lang.isString,value:M.util.get_string("unknownerror","moodle")},debuginfo:{value:null},stacktrace:{value:null},reproductionlink:{setter:function(e){return e!==null&&(e='<a href="'+e+'">'+e.replace(M.cfg.wwwroot,"")+"</a>"),e},value:null},hideTimeoutDelay:{validator:e.Lang.isNumber,value:null}}}),M.core.ajaxException=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});

View File

@ -102,7 +102,7 @@ Y.extend(AJAXEXCEPTION, M.core.notification.info, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**

View File

@ -113,7 +113,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
yesLabel: {
validator: Y.Lang.isString,
value: 'Yes'
value: M.util.get_string('yes', 'moodle')
},
/**
@ -125,7 +125,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
noLabel: {
validator: Y.Lang.isString,
value: 'No'
value: M.util.get_string('no', 'moodle')
},
/**
@ -137,7 +137,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
title: {
validator: Y.Lang.isString,
value: 'Confirm'
value: M.util.get_string('confirm', 'moodle')
},
/**
@ -149,7 +149,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
question: {
validator: Y.Lang.isString,
value: 'Are you sure?'
value: M.util.get_string('areyousure', 'moodle')
}
}
});

View File

@ -1 +1 @@
YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var f="Moodle confirmation dialogue",l;l=function(e){l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_closeEvents:null,initializer:function(){this._closeEvents=[],this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create('<input type="button" id="id_yuiconfirmyes-'+this.get("COUNT")+'" value="'+this.get(i)+'" />'),n=e.Node.create('<input type="button" id="id_yuiconfirmno-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),a=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get(u)+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,a,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(o)+"</h1>",e.WidgetStdMod.REPLACE),this._closeEvents.push(e.on("key",this.submit,window,"down:27",this,!1),t.on("click",this.submit,this,!0),n.on("click",this.submit,this,!1));var f=this.get("boundingBox").one(".closebutton");f&&this._closeEvents.push(f.on("click",this.submit,this))},submit:function(t,n){(new e.EventHandle(this._closeEvents)).detach(),this.fire("complete",n),n?this.fire("complete-yes"):this.fire("complete-no"),this.hide(),this.destroy()}},{NAME:f,CSS_PREFIX:n,ATTRS:{yesLabel:{validator:e.Lang.isString,value:"Yes"},noLabel:{validator:e.Lang.isString,value:"No"},title:{validator:e.Lang.isString,value:"Confirm"},question:{validator:e.Lang.isString,value:"Are you sure?"}}}),e.augment(l,e.EventTarget),M.core.confirm=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});
YUI.add("moodle-core-notification-confirm",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"},M.core=M.core||{};var f="Moodle confirmation dialogue",l;l=function(e){l.superclass.constructor.apply(this,[e])},e.extend(l,M.core.notification.info,{_closeEvents:null,initializer:function(){this._closeEvents=[],this.publish("complete"),this.publish("complete-yes"),this.publish("complete-no");var t=e.Node.create('<input type="button" id="id_yuiconfirmyes-'+this.get("COUNT")+'" value="'+this.get(i)+'" />'),n=e.Node.create('<input type="button" id="id_yuiconfirmno-'+this.get("COUNT")+'" value="'+this.get(s)+'" />'),a=e.Node.create('<div class="confirmation-dialogue"></div>').append(e.Node.create('<div class="confirmation-message">'+this.get(u)+"</div>")).append(e.Node.create('<div class="confirmation-buttons"></div>').append(t).append(n));this.get(r).addClass("moodle-dialogue-confirm"),this.setStdModContent(e.WidgetStdMod.BODY,a,e.WidgetStdMod.REPLACE),this.setStdModContent(e.WidgetStdMod.HEADER,'<h1 id="moodle-dialogue-'+this.get("COUNT")+'-header-text">'+this.get(o)+"</h1>",e.WidgetStdMod.REPLACE),this._closeEvents.push(e.on("key",this.submit,window,"down:27",this,!1),t.on("click",this.submit,this,!0),n.on("click",this.submit,this,!1));var f=this.get("boundingBox").one(".closebutton");f&&this._closeEvents.push(f.on("click",this.submit,this))},submit:function(t,n){(new e.EventHandle(this._closeEvents)).detach(),this.fire("complete",n),n?this.fire("complete-yes"):this.fire("complete-no"),this.hide(),this.destroy()}},{NAME:f,CSS_PREFIX:n,ATTRS:{yesLabel:{validator:e.Lang.isString,value:M.util.get_string("yes","moodle")},noLabel:{validator:e.Lang.isString,value:M.util.get_string("no","moodle")},title:{validator:e.Lang.isString,value:M.util.get_string("confirm","moodle")},question:{validator:e.Lang.isString,value:M.util.get_string("areyousure","moodle")}}}),e.augment(l,e.EventTarget),M.core.confirm=l},"@VERSION@",{requires:["moodle-core-notification-dialogue"]});

View File

@ -113,7 +113,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
yesLabel: {
validator: Y.Lang.isString,
value: 'Yes'
value: M.util.get_string('yes', 'moodle')
},
/**
@ -125,7 +125,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
noLabel: {
validator: Y.Lang.isString,
value: 'No'
value: M.util.get_string('no', 'moodle')
},
/**
@ -137,7 +137,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
title: {
validator: Y.Lang.isString,
value: 'Confirm'
value: M.util.get_string('confirm', 'moodle')
},
/**
@ -149,7 +149,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
question: {
validator: Y.Lang.isString,
value: 'Are you sure?'
value: M.util.get_string('areyousure', 'moodle')
}
}
});

View File

@ -449,7 +449,7 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
closeButtonTitle : {
validator : Y.Lang.isString,
value : 'Close'
value: M.util.get_string('closebuttontitle', 'moodle')
},
/**

File diff suppressed because one or more lines are too long

View File

@ -447,7 +447,7 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
closeButtonTitle : {
validator : Y.Lang.isString,
value : 'Close'
value: M.util.get_string('closebuttontitle', 'moodle')
},
/**

View File

@ -73,7 +73,7 @@ Y.extend(AJAXEXCEPTION, M.core.notification.info, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**

View File

@ -84,7 +84,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
yesLabel: {
validator: Y.Lang.isString,
value: 'Yes'
value: M.util.get_string('yes', 'moodle')
},
/**
@ -96,7 +96,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
noLabel: {
validator: Y.Lang.isString,
value: 'No'
value: M.util.get_string('no', 'moodle')
},
/**
@ -108,7 +108,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
title: {
validator: Y.Lang.isString,
value: 'Confirm'
value: M.util.get_string('confirm', 'moodle')
},
/**
@ -120,7 +120,7 @@ Y.extend(CONFIRM, M.core.notification.info, {
*/
question: {
validator: Y.Lang.isString,
value: 'Are you sure?'
value: M.util.get_string('areyousure', 'moodle')
}
}
});

View File

@ -420,7 +420,7 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
closeButtonTitle : {
validator : Y.Lang.isString,
value : 'Close'
value: M.util.get_string('closebuttontitle', 'moodle')
},
/**