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

Plural translations (with count paramater) produce "does not match server-rendered HTML" ("ua" locale) #605

Closed
nikitastryuk opened this issue Nov 7, 2023 · 3 comments
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@nikitastryuk
Copy link

nikitastryuk commented Nov 7, 2023

Description

Plural translations (with count paramater) which uses "Intl.PluralRules" API determined incorrectly on server ("ua" locale).

Issue
{ "test": "{count, plural, one {# user} other {# users}}" }

<p>{t('test', { count: 21 })}</p>

#other is returned from server-rendered html and then transformed to #one on client side.

image

Mandatory reproduction URL (CodeSandbox or GitHub repository)

Codesandbox

Reproduction description

To Reproduce

  1. Go to Codesandbox
  2. Insert /ua to url
  3. Press Enter
  4. See Hydration error
  5. Press enter more times (with url focused) to see blinking translations

Expected behaviour

Plural translations should behave the same on both server and client.

@nikitastryuk nikitastryuk added bug Something isn't working unconfirmed Needs triage. labels Nov 7, 2023
@nikitastryuk nikitastryuk changed the title Plural translations (with count paramater) does not match server-rendered HTML ("ua" locale) Plural translations (with count paramater) produce does not match server-rendered HTML ("ua" locale) Nov 7, 2023
@nikitastryuk nikitastryuk changed the title Plural translations (with count paramater) produce does not match server-rendered HTML ("ua" locale) Plural translations (with count paramater) produce "does not match server-rendered HTML" ("ua" locale) Nov 7, 2023
@nikitastryuk
Copy link
Author

nikitastryuk commented Nov 7, 2023

UPD after some debugging and investigation:

It started working with uk instead of ua. Looks like Intl.PluralRules works with codes from this list only.

But still not sure why server side initial result is different.

@amannn
Copy link
Owner

amannn commented Nov 8, 2023

Node.js and browsers seem to have subtle differences when it comes to the implementation of Intl. We saw a similar issue here: #528

@amannn
Copy link
Owner

amannn commented Nov 23, 2023

This seems to be out of control for next-intl and is related to the underlying runtime. You might have to provide polyfills for a consistent environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants