Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload Image Component Is Not Support many language #1167

Open
chenyong0923 opened this issue Nov 8, 2024 · 2 comments
Open

Upload Image Component Is Not Support many language #1167

chenyong0923 opened this issue Nov 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@chenyong0923
Copy link

image

image

`typescript
import React, { useMemo, useRef } from 'react';
import { Form, InputGroup } from 'react-bootstrap';
import type { FC } from 'react';
import { useTranslation } from 'react-i18next';

interface CustomFileInputProps {
value: string;
onChange: React.ChangeEventHandler;
isValid?: boolean;
isInvalid?: boolean;
}

const CustomFileInput: FC = ({
onChange,
value,
...rest
}) => {
const { t } = useTranslation('translation', { keyPrefix: 'editor' });
const fileName = useMemo(() => {
return value ?? t('file_upload.text');
}, [value]);

const fileRef = useRef(null);

return (
<Form.Group>
<Form.Control
type="file"
id="custom-file"
onChange={onChange}
style={{ zIndex: -1, position: 'absolute' }} // 隐藏默认控件
ref={fileRef}
{...rest}
/>

  <InputGroup className="mb-3">
    <InputGroup.Text id="basic-addon1">
      {t('file_upload.text')}
    </InputGroup.Text>
    <Form.Control
      type="text"
      readOnly
      value={fileName}
      aria-label={t('file_upload.text')}
      placeholder={t('file_upload.placeholder')}
      aria-describedby="basic-addon1"
      onClick={() => {
        fileRef?.current?.click?.();
      }}
    />
  </InputGroup>
</Form.Group>

);
};

export default CustomFileInput;


<CustomFileInput
value={link.value}
onChange={onUpload}
isInvalid={currentTab === 'localImage' && link.isInvalid}
/>
{/* <Form.Control
type="file"
placeholder="123"
prefix="234"
title="title"
onChange={onUpload}
isInvalid={currentTab === 'localImage' && link.isInvalid}
/> */}
`

@chenyong0923 chenyong0923 added the bug Something isn't working label Nov 8, 2024
@LinkinStars
Copy link
Member

image

Maybe you need to reload the page after changing the language.

@chenyong0923
Copy link
Author

image

Maybe you need to reload the page after changing the language.

This is official and it seems to have a problem. You can try more times. The solution I provided above should resolve the issue.show code
image

@fenbox fenbox changed the title Uoload Image Component Is Not Support many language Upload Image Component Is Not Support many language Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants