Conversation
|
Hey! I did a quite significant refactoring of the internals so you probably have some conflicts. |
Heyla, if you agree with the concepts in the PR I don't mind fixing the conflicts sometime soon :) |
|
It's an interesting idea. I'd love to explore the implications a bit further! If some input value is being kept in sync in the DOM and JavaScript I'm not sure how this would affect that. For example in React it's common to use controlled inputs |
| @@ -126,30 +134,40 @@ const strategies = { | |||
| }; | |||
|
|
|||
| const psuedoLocalizeString = (string, options = { strategy: "accented" }) => { | |||
There was a problem hiding this comment.
There will be conflicts on this line after rebase, I think the best fix is
{ strategy = 'accented', elongateNumbers = false } = {}to keep deep defaults and avoid can not find elongateNumbers of undefined Errors in edge cases!
| for (let character of string) { | ||
| if (opts.map[character]) { | ||
| const convertedCharacter = strategyOptions.map[character] | ||
| const characterAsInt = parseInt(character) |
There was a problem hiding this comment.
I think we can move this inline to line 146.
!isNaN(parseInt(character))imo it's still totally legible and we avoid executing parseInt for every character if elongateNumbers number is false.
Now that I think about it do we need to parseInt?
would
options.elongateNumbers &&
EVEN_NUMBER_MAP[character]not be enough?
|
|
||
| const psuedoLocalizeString = (string, options = { strategy: "accented" }) => { | ||
| let opts = strategies[options.strategy]; | ||
| let strategyOptions = strategies[options.strategy]; |

Fix #15.
For now I decided to only elongate even numbers to avoid elongating the numbers too much, it might make sense to review this later.
Our main use case is currencies, but also to exercise the UI with longer numbers like the amount of reviews, for example.