Skip to content

Commit

Permalink
#7 new helper construct.log, to output messages in the console
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Aug 4, 2013
1 parent bcedde0 commit 1e4f039
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/construct-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 25 additions & 5 deletions build/construct.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ Object.extend = function(destination, source) {

var locale = {
"en-US": {
"errors": {
"No_Backbone": "Backbone is not available: http://backbonejs.org/",
"No_jQuery": "jQuery is not available: http://jquery.com/",
"No_jQueryThree": "jQuery Three is required: https://github.com/makesites/jquery-three",
"No_BackboneApp": "This function requires Backbone APP: https://github.com/makesites/backbone-app"
"error": {
"no-backbone": "Backbone is not available: http://backbonejs.org/",
"no-jquery": "jQuery is not available: http://jquery.com/",
"no-jquery-three": "jQuery Three is required: https://github.com/makesites/jquery-three",
"no-backbone-app": "This function requires Backbone APP: https://github.com/makesites/backbone-app"
}
}
};
Expand Down Expand Up @@ -144,6 +144,26 @@ construct.update = function( fn ){

};

// output status messages
// inspired by the l10n handlebars helper: https://gist.github.com/tracend/3261055
construct.log = function( type, key ){
//prerequisites
if(!type || !key) return;
// find language
// make this a config option? (to avoid repeat lookups)
var lang = (navigator.language) ? navigator.language : navigator.userLanguage;

// pick the right dictionary - rever to the passed type/key
var string = locale[lang][type][key] || locale['en-US'][type][key] || type +": "+ key;

// check if console.log exists first?

//output
console.log(string);

};


construct.promise = new Promise();


Expand Down
20 changes: 20 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,24 @@ construct.update = function( fn ){

};

// output status messages
// inspired by the l10n handlebars helper: https://gist.github.com/tracend/3261055
construct.log = function( type, key ){
//prerequisites
if(!type || !key) return;
// find language
// make this a config option? (to avoid repeat lookups)
var lang = (navigator.language) ? navigator.language : navigator.userLanguage;

// pick the right dictionary - rever to the passed type/key
var string = locale[lang][type][key] || locale['en-US'][type][key] || type +": "+ key;

// check if console.log exists first?

//output
console.log(string);

};


construct.promise = new Promise();

0 comments on commit 1e4f039

Please sign in to comment.