Created
August 13, 2012 18:41
-
-
Save davglass/3343075 to your computer and use it in GitHub Desktop.
NodeJS Lang Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules/ <-- npm i yui | |
mod/ | |
moduleA/ | |
moduleA.js | |
lang/ | |
moduleA_en.js | |
test.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./test.js | |
ModuleA Strings: { foo: 'FOO', bar: 'BAR' } | |
callback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var YUI = require('yui').YUI, | |
path = require('path'); | |
YUI({ | |
lang: [ 'en' ], | |
groups: { | |
intl: { | |
base: path.join(__dirname, 'mod/'), | |
modules: { | |
moduleA: { | |
path: 'moduleA/moduleA.js', | |
lang: [ 'en' ], | |
requires: ['intl'] | |
} | |
} | |
} | |
} | |
}).use('moduleA', function(Y) { | |
console.log('callback'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('moduleA', function(Y) { | |
var strings = Y.Intl.get('moduleA'); | |
console.log('ModuleA Strings: ', strings); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('lang/moduleA_en', function(Y) { | |
Y.Intl.add("moduleA", "en", { | |
foo: 'FOO', | |
bar: 'BAR' | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment