Skip to content
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

Feature/pxweb2 99 formatting numbers based on language #65

Merged

Conversation

SjurSutterudSagen
Copy link
Contributor

Since we want to format numbers based on the language chosen, we need to
add this to the project. The basic functionality was added when i18next
was installed, but we have added examples for how to use this in a few
different ways.

We noticed that a basic example led to many places to set the
roundingMode, and therefore created a function and a custom formatter
for i18next, where we set this roundingMode based on a variable. This
prepares the number formatting for the work to be done later, with a
config file for the project.

Co-authored-by: Mikael Nordberg [email protected]

Add basic formatting for numbers. We are still looking into custom
decimals instead of specific hardcoded formats.

Co-authored-by: Mikael Nordberg <>
Add an example of how to override the formatting options, so we can have
other decimal numbers or rounding modes than what is specified in the
translation.json file.

This also gives us the ability to set the options based on a variable.
The next step is to look into turning this into a component to be
reused, so we can have global settings for the options.

Co-authored-by: Mikael Nordberg <>
Since we want to format numbers based on the language chosen, we need to
add this to the project. The basic functionality was added when i18next
was installed, but we have added examples for how to use this in a few
different ways.

We noticed that a basic example led to many places to set the
roundingMode, and therefore created a function and a cusstom formatter
for i18next, where we set this roundingMode based on a variable. This
prepares the number formatting for the work to be done later, with a
config file for the project.

Co-authored-by: Mikael Nordberg <>
@SjurSutterudSagen SjurSutterudSagen requested review from a team March 7, 2024 09:51
@SjurSutterudSagen
Copy link
Contributor Author

The issue we ran into with TypeScript and "roundingMode" missing in the type for intl.NumberFormatOptions is solved microsoft/TypeScript#52072. But this is not yet available in the released ts version, as of now.

@MikaelNordberg MikaelNordberg requested a review from likp March 8, 2024 10:43
Copy link
Contributor

@michaelpande michaelpande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@SjurSutterudSagen SjurSutterudSagen merged commit fe5f8e2 into main Mar 8, 2024
1 check passed
@SjurSutterudSagen SjurSutterudSagen deleted the feature/PXWEB2-99-formatting-numbers-based-on-language branch March 8, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants