Online-go.com: Vacation Day Accrued not displaying properly for 0 Days

Created on 23 Sep 2019  路  9Comments  路  Source: online-go/online-go.com

Describe the bug
September 22, 2019
[21:22]馃挅 KoBa 馃挅: Vacation Accrued: (Supporter) out of 60 Days
[21:22]馃挅 KoBa 馃挅: that thing only says "out of 60 days" if player has less than 1 day of vacation time available

Expected behavior
Display "0 Days" not ""

Screenshots
image

All 9 comments

Expected behavior
Display "0 Days" not ""

Or make it show "<1 days" instead "0 days" for the sake of clarity?

Or make it show "<1 days" instead "0 days" for the sake of clarity?

It'll depend on whether I need to hardcode it or just change a setting...

I can't tell exactly what this line does;

https://github.com/online-go/online-go.com/blob/7b8c2903efb8c41c0bde0bb2e695c4c2dc6e1a90/src/lib/translate.ts#L46

...but I suspect this is why the function returns "" instead of "0 Days"

any chance @GreenAsJade or @flovo could take a quick look at this for me? I'd rather not hardcode in a back door if I can avoid it.

Below is the whole function the above snippet came from

export function ngettext(singular, plural, count) {
    let key = singular + "" + plural;
    if (key in catalog) {
        if (catalog[key].length === 1) {
            count = 1;
        }

        return catalog[key][count === 1 ? 0 : 1];
    }
    return debug_wrap(count === 1 ? singular : plural);
}

As a first observation, this works for me:

    console.log("NGT DBG", ngettext("a", "b", 1));
    console.log("NGT DBG", ngettext("a", "b", 2));
    console.log("NGT DBG", ngettext("a", "b", 0));

NGT DBG a
NGT DBG b
NGT DBG b

grr... that's how anoek said it should work... so why isn't it then? :/

_() is just a gettext so I guess it must be inside interpolate() somewhere

... which strongly hints that vacation_time_accrued is not '0' but rather an empty string or some other thing by the time it hits ngettext.

IE check your code and assumptions before blaming the libraries ;)

hmm ok good call maybe math.round small/big doesn't = 0 like I assumed... time for some of my own console logs lol

Thanks @GreenAsJade

It turns out if(0) returns false, who knew 馃槢

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wizek picture Wizek  路  3Comments

benjaminpjones picture benjaminpjones  路  3Comments

ksafford picture ksafford  路  4Comments

roy7 picture roy7  路  5Comments

freysgodi picture freysgodi  路  4Comments