masroorejaz / react-simple-captcha

A very simple and powerful captcha for ReactJS
40 stars 19 forks source link

can't use string variable in reloadText property #27

Closed amirshnll closed 1 year ago

amirshnll commented 1 year ago

Hello @masroorejaz , In reloadText of LoadCanvasTemplate, I can't use a variable with a string. I load all of my string as a JSON file in page:

import STRINGES from "./string.json";
.
.
.
<LoadCanvasTemplate reloadText={STRINGES.reload} />
masroorejaz commented 1 year ago

Actually random string generation is already built-in function in react-simple-captcha.

Kindly read all the Optional Changes in Readme file

Simply use _loadCaptchaEnginge(Number_Of_Captcha_Charcters, BackgroundColor); as mentioned in Readme File and it will generate random string automatically.

amirshnll commented 1 year ago

no no no, I want to read reload link text from a file.

masroorejaz commented 1 year ago

Actually that's currently not possible in this captcha.

Also there are plenty of options like Numeric Only, Alphabets or Special Characters only that will fulfilled your desired output in Captcha.

If you still having problem then kindly share a screenshot with detials.

amirshnll commented 1 year ago

Thank you for replying fast.

To prevent hard code Persian (Farsi) characters immediately, I create a JSON file for saving my web app strings. and I want read value of the reloadText property instead of the hardcode inside my file:

hardcoded version

<LoadCanvasTemplate reloadText={"کدجدید"} />

i want this:

import STRINGES from "./string.json";
.
.
.
<LoadCanvasTemplate reloadText={STRINGES.reload} />

json file

{
"reload":"کدجدید"
}

In the render page, your library has not loaded my string and loaded the default string for reloadText.

masroorejaz commented 1 year ago

You can get value from json file in a string and display it using that string.

Currently what you are looking for it's not possible in the current version. You can however make changes the code accordingly as the whole code is uploaded on GitHub.

Thank you.

amirshnll commented 1 year ago

Thank you. I feel you can fix this problem with localization