CDN & Locales Example
Here you’ll see a demo of how you might use internationalization (i18n) in SME Uploader, as well as how to load SME Uploader using a pre-bundled version (CDN).
Uploaded files:
Console output:
To load the pre-built bundle (from a CDN) we’re using the following HTML and JavaScript:
<!-- Load SME Uploader CSS bundle. It is advisable to install SME Uploader from npm/yarn instead, and pick and choose the plugins/styles you need. But for experimenting, you can use CDN: --> <link href="https://unpkg.com/sme-uploader@1.0.6/dist/sme-uploader.min.css" rel="stylesheet"> <div class="checkbox"> <label for="localeList" class="switch"> <input type="checkbox" id="localeList" disabled checked/> <i> </i> <span>Changing locale: [ru_RU]</span> </label> </div> <div class="SmeUploaderDragDrop"></div> <div class="for-ProgressBar"></div> <div class="uploaded-files"> <h5>Uploaded files:</h5> <ol></ol> </div> <!-- Load SME Uploader JS bundle. --> <script src="https://unpkg.com/sme-uploader@1.0.6/dist/sme-uploader.min.js"></script> <script src="https://unpkg.com/sme-uploader@1.0.6/locales/ru_RU.min.js"></script> <script> const uploader = SmeUploader.Core({ debug: true, autoProceed: true, locale: SmeUploader.locales.ru_RU }); uploader.use(SmeUploader.DragDrop, { target: '.SmeUploaderDragDrop', // We are using the ru_RU locale pack (set above in SME Uploader.Core options), // but you can also override specific strings like so: locale: { strings: { browse: 'выберите 😃' } } }); uploader.use(SmeUploader.ProgressBar, { target: '.for-ProgressBar', hideAfterFinish: false }); uploader.use(SmeUploader.Tus, { endpoint: 'https://master.tus.io/files/' }); uploader.on('upload-success', function (file, response) { const url = response.uploadURL; const fileName = file.name; document.querySelector('.uploaded-files ol').innerHTML += '<li><a href="' + url + '" target="_blank">' + fileName + '</a></li>'; }); console.log('--> SME Uploader pre-built version with Tus, DragDrop & Russian language pack has loaded'); </script> |
Please see documentation for details.
Caught a mistake or want to contribute to the documentation?
Edit/fork this page directly on Github