rugk / unicodify

✍️ A browser add-on (Firefox, Chrome, Thunderbird) that allows you to autocorrect common text sequences and convert text characters to a look like a special font.
https://addons.mozilla.org/firefox/addon/unicodify-text-transformer/?utm_source=github.com&utm_medium=git&utm_content=repo-about-description&utm_campaign=github
Other
10 stars 2 forks source link

Quotes and number parsing for each language/locale #12

Open tdulcet opened 3 years ago

tdulcet commented 3 years ago

Background

The “Use Unicode smart quotes” option currently just uses the English smart quotes. The “Convert fractions and mathematical constants to Unicode characters” option currently only accepts the period for the decimal point and it does not support numbers with thousand separators, such as 1234.25. This is mainly because that is all the parseFloat() function supports (see here).

Proposed solution

For the “Use Unicode smart quotes” option, @rugk suggested that it use the quotes for each language/locale in https://github.com/rugk/awesome-emoji-picker/pull/93#pullrequestreview-451154606. See here for a table of the quotes for different languages. I would need to know which quote character(s) are on the keyboards for each locale and which smart quote character(s) it should automatically replace (autocorrect) them with.

For the “Convert fractions and mathematical constants to Unicode characters” option, I propose that it support locale formatted numbers, with the locale decimal point and thousand separators. For example, some locales write numbers like 1,234.25, while others would write the same number as 1.234,25.

rugk commented 3 years ago

parseFloat seems indeed problematic. While JS does have localized versions for string comparison and number generation it seems to have no built-in way for localized number parsing.