Skip to content

Place holder IDs aren't always starting from 0 #2

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

Open
Docteh opened this issue May 23, 2025 · 0 comments
Open

Place holder IDs aren't always starting from 0 #2

Docteh opened this issue May 23, 2025 · 0 comments

Comments

@Docteh
Copy link

Docteh commented May 23, 2025

Hi, I found a problem that is actually the opposite of a problem fixed in lingui/js-lingui. After a closer look that bug is extraction, I'm seeing an issue with compilation.

I'll look into building a simple test case, it'll take me awhile, but this really seems like a case of pouring milk into a bowl of cornflakes and getting fire as a result.

Hi, I think a fix in lingui/js-lingui#2204 likely needs to be applied to here

Code in question
https://github.com/revoltchat/frontend/blob/30abe9801eaac3268a8fe0df04b4987acd7d734d/packages/client/src/interface/channels/text/Composition.tsx#L453-L459

Line 9: import { useLingui } from "@lingui-solid/solid/macro";
Line 53: const { t } = useLingui();

Note: I think that means they're using this package/repository

        placeholder={
          props.channel.type === "SavedMessages"
            ? t`Save to your notes`
            : props.channel.type === "DirectMessage"
              ? t`Message ${props.channel.recipient?.username}`
              : t`Message ${props.channel.name}`
        }

Gets compiled to

        get placeholder() {
            return Re( () => e.channel.type === "SavedMessages")() ? t({
                id: "JW8mxK"
            }) : Re( () => e.channel.type === "DirectMessage")() ? t({
                id: "pqr+oY",
                values: {
                    0: e.channel.recipient?.username
                }
            }) : t({
                id: "1BJjUw",
                values: {
                    1: e.channel.name
                }
            })
        },

For extraction the strings are correctly extracted as "Message {0}" but for the compiled program the second translated string is being treated like "Message {1}"

$ echo -en "Message {0}\x1f" | sha256sum  | perl -nle 'print pack "H*", $_' | base64 | cut -b -6
pqr+oY
$ echo -en "Message {1}\x1f" | sha256sum  | perl -nle 'print pack "H*", $_' | base64 | cut -b -6
1BJjUw
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

1 participant