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

feat(react): preserve newlines during string formatting #1983

Closed

Conversation

Garbanas
Copy link
Contributor

@Garbanas Garbanas commented Jul 22, 2024

Description

This change will preserve newline characters also for translations in @lingui/react when <tags> are present. Newlines are already preserved for values with no tags or just simple placeholders.
This PR ensures that formatting is done the same way for both variants: with and without <tags>.

The benefit is that CSS rules or tags that rely on preservation of newlines now work with <tags>.
See https://developer.mozilla.org/en-US/docs/Web/CSS/white-space#pre-line

Types of changes

Depending on your view, this is either a bugfix (ensuring that formatting works the same across variants), or a breaking change (changes the newline behaviour for a formatting variant).

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Jul 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 2:00pm

Copy link

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.88 KB (0%)
./packages/detect-locale/dist/index.mjs 723 B (0%)
./packages/react/dist/index.mjs 1.67 KB (0%)
./packages/remote-loader/dist/index.mjs 7.26 KB (0%)

@timofei-iatsenko
Copy link
Collaborator

Have you seen these two merged pull requests?

#1897
#1882

The changes are already released with a next tag https://www.npmjs.com/package/@lingui/core/v/5.0.0-next.0

@andrii-bodnar
Copy link
Contributor

Thanks @Garbanas for the contribution!

As @thekip said, this has already been implemented in the next v5 release, so I will close this PR.

Feel free to try the 5.0.0-next.0 release and let us know if it works as expected for you.

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.

3 participants