Skip to content

Commit 30c8abd

Browse files
stephenhandCopilot
andauthored
Update aselo-webchat-react-app/src/localization/LocalizedTemplate.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent bb21c62 commit 30c8abd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

aselo-webchat-react-app/src/localization/LocalizedTemplate.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ import { useSelector } from 'react-redux';
1818
import { localizeKey } from './localizeKey';
1919
import { selectCurrentTranslations } from '../store/config.reducer';
2020

21-
const LocalizedTemplate: React.FC<{ code: string; renderAsHtml?: string } & Record<string, string>> = ({
21+
const LocalizedTemplate: React.FC<{ code: string; renderAsHtml?: string | boolean } & Record<string, string>> = ({
2222
code,
2323
renderAsHtml,
2424
...parameters
2525
}) => {
2626
const translations = useSelector(selectCurrentTranslations);
2727
const translateForCurrentLocale = localizeKey(translations);
28-
if (renderAsHtml?.toLowerCase() === 'true') {
28+
const shouldRenderAsHtml =
29+
typeof renderAsHtml === 'string'
30+
? renderAsHtml.trim().toLowerCase() === 'true'
31+
: Boolean(renderAsHtml);
32+
if (shouldRenderAsHtml) {
2933
// eslint-disable-next-line react/no-danger
3034
return <span dangerouslySetInnerHTML={{ __html: translateForCurrentLocale(code, parameters) }} />;
3135
}

0 commit comments

Comments
 (0)