unclecheese/silverstripe-dropzone

Translatiosn

Opened this issue · 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?

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.

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"