Closed paskuale75 closed 3 years ago
I'm not fully sure, but it might be worth attempting to also pass the locale
property to the options of DragDrop
Other than, do other uploading methods (ex. Dashboard) work with the locale?
In dragDrop options not. The very strange thing is that if I do a test in a new application by simply loading the two scripts from the CDN (see below) the translation works!
<script src="https://transloadit.edgly.net/releases/uppy/v1.21.1/uppy.min.js"></script>
<script src="https://transloadit.edgly.net/releases/uppy/locales/v1.16.7/it_IT.min.js"></script>
How is Uppy being loaded here? I'm not familiar with how Yii works.
I do have one uneducated guess...The locale files must either be loaded as a CommonJS module (usually with a bundler like browserify or webpack), or be loaded with a script tag, where they will attach to a global Uppy object. I think there is one case where this may go wrong: if the main Uppy bundle (uppy.min.js
) detects an AMD environment, it registers itself as an AMD module, and the global Uppy variable is not available. Then the locale scripts cannot find the global Uppy variable, so they assume they must be in a CommonJS module. If Yii comes with require.js, then that might be what's going on.
Yii2 uses the composer for both 'bower-assets' and 'npm-assets' and related classes called Asset that deal with css and js code compression, I don't know what the missing step is.
Hmm OK. The file in lib/
is a CommonJS module, so you can't include it directly with a script tag. In the uppy
package, dist/uppy.min.js
is the same file as the one from the CDN. In the @uppy/locales
package, dist/it_IT.min.js
is the same file as the one from the CDN. So those are the files to use, but I assume you were actually doing so already.
The uppy.min.js
file must be loaded before any locale files, or the locale will not be able to register itself. Could this be an ordering issue?
(e; going to add Yii to the issue title so I can better remember what this was about!)
Ok, I'll try to put on "head" the js call, thank you very much
Here my js code:
file "it_IT.min.js" it's loaded correctly (from /dist folder), but in dragDrop target I read the phrase "Drop file here" (english lang). If if I change the folder from which to load the language file and use the 'lib' folder instead of the 'dist' it returns this:
Uncaught ReferenceError: module is not defined
(at line _module.exports = itIT;) why ?