Skip to content

Commit

Permalink
feat: add translations for maximum file size label
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarth2824 committed Dec 10, 2024
1 parent 04eead2 commit 80ca91c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/components/Field/Attachment/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import omit from 'lodash/omit'
import simplur from 'simplur'

import { MB } from '~shared/constants/file'
import { Language } from '~shared/types'

import { ATTACHMENT_THEME_KEY } from '~theme/components/Field/Attachment'
import { ThemeColorScheme } from '~theme/foundations/colours'
Expand All @@ -22,6 +23,7 @@ import { downloadFile } from './utils/downloadFile'
import { AttachmentStylesProvider } from './AttachmentContext'
import { AttachmentDropzone } from './AttachmentDropzone'
import { AttachmentFileInfo } from './AttachmentFileInfo'
import { MAXIMUM_FILE_LABEL_TRANSLATIONS } from './constants'
import {
getFileExtension,
getInvalidFileExtensionsInZip,
Expand Down Expand Up @@ -99,6 +101,11 @@ export interface AttachmentProps extends UseFormControlProps<HTMLElement> {
* Override callback function that is invoked when remove button is clicked.
*/
handleRemoveFileOverride?: () => void

/**
* Selected language used for default labels
*/
selectedLanguage?: Language
}

export const Attachment = forwardRef<AttachmentProps, 'div'>(
Expand All @@ -119,6 +126,7 @@ export const Attachment = forwardRef<AttachmentProps, 'div'>(
isRemoveDisabled,
handleDownloadFileOverride,
handleRemoveFileOverride,
selectedLanguage = Language.ENGLISH,
...props
},
ref,
Expand Down Expand Up @@ -320,7 +328,8 @@ export const Attachment = forwardRef<AttachmentProps, 'div'>(
textStyle="body-2"
aria-hidden
>
Maximum file size: {readableMaxSize}
{MAXIMUM_FILE_LABEL_TRANSLATIONS[selectedLanguage]}{' '}
{readableMaxSize}
</Text>
) : null}
</Box>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/Field/Attachment/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Language } from '~shared/types'

export const MAXIMUM_FILE_LABEL_TRANSLATIONS: Record<Language, string> = {
[Language.ENGLISH]: 'Maximum file size:',
[Language.CHINESE]: '文件限制:不超过',
[Language.MALAY]: 'Saiz fail maksimum:',
[Language.TAMIL]: 'கோப்பின் அதிகபட்ச அளவு:',
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const AttachmentField = ({
title={`${schema.questionNumber}. ${schema.title}`}
showDownload={showDownload}
showRemove={!schema.disabled}
selectedLanguage={selectedLanguage}
/>
)}
name={fieldName}
Expand Down

0 comments on commit 80ca91c

Please sign in to comment.