Skip to content

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

@Docteh

Description

@Docteh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions