Skip to content

Commit

Permalink
fixup! feat(i18n): convert file, image and imagetool input strings to…
Browse files Browse the repository at this point in the history
… use i18n primitives
  • Loading branch information
bjoerge committed Oct 11, 2023
1 parent e1504f9 commit 634c214
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
21 changes: 14 additions & 7 deletions dev/test-studio/plugins/locale-no-nb/bundles/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const studioResources: Record<StudioLocaleResourceKeys, string> = {
/** --- File (Image, File and ImageTool) Inputs --- */

/** Open image edit dialog */
'inputs.files.image.actions-menu.edit-details.label': 'Åpne bilde redigeringsdialog',
'inputs.files.image.actions-menu.edit-details.label': 'Åpne bilderedigeringsdialog',

/** Open image options menu */
'inputs.files.image.actions-menu.options.label': 'Åpne bildeinnstillingsmeny',
Expand Down Expand Up @@ -325,14 +325,21 @@ const studioResources: Record<StudioLocaleResourceKeys, string> = {
/** Read only */
'inputs.files.common.placeholder.read-only': 'Skrivebeskyttet',

/** Drop to upload `{{type}}` */
'inputs.files.common.placeholder.drop-to-upload': 'Slipp for å laste opp {{type}}',
/** Drop to upload file */
'inputs.files.common.placeholder.drop-to-upload_file': 'Slipp for å laste opp fil',

/** Cannot upload `{{count}}` files */
'inputs.files.common.placeholder.cannot-upload-some-files': 'Kan ikke laste opp {{count}} filer',
/** Drop to upload image */
'inputs.files.common.placeholder.drop-to-upload_image': 'Slipp for å laste opp bilde',

/** Drag or paste `{{type}}` here */
'inputs.files.common.placeholder.drag-or-paste-to-upload': 'Dra eller lim inn {{type}} her',
/** Cannot upload `{{count}}` files */
'inputs.files.common.placeholder.cannot-upload-some-files_one': 'Kan ikke laste opp fil',
'inputs.files.common.placeholder.cannot-upload-some-files_other':
'Kan ikke laste opp {{count}} filer',

/** Drag or paste file here */
'inputs.files.common.placeholder.drag-or-paste-to-upload_file': 'Dra eller lim inn fil her',
/** Drag or paste image here */
'inputs.files.common.placeholder.drag-or-paste-to-upload_image': 'Dra eller lim inn bilde her',

/** Drop to upload */
'inputs.files.common.drop-message.drop-to-upload': 'Slipp for å laste opp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface BaseImageInputProps
observeAsset: (documentId: string) => Observable<ImageAsset>
resolveUploader: UploaderResolver
client: SanityClient
t: TFunction
t: (key: string, values?: Record<string, string>) => string
}

const getDevicePixelRatio = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function PlaceholderText(props: Props) {

if (hoveringFiles && directUploads && !readOnly) {
if (acceptedFiles.length > 0) {
return t('inputs.files.common.placeholder.drop-to-upload', {type})
return t('inputs.files.common.placeholder.drop-to-upload', {context: type})
}
if (rejectedFilesCount > 0) {
return t('inputs.files.common.placeholder.cannot-upload-some-files', {
Expand All @@ -56,7 +56,7 @@ export function PlaceholderText(props: Props) {
}
}

return t('inputs.files.common.placeholder.drag-or-paste-to-upload')
return t('inputs.files.common.placeholder.drag-or-paste-to-upload', {context: type})
}, [acceptedFiles.length, directUploads, hoveringFiles, readOnly, rejectedFilesCount, t, type])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export function UploadProgress({uploadState, onCancel, onStale, height}: Props)
t={t}
i18nKey="input.files.common.upload-progress"
components={{
FileName: () => (
<CodeWrapper size={1}>{filename ? filename : '...'}</CodeWrapper>
),
FileName: () => <CodeWrapper size={1}>{filename ? filename : '…'}</CodeWrapper>,
}}
/>
</Inline>
Expand Down
17 changes: 12 additions & 5 deletions packages/sanity/src/core/i18n/bundles/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,21 @@ export const studioLocaleStrings = {
/** Read only */
'inputs.files.common.placeholder.read-only': 'Read only',

/** Drop to upload `{{type}}` */
'inputs.files.common.placeholder.drop-to-upload': 'Drop to upload {{type}}',
/** Drop to upload image */
'inputs.files.common.placeholder.drop-to-upload_image': 'Drop to upload image',

/** Drop to upload file */
'inputs.files.common.placeholder.drop-to-upload_file': 'Drop to upload file',

/** Cannot upload `{{count}}` files */
'inputs.files.common.placeholder.cannot-upload-some-files': 'Cannot upload {{count}} files',
'inputs.files.common.placeholder.cannot-upload-some-files_one': 'Cannot upload file',
'inputs.files.common.placeholder.cannot-upload-some-files_other': 'Cannot upload {{count}} files',

/** Drag or paste type here */
'inputs.files.common.placeholder.drag-or-paste-to-upload_file': 'Drag or paste file here',

/** Drag or paste `{{type}}` here */
'inputs.files.common.placeholder.drag-or-paste-to-upload': 'Drag or paste {{type}} here',
/** Drag or paste image here */
'inputs.files.common.placeholder.drag-or-paste-to-upload_image': 'Drag or paste image here',

/** Drop to upload */
'inputs.files.common.drop-message.drop-to-upload': 'Drop to upload',
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/test/form/renderImageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export async function renderImageInput(options: {
...restProps,
assetSources,
client,
t: (key: string, values?: Record<string, string>) => key,
imageUrlBuilder,
observeAsset,
resolveUploader,
Expand Down

0 comments on commit 634c214

Please sign in to comment.