react-currency-input-field
react-currency-input-field copied to clipboard
Add support for Bulgarian
Describe the bug The CurrencyInput component doesn't properly format the string when you set the locale to a language in which the group separator is a " " (space), such as Bulgarian.
To Reproduce
- Create a component as follows:
import CurrencyInput from 'react-currency-input-field';
import React from "react";
const InputCurrencyReactInputField = () => {
const [userInput, setUserInput] = React.useState('');
return (
<CurrencyInput
value={userInput}
id="input-example"
intlConfig={{
locale: 'bg-BG',
currency: 'EUR',
}}
name="input-name"
placeholder="Please enter a number"
defaultValue={1000}
decimalsLimit={2}
onValueChange={(value, name, values) => {
setUserInput(value);
console.log({value, name, values})
}}
/>
)
}
export default InputCurrencyReactInputField;
In the browser, type "90000". The expected string is "90 000 €" but the one shown is "90000€"
Expected behavior To show "90 000 €"
Code Sandbox Example
Additional context Some problems with this bug are related to the fact that the separator isn't assumed to be a space. The helper addSeparator might need to be implemented. As it is, it won't work properly for Bulgarian in the cases that the amount is less than 9999 (in Bulgarian, numbers less than 9999 do not have a group separator)