silverstripe-dropzone icon indicating copy to clipboard operation
silverstripe-dropzone copied to clipboard

Translatiosn

Open sanderha opened this issue 8 years ago • 3 comments

I might be missing something but I was wondering how I can translate strings defined in JS? For example I need to translate the "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB." string. Is there any way to do this?

sanderha avatar Sep 05 '16 11:09 sanderha

You're right. This isn't supported, and it should have been by now. :)

Keen to submit a PR? All we have to do is chuck some params into the dropzone config in getConfigJSON()

$data['dictInvalidFileType'] = _t('Dropzone.INVALID_FILE_TYPE','Invalid file type');
// etc...

Ensure that the fallback translations come straight from the JS file, so that nothing changes for English users.

unclecheese avatar Sep 05 '16 23:09 unclecheese

Reference:

https://github.com/unclecheese/silverstripe-dropzone/blob/master/javascript/dropzone.js#L312

unclecheese avatar Sep 05 '16 23:09 unclecheese

For anyone trying to figure this out: it's already possible to add your custom translations (which are set in defaultOptions).

Just add them to your config.yml file, e.g.: FileAttachmentField: defaults: dictDefaultMessage: "My custom translation goes here"

t-silvius avatar Sep 21 '18 13:09 t-silvius