i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
472 stars 194 forks source link

Trans should not generate <1></1> for <br /> and <p> #264

Open tkrotoff opened 3 years ago

tkrotoff commented 3 years ago

To Reproduce

function Test() {
  const { t } = useTranslation();

  return (
    <Trans t={t}>
      hello
      <br />
      world
    </Trans>
  );
}
i18next Test.ts

i18next-parser generates:

{
  "hello<1></1>world": "salut<1></1>monde",
}

i18next in debug mode reports:

i18next::translator: missingKey fr translation hello<br/>world hello<br/>world

Expected behavior

i18next-parser should generate instead:

{
  "hello<br/>world": "salut<br/>monde",
}

More

<p> does not work too: i18next-parser should generate hello<p>world</p> instead of hello<1>world</1>.

Funny: <small> generates hello<1>world</1> and it works with i18next!!

There is definitely something wrong with i18next and i18next-parser formats: they should be the same.

Your Environment

karellm commented 3 years ago

It might be related to https://github.com/i18next/i18next-parser/pull/254

I'm not using react and I'm mostly maintaining this project because many rely on it. If you want to submit a PR, I will review and merge it!

igorsantos07 commented 3 years ago

Yep, that seems to still be a bug under i18next-parser 4.3.0. I wonder if the parser should follow the settings for the 18next?

Setting => transKeepBasicHtmlNodesFor: ['p', 'br', 'strong', 'b', 'i', 'em', 'u', 'tt', 'label']
Interface has => [...] <span className="text-nowrap">Use <tt>0</tt> to disable</span>
i18next reports =>      [...] <1>Use <tt>0</tt> to disable</1>. 
i18next-parser writes => [...] <1>Use <1>0</1> to disable</1>.

Indexing seems odd at first glance, but I guess it's 1 and 1 because they're nested?

The workaround currently is to disregard this neat option with transSupportBasicHtmlNodes: false. It works fine (even the 1 and 1 tags work, still showing that way).


Btw, if the project is solely depending on external PRs, I wonder if it would be better to remove the "gold sponsor" ad in the README? I mean, it seems they're neither sponsoring maintenance nor caring themselves for the project, even though it's under their org...

karellm commented 3 years ago

@igorsantos07 Yes ideally it should follow the settings from i18next.

For your other question: I'm not affiliated to i18next and this project is under their organization only to make it easier for people to find. That said, they were kind enough to offer a small monthly contribution. On a personal note, I don't even use this project anymore but I only maintain this project because it is used quite a lot. I've never done this for the money and the sponsorship doesn't come close to pay for the hundreds of hours spent on this project. Yet I will not remove the mention to it because I'm grateful for their contribution. Rather than criticizing the sponsorship of other, I believe a more productive question would be how can you contribute (with you time or financially) in order to have more work done on this project.

igorsantos07 commented 3 years ago

Right, it makes sense if the sponsorship still happens, even if symbolic for your past work.

I'm totally in for OS contributions, but it's complicated to contribute forever during work time when you end up finding and reporting more bugs than actually using a "battle tested and 10yo library". So, yeah, I'm leaving criticism around when it's mentioned "there's no time or money to fix bugs" as a reason to leave stuff pending. It IS a valid reason, but it's tiring when you find the same in all corners of the environment.

The fact it got embraced by the main organization is also confusing since the... Organization don't really offer support besides the symbolic sponsorship. It really just helps organizing, instead of being a cohesive group of developed projects. It's the same false message a sponsored project passes on - you expect organization and maintenance, but most is in a PRs-only state.

The criticism is not on you. It's on the image i18next packages pass.

On Fri, Sep 3, 2021, 22:34 Karel Ledru @.***> wrote:

@igorsantos07 https://github.com/igorsantos07 Yes ideally it should follow the settings from i18next.

For your other question: I'm not affiliated to i18next and this project is under their organization only to make it easier for people to find. That said, they were kind enough to offer a small monthly contribution. On a personal note, I don't even use this project anymore but I only maintain this project because it is used quite a lot. I've never done this for the money and the sponsorship doesn't come close to pay for the hundreds of hours spent on this project. Yet I will not remove the mention to it because I'm grateful for their contribution. Rather than criticizing the sponsorship of other, I believe a more productive question would be how can you contribute (with you time or financially) in order to have more work done on this project.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/i18next/i18next-parser/issues/264#issuecomment-912885396, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEB6S7CBHGAFRLHP6DIXCTUAFZRHANCNFSM4YRF6VDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jamuhl commented 3 years ago

@igorsantos07 I'm not sure what you like to achieve? On one hand, you are crying around open source is broken by not having enough maintained modules. On the other hand, you're pointing around our organisation does no free support or not enough. @adrai and I do quite a lot to keep i18next and react-i18next running and in a way, it will run in the next years coming too.

i18next is feature stable (proven over the years) and therefore new features needed by minorities are added carefully to not further bloat the project size.

You say it's tiring - but the fact is i18next runs now for over 10 years - and is even more or less API compatible with the v1. Give me any other module of this size that has achieved this. Believe me I gone through all the react-routers, react state managements with their ever-changing APIs every few months.

If you don't like i18next or locize...there are other options around...that easy. Perhaps you just have the wrong picture of the size of our company...

If you think you're able to change the i18next organisation to a cohesive group of developed projects - I'm open to letting you prove it...

igorsantos07 commented 2 years ago

@jamuhl Could not help but laugh at your mention of react-routers (emphasis on the plural) and the likes. Definitely can relate lol I left the issue alone since I saw nothing was going to be fixed, and ended up never seeing the response on the side-topic.

The thing is: the message passed by being under an Org and being a sponsored project isn't what really happens. And I understand why all that, but still it's not clear these projects are in PR-only mode. You come in for the battle-tested and 10yo stability, but end up finding a couple of bugs here and there that almost get a "wontfix" label.

I don't need to prove anything, nor change something from the outside. What I can do is show what's visible from the outside, from a newcomer's point of view: there is slight incoherence in a sponsored project being PR-only. One would expect sponsored projects to be actively looked into, instead of getting "we're open to PRs" on bug reports. Since this is really the case, this should be clear from the readme and docs, stating the project is sort of stale.


On the main topic though, I came back because it bite me again. My suggestion created a nasty side-effect, which I guess is better suited to another issue.

adrai commented 2 years ago

@jamuhl Could not help but laugh at your mention of react-routers (emphasis on the plural) and the likes. Definitely can relate lol I left the issue alone since I saw nothing was going to be fixed, and ended up never seeing the response on the side-topic.

The thing is: the message passed by being under an Org and being a sponsored project isn't what really happens. And I understand why all that, but still it's not clear these projects are in PR-only mode. You come in for the battle-tested and 10yo stability, but end up finding a couple of bugs here and there that almost get a "wontfix" label.

I don't need to prove anything, nor change something from the outside. What I can do is show what's visible from the outside, from a newcomer's point of view: there is slight incoherence in a sponsored project being PR-only. One would expect sponsored projects to be actively looked into, instead of getting "we're open to PRs" on bug reports. Since this is really the case, this should be clear from the readme and docs, stating the project is sort of stale.

tldr;

Solutions? So what could be possible solutions to optimize the situation of i18next-parser? Since @jamuhl @karellm and I are not using i18next-parser personally, who wants to contribute? How much money/time is needed so these i18next-parser "issues" could be addressed? Is someone able to create an estimation/offer?

karellm commented 2 years ago

@adrai I'm still coding and fixing things for this project. Yet I'm at a different place in my life today and my priorities are organized differently. It means that it will evolve slowly when I can afford to put some time on it.

If someone need things fixed faster, one way would be to give a financial contribution. I've never received such a proposition in this project (beside the welcomed sponsorship) but I'm willing to discuss it. Another way is to open PRs and invest the necessary time to improve the project collaboratively, I'd be happy to open a maintainer sit if anyone feels the calling.

LuisHerrero92 commented 2 years ago

This is still an issue.