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

Set plugin titles from locale #3023

Merged
merged 19 commits into from
Jul 30, 2021
Merged

Set plugin titles from locale #3023

merged 19 commits into from
Jul 30, 2021

Conversation

arturi
Copy link
Contributor

@arturi arturi commented Jul 16, 2021

  • Trying to move i18nInit to the BasePlugin class, since around 70% of the plugins use locales, and right now we have this dance duplicated in each of them. Good idea?
i18nInit () {
  this.translator = new Translator([this.defaultLocale, this.uppy.locale, this.opts.locale])
  this.i18n = this.translator.translate.bind(this.translator)
  this.i18nArray = this.translator.translateArray.bind(this.translator)
  this.setPluginState() // so that UI re-renders and we see the updated locale
}
  • Using locale keys like pluginNameInstagram, pluginNameWebcam to group them in the locale file and distinguish from general keywords like Camera or Webcam vs pluginNameWebcam.

Closes #2279

Comment on lines 49 to 51
this.translator = new Translator([this.defaultLocale, this.uppy.locale, this.opts.locale])
this.i18n = this.translator.translate.bind(this.translator)
this.i18nArray = this.translator.translateArray.bind(this.translator)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move translator and i18nArray to private properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you mean the new # thing? I think so, shouldn’t be public.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18nArray should be accessible by subclasses so they can use it in preact code

@arturi arturi marked this pull request as ready for review July 29, 2021 14:50
@arturi arturi requested a review from aduh95 July 29, 2021 14:50
aduh95
aduh95 previously approved these changes Jul 29, 2021
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of those bind calls.

packages/@uppy/core/src/BasePlugin.js Outdated Show resolved Hide resolved
packages/@uppy/core/src/index.js Outdated Show resolved Hide resolved
@aduh95 aduh95 dismissed their stale review July 29, 2021 18:07

E2E tests are failing (packages/@uppy/locales/src/en_US.js issue again).

arturi and others added 3 commits July 30, 2021 11:14
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95
Copy link
Contributor

aduh95 commented Jul 30, 2021

Is this still necessary if Transloadit extends BasePlugin?

i18nInit () {
this.translator = new Translator([this.defaultLocale, this.uppy.locale, this.opts.locale])
this.i18n = this.translator.translate.bind(this.translator)
this.i18nArray = this.translator.translateArray.bind(this.translator)
this.setPluginState() // so that UI re-renders and we see the updated locale
}

@arturi arturi merged commit 4ca78ab into 2.0 Jul 30, 2021
@arturi arturi deleted the plugin-title-from-locale branch July 30, 2021 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants