MDL-45635 javascript: Make core dialogue translatable

This commit is contained in:
Andrew Nicols
2014-05-23 16:19:15 +08:00
parent b8604eb33b
commit 6c66c20107
14 changed files with 57 additions and 45 deletions
+3
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}';
@@ -1827,6 +1829,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';
+9
View File
@@ -1481,6 +1481,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) {
@@ -102,7 +102,7 @@ Y.extend(AJAXEXCEPTION, M.core.dialogue, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**
@@ -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.dialogue,{_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.dialogue,{_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"]});
@@ -102,7 +102,7 @@ Y.extend(AJAXEXCEPTION, M.core.dialogue, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**
@@ -104,9 +104,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Yes'
*/
yesLabel : {
validator : Y.Lang.isString,
value : 'Yes'
yesLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('yes', 'moodle')
},
/**
@@ -116,9 +116,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'No'
*/
noLabel : {
validator : Y.Lang.isString,
value : 'No'
noLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('no', 'moodle')
},
/**
@@ -128,9 +128,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Confirm'
*/
title : {
validator : Y.Lang.isString,
value : 'Confirm'
title: {
validator: Y.Lang.isString,
value: M.util.get_string('confirm', 'moodle')
},
/**
@@ -140,9 +140,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Are you sure?'
*/
question : {
validator : Y.Lang.isString,
value : 'Are you sure?'
question: {
validator: Y.Lang.isString,
value: M.util.get_string('areyousure', 'moodle')
}
}
});
@@ -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.dialogue,{closeEvents:[],initializer:function(){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.after("destroyedChange",function(){this.get(r).remove()},this),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.dialogue,{closeEvents:[],initializer:function(){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.after("destroyedChange",function(){this.get(r).remove()},this),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"]});
@@ -104,9 +104,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Yes'
*/
yesLabel : {
validator : Y.Lang.isString,
value : 'Yes'
yesLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('yes', 'moodle')
},
/**
@@ -116,9 +116,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'No'
*/
noLabel : {
validator : Y.Lang.isString,
value : 'No'
noLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('no', 'moodle')
},
/**
@@ -128,9 +128,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Confirm'
*/
title : {
validator : Y.Lang.isString,
value : 'Confirm'
title: {
validator: Y.Lang.isString,
value: M.util.get_string('confirm', 'moodle')
},
/**
@@ -140,9 +140,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Are you sure?'
*/
question : {
validator : Y.Lang.isString,
value : 'Are you sure?'
question: {
validator: Y.Lang.isString,
value: M.util.get_string('areyousure', 'moodle')
}
}
});
@@ -450,7 +450,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
@@ -450,7 +450,7 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
closeButtonTitle : {
validator : Y.Lang.isString,
value : 'Close'
value: M.util.get_string('closebuttontitle', 'moodle')
},
/**
+1 -1
View File
@@ -73,7 +73,7 @@ Y.extend(AJAXEXCEPTION, M.core.dialogue, {
*/
error : {
validator : Y.Lang.isString,
value : 'Unknown error'
value: M.util.get_string('unknownerror', 'moodle')
},
/**
+12 -12
View File
@@ -75,9 +75,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Yes'
*/
yesLabel : {
validator : Y.Lang.isString,
value : 'Yes'
yesLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('yes', 'moodle')
},
/**
@@ -87,9 +87,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'No'
*/
noLabel : {
validator : Y.Lang.isString,
value : 'No'
noLabel: {
validator: Y.Lang.isString,
value: M.util.get_string('no', 'moodle')
},
/**
@@ -99,9 +99,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Confirm'
*/
title : {
validator : Y.Lang.isString,
value : 'Confirm'
title: {
validator: Y.Lang.isString,
value: M.util.get_string('confirm', 'moodle')
},
/**
@@ -111,9 +111,9 @@ Y.extend(CONFIRM, M.core.dialogue, {
* @type String
* @default 'Are you sure?'
*/
question : {
validator : Y.Lang.isString,
value : 'Are you sure?'
question: {
validator: Y.Lang.isString,
value: M.util.get_string('areyousure', 'moodle')
}
}
});
+1 -1
View File
@@ -421,7 +421,7 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
closeButtonTitle : {
validator : Y.Lang.isString,
value : 'Close'
value: M.util.get_string('closebuttontitle', 'moodle')
},
/**