-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional number elongation #18
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
|
||
let pseudoLocalizedText = ""; | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@@ -126,30 +134,40 @@ const strategies = { | |||
}; | |||
|
|||
const psuedoLocalizeString = (string, options = { strategy: "accented" }) => { | |||
let opts = strategies[options.strategy]; | |||
let strategyOptions = strategies[options.strategy]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice rename :)
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.