Mixing plural and properties other than textContent
Phyks opened this issue · 9 comments
Hi,
I am trying to mix plural and properties other than textContent
, such as innerHTML
.
My properties file contains:
available_bikes.innerHTML = {[ plural(n) ]}
available_bikes[zero].innerHTML = available<br/>bike
available_bikes[one].innerHTML = available<br/>bike
available_bikes[other].innerHTML = available<br/>bikes
And my HTML file contains:
<span data-l10n-id="available_bikes" data-l10n-args='{ "n": "42" }'>vélos<br/>disponibles</span>
Which, as far as I understand the syntax and the way the code works, should be working. But it does not. It displays {[ plural(n) ]}
, which is unexpected. If I edit the HTML file to look like this:
<span data-l10n-id="available_bikes[other]">vélos<br/>disponibles</span>
it works.
Do you know if I am doing anything wrong or if this is a bug?
Thanks
Anyone having a solution for this issue? Thanks!
Try stepping through with a debugger to see what goes wrong.
I suggest to put a breakpoint at the start of gMacros.plural
.
@Rob--W It is due to https://github.com/fabi1cazenave/webL10n/blob/master/l10n.js#L811 which bypasses evaluation for non-textual properties such as innerHTML
.
Is there any reason to have this line of code?
@Phyks I guess that it's just not implemented due to the lack of need / time. @fabi1cazenave can give a more authorative answer to why that line of code is there.
@Rob--W @fabi1cazenave Ok, I just removed the faulty line and it works for my use case. I guess it can break something else, and if you have feedback about it, I am interested in them.
In the meantime, I guess this is just the solution for anyone experiencing the same issue :)
Any advice on it? Interested in a PR?
I don't see any immediate issues with allowing plurals for non-textContent properties. If @fabi1cazenave has no objections, I would accept a PR.
Bump
I think that you'd better shoot him a mail if you want feedback from @fabi1cazenave .