Skip to content

Commit

Permalink
Merge pull request #226 from lorenzulrich/task/translations
Browse files Browse the repository at this point in the history
TASK: Add translations for labels, finish German translation
  • Loading branch information
Sebobo authored Jan 9, 2024
2 parents 9b6c48c + 92e3200 commit 6283e3d
Show file tree
Hide file tree
Showing 14 changed files with 869 additions and 46 deletions.
16 changes: 11 additions & 5 deletions Classes/GraphQL/Resolver/Type/MutationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Flowpack\Media\Ui\Exception;
use Flowpack\Media\Ui\GraphQL\Context\AssetSourceContext;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\I18n\Translator;
use Neos\Flow\Persistence\Exception\IllegalObjectTypeException;
use Neos\Flow\Persistence\Exception\InvalidQueryException;
use Neos\Flow\Persistence\PersistenceManagerInterface;
Expand All @@ -47,6 +48,10 @@
*/
class MutationResolver implements ResolverInterface
{
protected const STATE_ADDED = 'ADDED';
protected const STATE_EXISTS = 'EXISTS';
protected const STATE_ERROR = 'ERROR';

/**
* @Flow\Inject
* @var AssetRepository
Expand Down Expand Up @@ -364,7 +369,7 @@ public function uploadFile($_, array $variables): array
$assetCollectionId = $variables['assetCollectionId'] ?? null;

$success = false;
$result = 'ERROR';
$result = self::STATE_ERROR;

$filename = $file->getClientFilename();
try {
Expand All @@ -379,7 +384,7 @@ public function uploadFile($_, array $variables): array
$resource->setMediaType($file->getClientMediaType());

if ($this->assetRepository->findOneByResourceSha1($resource->getSha1())) {
$result = 'EXISTS';
$result = self::STATE_EXISTS;
} else {
try {
$className = $this->mappingStrategy->map($resource);
Expand All @@ -403,10 +408,10 @@ public function uploadFile($_, array $variables): array
}

$this->assetRepository->add($asset);
$result = 'ADDED';
$result = self::STATE_ADDED;
$success = true;
} else {
$result = 'EXISTS';
$result = self::STATE_EXISTS;
}
} catch (IllegalObjectTypeException $e) {
$this->systemLogger->error('Type of uploaded file cannot be stored');
Expand Down Expand Up @@ -479,7 +484,7 @@ public function replaceAsset($_, array $variables, AssetSourceContext $assetSour
}

$success = false;
$result = 'ERROR';
$result = self::STATE_ERROR;
$sourceMediaType = MediaTypes::parseMediaType($asset->getMediaType());
$replacementMediaType = MediaTypes::parseMediaType($file->getClientMediaType());
$filename = $file->getClientFilename();
Expand Down Expand Up @@ -806,4 +811,5 @@ public function deleteTag($_, array $variables): bool

return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const DeleteButton: React.FC = () => {
if (!canDeleteTag) return;
// TODO: Implement `obtainApprovalToDeleteCollection` for deleting
const confirm = window.confirm(
translate('action.deleteTag.confirm', 'Do you really want to delete the tag ' + selectedTag.label, [
translate('action.deleteTag.confirm', `Do you really want to delete the tag "${selectedTag.label}"?`, [
selectedTag.label,
])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const EditAssetDialog: React.FC = () => {
<span>{translate('uploadDialog.generateRedirects', 'Generate redirects')}</span>
</Label>
)}
{loading && <p>{translate('EditAssetDialog.updating', 'Updating…')}</p>}
{loading && <p>{translate('editAssetDialog.updating', 'Updating…')}</p>}
</section>
</Dialog>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const CreateTagDialog: React.FC = () => {
setDialogState((state) => ({ ...state, visible: false }));
createTag(dialogState.label, selectedAssetCollection?.id)
.then(() => {
Notify.ok(translate('assetCollectionActions.create.success', 'Tag was created'));
Notify.ok(translate('tagActions.create.success', 'Tag was created'));
})
.catch((error) => {
Notify.error(translate('assetCollectionActions.create.error', 'Failed to create tag'), error.message);
Notify.error(translate('tagActions.create.error', 'Failed to create tag'), error.message);
});
}, [Notify, setDialogState, createTag, dialogState, translate, selectedAssetCollection]);
const setLabel = useCallback((label) => setDialogState((state) => ({ ...state, label })), [setDialogState]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
.fileList {
margin-top: var(--theme-spacing-Full);
display: flex;
flex-direction: row;
flex-wrap: wrap;
}

.fileListHeader {
flex: 1 1 100%;
margin-bottom: var(--theme-spacing-Full);
font-size: var(--theme-fontSize-base);
}

.thumb {
display: inline-flex;
border-radius: 2px;
border: 1px solid #eaeaea;
margin-bottom: var(--theme-spacing-Half);
margin-right: var(--theme-spacing-Half);
width: 100px;
height: 100px;
padding: var(--theme-spacing-Quarter);
Expand All @@ -35,6 +20,7 @@
.thumbInner span {
margin-left: var(--theme-spacing-Half);
user-select: none;
word-break: break-all;
}

.img {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cx from 'classnames';
import { Icon } from '@neos-project/react-ui-components';

import classes from './FilePreview.module.css';
import { useIntl } from '@media-ui/core';

interface FilePreviewProps {
file: UploadedFile;
Expand All @@ -12,10 +13,10 @@ interface FilePreviewProps {
}

const FilePreview: React.FC<FilePreviewProps> = ({ file, loading = false, fileState }: FilePreviewProps) => {
const { translate } = useIntl();
const success = fileState?.success;
const error = fileState && !success;

// TODO: Output helpful localised messages for results 'EXISTS', 'ADDED', 'ERROR'
return (
<div
className={cx(
Expand All @@ -29,7 +30,9 @@ const FilePreview: React.FC<FilePreviewProps> = ({ file, loading = false, fileSt
{loading && <Icon icon="spinner" spin={true} />}
{success && <Icon icon="check" />}
{error && <Icon icon="exclamation-circle" />}
{fileState?.result && <span>{fileState.result}</span>}
{fileState?.result && (
<span>{translate(`uploadDialog.fileList.${fileState.result.toLowerCase()}`)}</span>
)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: var(--theme-spacing-Full);
}

.fileListHeader {
flex: 1 1 100%;
margin-bottom: var(--theme-spacing-Full);
font-size: var(--theme-fontSize-base);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const PreviewSection: React.FC<PreviewSectionProps> = ({ files, loading, uploadS
{files.rejected.length > 0 && (
<>
<h4 className={classes.fileListHeader}>
{translate('uploadDialog.fileList.uploadedHeader', 'Failed uploads')}
{translate('uploadDialog.fileList.failedUploadsHeader', 'Failed uploads')}
</h4>
{files.rejected.map((file) => (
<FilePreview
Expand All @@ -51,7 +51,7 @@ const PreviewSection: React.FC<PreviewSectionProps> = ({ files, loading, uploadS
{files.finished.length > 0 && (
<>
<h4 className={classes.fileListHeader}>
{translate('uploadDialog.fileList.uploadedHeader', 'Successful uploads')}
{translate('uploadDialog.fileList.successfulUploadsHeader', 'Successful uploads')}
</h4>
{files.finished.map((file) => (
<FilePreview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const VariantsInspector = () => {
return (
<div className={classes.variantsContainer}>
{result.loading ? (
<div>Loading Variants</div>
<div>{translate('assetVariants.loadingVariants', 'Loading Variants…')}</div>
) : (
<>
<h1>Image Variants</h1>
<h1>{translate('assetVariants.title', 'Image Variants')}</h1>
<ul>
{result.variants?.length > 0 ? (
result.variants?.map((variant) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const DefaultApprovalAttainmentStrategyFactory: ApprovalAttainmentStrateg
title: deps.intl.translate('actions.deleteAsset.confirm.title', 'Delete Asset', [asset.label]),
message: deps.intl.translate(
'action.deleteAsset.confirm.message',
`Do you really want to delete the asset "${asset.label}"`,
`Do you really want to delete the asset "${asset.label}"?`,
[asset.label]
),
buttonLabel: deps.intl.translate(
Expand All @@ -57,7 +57,7 @@ export const DefaultApprovalAttainmentStrategyFactory: ApprovalAttainmentStrateg
title: deps.intl.translate('actions.deleteAssets.confirm.title', 'Delete Assets', [assets.length]),
message: deps.intl.translate(
'action.deleteAssets.confirm.message',
`Do you really want to delete ${assets.length} assets`,
`Do you really want to delete ${assets.length} assets?`,
[assets.length]
),
buttonLabel: deps.intl.translate(
Expand All @@ -73,7 +73,7 @@ export const DefaultApprovalAttainmentStrategyFactory: ApprovalAttainmentStrateg
]),
message: deps.intl.translate(
'action.deleteAssetCollection.confirm.message',
`Do you really want to delete the collection "${assetCollection.title}"`,
`Do you really want to delete the collection "${assetCollection.title}"?`,
[assetCollection.title]
),
buttonLabel: deps.intl.translate(
Expand All @@ -87,7 +87,7 @@ export const DefaultApprovalAttainmentStrategyFactory: ApprovalAttainmentStrateg
title: deps.intl.translate('actions.deleteTag.confirm.title', 'Delete tag', [tag.label]),
message: deps.intl.translate(
'action.deleteTag.confirm.message',
`Do you really want to delete the tag "${tag.label}"`,
`Do you really want to delete the tag "${tag.label}"?`,
[tag.label]
),
buttonLabel: deps.intl.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ListView: React.FC<ListViewProps> = ({ assetIdentities }: ListViewProps) =
<th className={classes.tableHeader} />
<th className={classes.tableHeader}>{translate('thumbnailView.header.name', 'Name')}</th>
<th className={classes.tableHeader}>
{translate('thumbnailView.header.lastModified', 'Last Modified')}
{translate('thumbnailView.header.lastModified', 'Last modified')}
</th>
<th className={classes.tableHeader}>
{translate('thumbnailView.header.fileSize', 'File size')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const SimilarAssetsModal: React.FC = () => {
return (
<Dialog
isOpen={isOpen}
title={translate('similarAssetsModal.title', `Similar assets to ${asset.label}`, { asset: asset.label })}
title={translate('similarAssetsModal.title', `Similar assets to "${asset.label}"`, { asset: asset.label })}
onRequestClose={handleRequestClose}
style="wide"
actions={[
Expand All @@ -41,7 +41,7 @@ const SimilarAssetsModal: React.FC = () => {
) : (
<span>
{loading
? translate('similarAssetsModal.loading', 'Loading...')
? translate('similarAssetsModal.loading', 'Loading')
: translate('similarAssetsModal.noResults', 'No results')}
</span>
)}
Expand Down
Loading

0 comments on commit 6283e3d

Please sign in to comment.