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

Newlines not preserved in @lingui/react with <tags> #2157

Closed
Garbanas opened this issue Jan 24, 2025 · 0 comments · Fixed by #2158
Closed

Newlines not preserved in @lingui/react with <tags> #2157

Garbanas opened this issue Jan 24, 2025 · 0 comments · Fixed by #2158

Comments

@Garbanas
Copy link
Contributor

Description

In @lingui/react, newlines in translations are not preserved during formatting (rendering), when <tags> are present.
Please see this demo: https://codesandbox.io/p/devbox/infallible-cdn-y863cd

To Reproduce

The content in <pre> should be formatted the same way both times.

import { Trans } from "@lingui/react/macro"

export default function App() {
   return (
      <>
         <pre>
            This is a test{"\n"}
            <strong>with a second{"\n"} and third line</strong>{"\n"}
            and even a fourth one!
         </pre>
         <pre>
            <Trans>
               This is a test{"\n"}
               <strong>with a second{"\n"} and third line</strong>{"\n"}
               and even a fourth one!
            </Trans>
         </pre>
      </>
   );
}

Expected behavior

Newlines are preserved in and around <tags> in translations. The update to lingui 5.0 fixed the whitespace & newline export to catalogs, but formatting is still broken.

Additional context

  • jsLingui version 5.1.2
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 a pull request may close this issue.

1 participant