Skip to content
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
44 changes: 36 additions & 8 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@sentry/react": "^10.31.0",
"@sentry/vite-plugin": "^4.6.1",
"@stomp/stompjs": "^6.1.2",
"@tginternal/editor": "1.18.0",
"@tginternal/editor": "1.19.0",
"@tginternal/library": "file:../library",
"@tolgee/format-icu": "^7.1.1",
"@tolgee/react": "^7.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { TranslationEditor } from '../TranslationEditor';
import { MissingPlaceholders } from '../cell/MissingPlaceholders';

import { useMissingPlaceholders } from '../cell/useMissingPlaceholders';
import { useInvalidPlaceholders } from '../cell/useInvalidPlaceholders';
import { TranslationVisual } from '../translationVisual/TranslationVisual';
import { ControlsEditorReadOnly } from '../cell/ControlsEditorReadOnly';
import { useBaseTranslation } from '../useBaseTranslation';
Expand Down Expand Up @@ -131,6 +132,12 @@ export const TranslationWrite: React.FC<React.PropsWithChildren<Props>> = ({
enabled: baseLanguage !== language.tag,
});

const invalidPlaceholders = useInvalidPlaceholders({
currentTranslation: value,
nested,
enabled: editEnabled,
});

const handleModeToggle = () => {
setMode((mode) => (mode === 'syntax' ? 'placeholders' : 'syntax'));
};
Expand Down Expand Up @@ -221,6 +228,7 @@ export const TranslationWrite: React.FC<React.PropsWithChildren<Props>> = ({
</Tooltip>
<MissingPlaceholders
placeholders={missingPlaceholders}
invalidPlaceholders={invalidPlaceholders}
onPlaceholderClick={handlePlaceholderClick}
variant={editVal.value.parameter ? activeVariant : undefined}
locale={language.tag}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useTranslationCell } from '../useTranslationCell';
import { TranslationEditor } from '../TranslationEditor';
import { MissingPlaceholders } from '../cell/MissingPlaceholders';
import { useMissingPlaceholders } from '../cell/useMissingPlaceholders';
import { useInvalidPlaceholders } from '../cell/useInvalidPlaceholders';
import { TranslationVisual } from '../translationVisual/TranslationVisual';
import { ControlsEditorReadOnly } from '../cell/ControlsEditorReadOnly';
import { useBaseTranslation } from '../useBaseTranslation';
Expand Down Expand Up @@ -100,6 +101,12 @@ export const TranslationWrite: React.FC<React.PropsWithChildren<Props>> = ({
enabled: baseLanguage !== language.tag,
});

const invalidPlaceholders = useInvalidPlaceholders({
currentTranslation: value,
nested,
enabled: editEnabled,
});

const translationTasks = keyData.tasks?.filter(
(t) => t.languageTag === language.tag
);
Expand Down Expand Up @@ -158,9 +165,12 @@ export const TranslationWrite: React.FC<React.PropsWithChildren<Props>> = ({
/>
)}
<StyledPlaceholdersAndControls>
{Boolean(missingPlaceholders.length) && (
{Boolean(
missingPlaceholders.length || invalidPlaceholders.length
) && (
<MissingPlaceholders
placeholders={missingPlaceholders}
invalidPlaceholders={invalidPlaceholders}
onPlaceholderClick={handlePlaceholderClick}
variant={editVal.value.parameter ? activeVariant : undefined}
locale={language.tag}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { styled, useTheme } from '@mui/material';
import {
InvalidPlaceholder,
Placeholder,
generatePlaceholdersStyle,
getVariantExample,
Expand All @@ -17,8 +18,17 @@ const StyledLabel = styled('span')`
bottom: 1px;
`;

const StyledInvalid = styled('span')`
margin-right: 8px;
font-size: 14px;
position: relative;
bottom: 1px;
color: ${({ theme }) => theme.palette.error.main};
`;

type Props = {
placeholders: Placeholder[];
invalidPlaceholders: InvalidPlaceholder[];
onPlaceholderClick: (placeholder: Placeholder) => void;
locale: string;
variant: string | undefined;
Expand All @@ -27,6 +37,7 @@ type Props = {

export const MissingPlaceholders = ({
placeholders,
invalidPlaceholders,
onPlaceholderClick,
locale,
variant,
Expand All @@ -50,6 +61,17 @@ export const MissingPlaceholders = ({
className={className}
onMouseDown={(e) => e.preventDefault()}
>
{Boolean(invalidPlaceholders.length) && (
<StyledInvalid>
<T
keyName="translations_invalid_icu_placeholders"
defaultValue="Invalid ICU: {value}"
params={{
value: invalidPlaceholders.map((p) => p.value).join(', '),
}}
/>
</StyledInvalid>
)}
{Boolean(placeholders.length) && (
<>
<StyledLabel>
Expand Down
Loading
Loading