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

fix google picker i18n #5632

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -101,6 +101,7 @@ export default class GooglePhotosPicker<M extends Meta, B extends Body>
storage={this.storage}
pickerType="photos"
uppy={this.uppy}
i18n={this.i18n}
clientId={this.opts.clientId}
onFilesPicked={this.handleFilesPicked}
/>
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
Loading