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

Lingui v5 preview - issues with multiline messages #1975

Closed
AndrewIngram opened this issue Jul 9, 2024 · 3 comments
Closed

Lingui v5 preview - issues with multiline messages #1975

AndrewIngram opened this issue Jul 9, 2024 · 3 comments

Comments

@AndrewIngram
Copy link

We have some messages using the msg macro that are multiline, eg:

        <SomeComponent
          description={_(msg`Learn about the four key steps of building a top-tier corporate
          sustainability program for tackling climate change: measuring
          emissions, reducing them with initiatives, achieving net zero, and
          reporting progress.`)}
        />

(note the indentation)

In Lingui 4, this gets extracted as:

#: components/home/KickoffCard.tsx:116
msgid ""
"Learn about the four key steps of building a top-tier corporate\n"
"sustainability program for tackling climate change: measuring\n"
"emissions, reducing them with initiatives, achieving net zero, and\n"
"reporting progress."
msgstr ""
"Learn about the four key steps of building a top-tier corporate\n"
"sustainability program for tackling climate change: measuring\n"
"emissions, reducing them with initiatives, achieving net zero, and\n"
"reporting progress."

With a generated ID of N0eok2

However, with Lingui 5 it gets extracted as:

#: components/home/KickoffCard.tsx:116
msgid ""
"Learn about the four key steps of building a top-tier corporate\n"
"          sustainability program for tackling climate change: measuring\n"
"          emissions, reducing them with initiatives, achieving net zero, and\n"
"          reporting progress."

With a generated ID of omQrF1.

When we attempt to load the message at runtime (we're using the swc plugin) it's using the ID N0eok2 (matching the v4 extracted message). The dedentation is desirable, so I think the v4 behaviour is most correct?

@timofei-iatsenko
Copy link
Collaborator

timofei-iatsenko commented Jul 9, 2024

The v5 behavior is correct. All indentation / whitespaces are left as-is without any cleaning. V4 version of swc plugin has v4 behavior of whitespace cleaning, so you will have mismatch during runtime/extraction.

This change is ported to swc plugin, but it's not released yet. I asked @andrii-bodnar to make a pre-release of lingui swc plugin.

References:
#1897
#1882

@AndrewIngram
Copy link
Author

Yeah, we're using the swc plugin. I'll try that out when the pre-release is out.

@timofei-iatsenko
Copy link
Collaborator

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

No branches or pull requests

2 participants