Skip to content

Commit

Permalink
feat: add i18n strings
Browse files Browse the repository at this point in the history
  • Loading branch information
drewlyton committed Sep 26, 2024
1 parent cdb48af commit b1103ec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable i18next/no-literal-string */

import {Box, Card, Flex, Stack, Text, TextInput, useToast} from '@sanity/ui'
import {useEffect, useId, useMemo, useState} from 'react'
import {type Role, useClient, useProjectId, useTranslation} from 'sanity'
Expand Down Expand Up @@ -131,16 +129,16 @@ export function RequestPermissionDialog({
<Dialog
width={1}
id={dialogId}
header={'Ask to edit'}
header={t('request-permission-dialog.header.text')}
footer={{
cancelButton: {
onClick: onCancel,
text: t('confirm-delete-dialog.cancel-button.text'),
text: t('confirm-dialog.cancel-button.fallback-text'),
},
confirmButton: {
loading: isSubmitting,
disabled: hasTooManyRequests || hasBeenDenied,
text: 'Send request',
text: t('request-permission-dialog.confirm-button.text'),
tone: 'primary',
onClick: onConfirm,
},
Expand All @@ -150,30 +148,23 @@ export function RequestPermissionDialog({
>
<DialogBody>
<Stack space={4}>
<Text>
A request will be made to administrators asking to grant you increased permission to
this project.
</Text>
<Text>If you'd like, you can add a note</Text>
<Text>{t('request-permission-dialog.description.text')}</Text>
<Text>{t('request-permission-dialog.note-input.description.text')}</Text>
{hasTooManyRequests || hasBeenDenied ? (
<Card tone={'caution'} padding={3} radius={2} shadow={1}>
<Text size={1}>
{hasTooManyRequests && (
<>
{msgError ??
`You've reached the limit for role requests across all projects. Please wait
before submitting more requests or contact an admin for assistance.`}
</>
<>{msgError ?? t('request-permission-dialog.warning.limit-reached.text')}</>
)}
{hasBeenDenied && (
<>{msgError ?? `Your request to access this project has been declined.`}</>
<>{msgError ?? t('request-permission-dialog.warning.denied.text')}</>
)}
</Text>
</Card>
) : (
<Stack space={3} paddingBottom={0}>
<TextInput
placeholder="Add note..."
placeholder={t('request-permission-dialog.note-input.placeholder.text')}
disabled={isSubmitting}
onKeyDown={(e) => {
if (e.key === 'Enter') onConfirm()
Expand Down
18 changes: 18 additions & 0 deletions packages/sanity/src/structure/i18n/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,24 @@ const structureLocaleStrings = defineLocalesResources('structure', {
/** The text for the "Open preview" action for a document */
'production-preview.menu-item.title': 'Open preview',

/** The text for the confirm button in the request permission dialog used in the permissions banner */
'request-permission-dialog.confirm-button.text': 'Send request',
/** The description text for the request permission dialog used in the permissions banner */
'request-permission-dialog.description.text':
'A request will be made to administrators asking to grant you increased permission to this project.',
/** The header/title for the request permission dialog used in the permissions banner */
'request-permission-dialog.header.text': 'Ask to edit',
/** The text describing the note input for the request permission dialog used in the permissions banner */
'request-permission-dialog.note-input.description.text': "If you'd like, you can add a note",
/** The placeholder for the note input in the request permission dialog used in the permissions banner */
'request-permission-dialog.note-input.placeholder.text': 'Add note...',
/** The error/warning text in the request permission dialog when the user's request has been declined */
'request-permission-dialog.warning.denied.text':
'Your request to access this project has been declined.',
/** The error/warning text in the request permission dialog when the user's request has been denied due to too many outstanding requests */
'request-permission-dialog.warning.limit-reached.text':
"You've reached the limit for role requests across all projects. Please wait before submitting more requests or contact an admin for assistance.",

/** Label for button when status is saved */
'status-bar.document-status-pulse.status.saved.text': 'Saved',
/** Label for button when status is syncing */
Expand Down

0 comments on commit b1103ec

Please sign in to comment.