UNPKG

curl-amd

Version:

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.

67 lines (54 loc) 1.48 kB
<!DOCTYPE HTML> <html> <head> <title>i18n tests</title> <script> curl = { baseUrl: '.', paths: { curl: '../src/curl' }, //locale: true, //'en-gb', preloads: [ 'curl/tdd/undefine' ] }; </script> <script src="../src/curl.js" type="text/javascript"></script> <script type="text/javascript"> test1(); function test1 () { curl(['i18n!i18n/strings', 'curl/tdd/undefine']).then( function (strings, undefine) { var val1 = !!strings, val2 = strings.labels.beer == 'brew'; write((val1 ? 'SUCCESS' : 'FAILED') + ': i18n string bundle should be loaded.'); write((val2 ? 'SUCCESS' : 'FAILED') + ': i18n string should have correct value.'); undefine(['curl/plugin/i18n!i18n/strings', 'i18n/strings']); }, function (ex) { write('FAILED: to load i18n!i18n/strings ' + ex.message); } ).then(test2); } function test2 () { curl({ locale: 'en-gb' }, ['i18n!i18n/strings']).then( function (strings) { var val1 = !!strings, val2 = strings.labels.beer == 'pint'; write((val1 ? 'SUCCESS' : 'FAILED') + ': i18n string bundle (en-gb) should be loaded.'); write((val2 ? 'SUCCESS' : 'FAILED') + ': i18n string should have correct value (en-gb).'); }, function (ex) { write('FAILED: to load i18n!i18n/strings (en-gb) ' + ex.message); } ); } function write (msg) { curl('domReady!', function () { document.body.appendChild(document.createElement('div')).innerHTML = msg; }); } </script> </head> <body> </body> </html>