i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

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

Open tkrotoff opened this issue 3 years ago • 9 comments

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

  • runtime version: node 12, Firefox 86 & Chrome 88
  • i18next version: i.e. 19.9.1
  • i18next-parser version: 3.7.0
  • react-i18next version: 11.8.8

tkrotoff avatar Mar 03 '21 13:03 tkrotoff

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!

karellm avatar Mar 03 '21 20:03 karellm

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...

igorsantos07 avatar Sep 03 '21 05:09 igorsantos07

@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.

karellm avatar Sep 04 '21 01:09 karellm

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.

igorsantos07 avatar Sep 04 '21 12:09 igorsantos07

@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...

jamuhl avatar Sep 04 '21 13:09 jamuhl

@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.

igorsantos07 avatar Mar 11 '22 21:03 igorsantos07

@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;

  • i18next is not a real organization or company, it's a github organization: https://github.com/i18next
  • 10yo stability is for i18next (https://github.com/i18next/i18next), not for all i18next related modules
  • Regarding sponsoring: at least there is a bit of sponsoring. I don't think it would be better without any sponsoring?
  • A bit of history:
    1. i18next library was created by @jamuhl
    2. community extended the ecosystem, i.e. i18next-parser
    3. i18next creators created locize (also to fund the i18next library maintenance) - the question was "keep it in PR only mode"/deprecate it or try to find some funding
    4. locize tries to "say thank you" to some of the i18next projects created by the community by sponsoring them
  • All open source related work for i18next was and is done during our free time. Do you know what it means to maintain an open source project? A lot of time (not only coding, issues, Stackoverflow, docs, tutorials, etc.) is invested.
  • At the end: if you're not happy with i18next, I hope nobody forces you to use it, so you can pick something that suits more your expectations.

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?

adrai avatar Mar 12 '22 09:03 adrai

@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.

karellm avatar Mar 12 '22 16:03 karellm

This is still an issue.

LuisHerrero92 avatar Jun 09 '22 13:06 LuisHerrero92