fix: variable label i18n & create question guide language (#2933)

This commit is contained in:
heheer
2024-10-16 14:21:53 +08:00
committed by GitHub
parent 8bdb35ff51
commit d45d18cc3b
2 changed files with 12 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import { TextNode } from 'lexical';
import { getHashtagRegexString } from './utils';
import { mergeRegister } from '@lexical/utils';
import { registerLexicalTextEntity } from '../../utils';
import { useTranslation } from 'react-i18next';
const REGEX = new RegExp(getHashtagRegexString(), 'i');
@@ -14,6 +15,7 @@ export default function VariableLabelPlugin({
}: {
variables: EditorVariableLabelPickerType[];
}) {
const { t } = useTranslation();
const [editor] = useLexicalComposerContext();
useEffect(() => {
if (!editor.hasNodes([VariableLabelNode]))
@@ -25,7 +27,7 @@ export default function VariableLabelPlugin({
const currentVariable = variables.find(
(item) => item.parent.id === parentKey && item.key === childrenKey
);
const variableLabel = `${currentVariable && currentVariable.parent?.label}.${currentVariable?.label}`;
const variableLabel = `${currentVariable && t(currentVariable.parent?.label as any)}.${currentVariable?.label}`;
const nodeAvatar = currentVariable?.parent?.avatar || '';
return $createVariableLabelNode(textNode.getTextContent(), variableLabel, nodeAvatar);
}, []);