indico / indico

Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.
https://getindico.io
MIT License
1.7k stars 412 forks source link

Handle plural case of translations correctly #4613

Open DirkHoffmann opened 3 years ago

DirkHoffmann commented 3 years ago

This should be "pluralised" correctly: https://github.com/indico/indico/blob/b11b9c9c000a8bf8949fa704ee72f45bf17c1900/indico/web/client/js/legacy/libs/timetable/Management.js#L624-L629 I don't know how to do it, and even less how to test it duely. May I leave it to you, @ThiefMaster?

And this is in the same file, just a little bit below: https://github.com/indico/indico/blob/b11b9c9c000a8bf8949fa704ee72f45bf17c1900/indico/web/client/js/legacy/libs/timetable/Management.js#L635-L639

Probably something like

if (h > 0) {
   intervalExplanationText += $T
      .ngettext('{0} hour ', "{0} hours ", h)
      .format(h);  
ThiefMaster commented 3 years ago

I know it's awful, but I don't think we're going to fix this legacy code (contributions welcome though).

We want to rewrite the timetable in react - hopefully next year - and would then replace this mess with something proper.

FWIW, what we need in this particular case is a util that converts a duration to a human-friendly translatable string. And then translate ''Entries will be separated by gaps of {duration}" with duration being the output of that util.