From 9d68c317797123d982d627ac5b8444236cb06e27 Mon Sep 17 00:00:00 2001 From: Liam Mulhall Date: Thu, 5 Jan 2023 16:34:06 -0700 Subject: [PATCH] fix: add curly brace pattern validation for shared strings See https://github.com/phetsims/rosetta/issues/350. --- src/client/components/InputErrorMessage.jsx | 50 ++++++++++--------- .../components/TranslationFormTables.jsx | 2 +- src/client/js/computeTranslatedStringsData.js | 2 +- src/client/js/makeValidationSchema.js | 5 +- src/client/js/submitTranslation.js | 2 +- src/{client/js => common}/KeyTypesEnum.js | 0 6 files changed, 32 insertions(+), 29 deletions(-) rename src/{client/js => common}/KeyTypesEnum.js (100%) diff --git a/src/client/components/InputErrorMessage.jsx b/src/client/components/InputErrorMessage.jsx index 2a5e6dfc..658a6df6 100644 --- a/src/client/components/InputErrorMessage.jsx +++ b/src/client/components/InputErrorMessage.jsx @@ -7,6 +7,7 @@ */ import { useContext } from 'react'; +import KeyTypesEnum from '../../common/KeyTypesEnum.js'; import { ErrorContext } from './TranslationForm.jsx'; import questionOctagon from '../img/question-octagon.svg'; @@ -21,15 +22,15 @@ const InputErrorMessage = ( { fieldKey } ) => { marginLeft: '6px' }; const tooltip = 'Curly brace patterns must match the English version. ' + - 'The values inside of the curly braces must also match the English version. ' + - 'These curly brace patterns are values that dynamically change in the sim.\n\n' + - 'For example, {0}: {1} cannot be translated to {x}: {y}. ' + - 'However, the order of the {0} and the {1} can change. ' + - 'So {0}: {1} could be translated to {1}: {0}.\n\n' + - 'The text outside the curly braces can be changed. ' + - 'For example, Software Development: {0} could be translated to Software Dev: {0}.\n\n' + - 'The rules above apply to string keys with double curly braces as well.\n\n' + - 'For further guidance, please read the user guide.'; + 'The values inside of the curly braces must also match the English version. ' + + 'These curly brace patterns are values that dynamically change in the sim.\n\n' + + 'For example, {0}: {1} cannot be translated to {x}: {y}. ' + + 'However, the order of the {0} and the {1} can change. ' + + 'So {0}: {1} could be translated to {1}: {0}.\n\n' + + 'The text outside the curly braces can be changed. ' + + 'For example, Software Development: {0} could be translated to Software Dev: {0}.\n\n' + + 'The rules above apply to string keys with double curly braces as well.\n\n' + + 'For further guidance, please read the user guide.'; const errorTooltipJsx = (