Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using uppy.setOptions({locale}) won't update locale strings in Restricter instance #5115

Closed
2 tasks done
ZaDarkSide opened this issue Apr 25, 2024 · 0 comments · Fixed by #5118
Closed
2 tasks done
Labels

Comments

@ZaDarkSide
Copy link

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

Runnable example cannot be provided codesandbox.io starter example is broken https://codesandbox.io/s/uppy-dashboard-xpxuhd?file=/src/index.js

Steps to reproduce

Consider this code

import Uppy from '@uppy/core'
import French from '@uppy/locales/lib/fr_FR.js'

const uppy = new Uppy()
uppy.setOptions({ inline: true, locale: French, restrictions: { allowedFileTypes: ['image/*'] })

Then try to upload a file that is not an image, the error message from Informer that comes from Restricter should be in French not English.

Expected behavior

The error message from Informer should be in French not English.

Actual behavior

The error message from Informer is in English, even if setOptions() call set the locale correctly.

A possible solution

This code:

this.i18nInit()
if (newOpts.locale) {
this.iteratePlugins((plugin) => {
plugin.setOptions(newOpts)
})
}

To be changed to this:

 this.i18nInit()

 // Restricter sadly hasn't a setOptions() method, so it will be needed to be reinstanciated
 this.#restricter = new Restricter<M, B>(() => this.opts, this.i18n) 

 if (newOpts.locale) { 
   this.iteratePlugins((plugin) => { 
     plugin.setOptions(newOpts) 
   }) 
 } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant