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

nggettext and msgid returning ${ undefined } on plural #208

Open
mmso opened this issue Oct 8, 2020 · 3 comments
Open

nggettext and msgid returning ${ undefined } on plural #208

mmso opened this issue Oct 8, 2020 · 3 comments

Comments

@mmso
Copy link
Contributor

mmso commented Oct 8, 2020

A string such as

  const result = c('Title').ngettext(msgid`Delete ${name}`, `Delete ${count} contacts`, count);

when translated will result in

${undefined} Kontakte löschen

It seems that variables aren't replaced in the plural version

I've created a reproducible example here: mmso/ttag-bug-example@5a550dd

@AlexMost
Copy link
Member

AlexMost commented Nov 2, 2020

Thanks for the report! will try to fix that ASAP

@zzorba
Copy link

zzorba commented Nov 18, 2020

I ran into something that I think might be a similar issue, so just detailing what I found in hopes that it is helpful.

In my codebase, I had two strings with the same key -- one had plural forms and the other did not.

e.g.

ngettext(msgid`${experience} XP`, `${experience} XP`, experience)

vs

t`${experience} XP`

The singular form existed first, and was all that was included in the extracted PO files (even after the plural was added). Even when the singular form was removed, the po files were not updated. Using said translation seemed to cause a runtime error with ngettext + r.replace when it was used.

By deleting the singular form from all the translated versions and regenerating, I was able to get past this.

Not sure if that's helpful, but the singular/plural split seems like it might be related here.

@andrey-skl
Copy link

andrey-skl commented May 16, 2024

We can see that the issue is replaceVariables takes variables only from first string (that is wrapped with msgid):

2024-05-16 17 14 39

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

4 participants