I’m developing my plugin in the English version of Photoshop.
I have an sp-textfield that accepts user input.
<sp-textfield quiet type="number" id="offset" ></sp-textfield>
This textfield accepts numbers including decimals, like: 20.8
That works fine in the U.S. version of the plugin. However, in France, they need to enter their decimal numbers like: 20,8
They use a comma for the decimal point, not a period.
Unfortunately, since the sp-textfield’s type is “number” it doesn’t accept commas, and French users will only be able to enter whole numbers.
I’ve read here that I can get the “locale” using the following code:
const host = require('uxp').host; const locale = host.uiLocale; const hostName = host.name const hostVersion = host.version; console.log(`locale: ${locale} host ${hostName} version ${hostVersion}`);
That works. But now what do I do with the locale so that this sp-textfield that requires numbers will accept commas in France?
Or is the best solution to change the sp-textfield’s type to “text” and monitor for incorrect entries?