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

ngettext definition not in resulting .po-file #200

Open
aldipower opened this issue May 26, 2020 · 6 comments
Open

ngettext definition not in resulting .po-file #200

aldipower opened this issue May 26, 2020 · 6 comments

Comments

@aldipower
Copy link

aldipower commented May 26, 2020

Hi,

I have the following code-block in my application, which is not detected by the parser and thus not included in the resulting .po-file:

import { ngettext, msgid } from 'ttag.macro';

export const timespanTypePluralNameFunc = {
  [TimespanType.WEEK]: count => ngettext(msgid`Woche`, `Wochen`, count),
  [TimespanType.MONTH]: count => ngettext(msgid`Monat`, `Monate`, count),
  [TimespanType.YEAR]: count => ngettext(msgid`Jahr`, `Jahre`, count),
};

Other functions with ngettext are working perfectly fine, f.ex. this is included and working:

  import { ngettext, msgid } from 'ttag.macro';

  getDaysLine() {
    const { days = 0 } = this.props.entry;

    return (
      <span>
        {days} {ngettext(msgid`Tag`, `Tage`, days)}
      </span>
    );
  }

Maybe it's not a bug and I do not understand the upper scope correctly?
It is really unexpected anyway.


Acutally it is include in the .po file, but only as singular form:

#: src/maps/index.js:75
msgid "Woche"
msgstr "Woche"
@aldipower
Copy link
Author

aldipower commented May 26, 2020

OK, the problem is that I already defined a singular definition of "Woche" somewhere else.

export const timespanTypeNameMap = {
  [TimespanType.WEEK]: t`Woche`,
}

So this seems to be conflicting then and the latter 'ngettext' gets ignored without warning..


Ok, sorry to be overhasty, this wasn't the problem. Even if I remove the singular variants, the plural still does not show up.

@AlexMost
Copy link
Member

Hi @aldipower! Seems like a bug, need to check that. Let's clarify the reproduce case. If I've got your point, this code block is not extracted by ttag-cli:

import { ngettext, msgid } from 'ttag.macro';

export const timespanTypePluralNameFunc = {
  [TimespanType.WEEK]: count => ngettext(msgid`Woche`, `Wochen`, count),
  [TimespanType.MONTH]: count => ngettext(msgid`Monat`, `Monate`, count),
  [TimespanType.YEAR]: count => ngettext(msgid`Jahr`, `Jahre`, count),
};

It's CRA?
You can also try to add --discover option to ttag-cli. https://github.com/ttag-org/ttag-cli#update-opts-pofile-src

@aldipower
Copy link
Author

aldipower commented May 26, 2020

Hi @AlexMost !

Yes, it's CRA with ttag.macro.

Exactly, the above code block isn't extracted and does not show up in the .po.
Interesstingly, when I change

[TimespanType.WEEK]: count => ngettext(msgid`Woche`, `Wochen`, count),

to

[TimespanType.WEEK]: count => ngettext(msgid`WocheTEST`, `WochenTEST`, count),

it shows up as expected.

When I run it with --discover ngettext it doesn't make any difference.

@AlexMost
Copy link
Member

Hm, that sound's interesting. I will appreciate if you could create some example repo. That would simplify the reproduce case for me.

@aldipower
Copy link
Author

Yes, let me try to reproduce it in a clean repo. Please hold the line. ;) Could take me a while..

@aldipower
Copy link
Author

aldipower commented May 26, 2020

Ok @AlexMost, that was easy to reproduce.

https://github.com/aldipower/ttag-test

Plural forms of src/test-map/index.js should show up in i18n/en.po after running npm run i18n-update, but the do not.

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