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

InputNumber should support global locale #4291

Closed
tomas-pritrsky opened this issue Apr 26, 2023 · 5 comments · Fixed by #4297
Closed

InputNumber should support global locale #4291

tomas-pritrsky opened this issue Apr 26, 2023 · 5 comments · Fixed by #4297
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@tomas-pritrsky
Copy link

Describe the feature you would like to see added

All components should respect PrimeReact.locale

Is your feature request related to a problem?

InputNumber component already has a 'locale' attribute which works fine. However, in usual scenarios, you want to set PrimeReact.locale once and have all components respect this configuration. For example Calendar component supports the PrimeReact.locale

Ofcourse, if I set 'locale' attribute to InputNumber directly, this must be applied regardless of what is set in PrimeReact.locale

Describe the solution you'd like

When I set PrimeReact.locale, all components should use this value as a default locale

Describe alternatives you have considered

setting 'locale' attribute to InputNumber manually - works, but should not be necessary for default number formatting

Additional context

issue is at PrimeReact v8.6.1 and also latest

@tomas-pritrsky tomas-pritrsky added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Apr 26, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 26, 2023
@melloware melloware added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Type: New Feature Issue contains a new feature or new component request Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 26, 2023
@melloware melloware self-assigned this Apr 26, 2023
@melloware melloware modified the milestones: 10.0.0, 9.4.0 Apr 26, 2023
@melloware
Copy link
Member

I think I know why. In the example

image

NULL locale means use the browsers locale, using the global Locale its always US English en so that means there would be no way to default to the browsers Locale.

So a workaround is here: https://stackblitz.com/edit/react-crtbtu?file=src%2FApp.tsx

<InputNumber
          inputId="locale-user"
          value={value1}
          onValueChange={(e: InputNumberValueChangeEvent) => setValue1(e.value)}
          minFractionDigits={2}
          locale={PrimeReact.locale}
        />

@melloware melloware removed this from the 9.4.0 milestone Apr 26, 2023
@melloware melloware added Status: Discussion Issue or pull request needs to be discussed by Core Team and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Apr 26, 2023
@MatejHudec
Copy link

so it can't be set on a global scale i suppose as another prime react components localization. Intl number localization is not part of PrimeReact locale functionality.

@melloware
Copy link
Member

Correct!!!

@melloware
Copy link
Member

I am trying to think of a clever way this could be done without breaking the default browser locale scenario...

@melloware
Copy link
Member

Submitted a PR and assigned PrimeTek to review.

@melloware melloware added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Apr 27, 2023
melloware added a commit to melloware/primereact that referenced this issue Apr 27, 2023
melloware added a commit to melloware/primereact that referenced this issue Apr 28, 2023
melloware added a commit to melloware/primereact that referenced this issue May 10, 2023
melloware added a commit to melloware/primereact that referenced this issue May 10, 2023
melloware added a commit to melloware/primereact that referenced this issue Jun 12, 2023
melloware added a commit to melloware/primereact that referenced this issue Jun 12, 2023
@melloware melloware added this to the 9.6.0 milestone Jun 13, 2023
@melloware melloware removed the Status: Discussion Issue or pull request needs to be discussed by Core Team label Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants