Skip to content

Commit

Permalink
fix google picker i18n
Browse files Browse the repository at this point in the history
fixes #5542
fixes #5620
  • Loading branch information
mifi committed Jan 31, 2025
1 parent 3aa8d68 commit 250131b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export class Uppy<

store: NonNullableUppyOptions<M, B>['store']

// Warning: do not use this from a plugin, as it will cause the plugins' translations to be missing
i18n!: I18n

i18nArray!: Translator['translateArray']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default class GoogleDrivePicker<M extends Meta, B extends Body>
storage={this.storage}
pickerType="drive"
uppy={this.uppy}
i18n={this.i18n}
clientId={this.opts.clientId}
apiKey={this.opts.apiKey}
appId={this.opts.appId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useCallback, useEffect, useRef, useState } from 'preact/hooks'

import type { Uppy, AsyncStore } from '@uppy/core'

import type { I18n } from '@uppy/utils/lib/Translator'

import {
authorize,
ensureScriptsInjected,
Expand Down Expand Up @@ -44,6 +46,7 @@ function useStore(

export type GooglePickerViewProps = {
uppy: Uppy<any, any>
i18n: I18n
clientId: string
onFilesPicked: (files: PickedItem[], accessToken: string) => void
storage: AsyncStore
Expand All @@ -62,6 +65,7 @@ export type GooglePickerViewProps = {

export default function GooglePickerView({
uppy,
i18n,
clientId,
onFilesPicked,
pickerType,
Expand Down Expand Up @@ -212,20 +216,20 @@ export default function GooglePickerView({
}, [accessToken, setAccessToken])

if (loading) {
return <div>{uppy.i18n('pleaseWait')}...</div>
return <div>{i18n('pleaseWait')}...</div>
}

if (accessToken == null) {
return (
<AuthView
pluginName={
pickerType === 'drive' ?
uppy.i18n('pluginNameGoogleDrivePicker')
: uppy.i18n('pluginNameGooglePhotosPicker')
i18n('pluginNameGoogleDrivePicker')
: i18n('pluginNameGooglePhotosPicker')
}
pluginIcon={pickerType === 'drive' ? GoogleDriveIcon : GooglePhotosIcon}
handleAuth={showPicker}
i18n={uppy.i18n}
i18n={i18n}
loading={loading}
/>
)
Expand All @@ -240,17 +244,15 @@ export default function GooglePickerView({
disabled={loading}
onClick={() => showPicker()}
>
{pickerType === 'drive' ?
uppy.i18n('pickFiles')
: uppy.i18n('pickPhotos')}
{pickerType === 'drive' ? i18n('pickFiles') : i18n('pickPhotos')}
</button>
<button
type="button"
className="uppy-u-reset uppy-c-btn"
disabled={loading}
onClick={handleLogoutClick}
>
{uppy.i18n('logOut')}
{i18n('logOut')}
</button>
</div>
)
Expand Down

0 comments on commit 250131b

Please sign in to comment.