Page MenuHomePhabricator

Adapt better to invalid language codes
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
Alien333
May 8 2025, 7:58 PM
Referenced Files
F59804763: 2.jpg
May 9 2025, 6:18 AM
F59804695: 1.jpg
May 9 2025, 6:18 AM

Description

Reported by @1AmNobody24 in T393520#10804424:

I can't see the Year counts and Month counts charts, with the debugger showing `Uncaught RangeError: invalid language tag: "de""

That is an invalid language code, but we should be saying that clearly.

Event Timeline

Alien333 triaged this task as Medium priority.May 8 2025, 8:00 PM

@1AmNobody24 : As I said there, I cannot replicate this error at these URLs. I'd appreciate if you could give a bit more details, including notably your browser and browser version; the entire console log; the specific erroring urls (if distinct from those two); and the traceback of the error (where it occurs; in most consoles you can get this).

Browser is Firefox
Version 139.0b5
It has a weird way to replicate. First I open https://xtools.wmcloud.org/ec/de.wikipedia/Gripweed?uselang=de%22 then I open https://xtools.wmcloud.org/ec-yearcounts/en.wikipedia.org/1AmNobody24.
Which now looks like

1.jpg (901×1 px, 207 KB)

With the console being
2.jpg (285×1 px, 95 KB)

This happens not only on the counts pages, but also on the full statistics page.

Alien333 changed the task status from Open to In Progress.EditedMay 9 2025, 12:20 PM
Alien333 claimed this task.
Alien333 moved this task from Edit Counter to General / other on the XTools board.
Alien333 changed the subtype of this task from "Task" to "Bug Report".

Well, you've entered yourself the uselang de" (url-encoded, de%22; and html-encoded, de"). That seems to be pretty straightforwardly the cause of this issue, as de" is not a valid language code. If you look closely, it also happens at gripweed's counter.

It's normal for this to happen on the parent page too; that essentially transcludes the subpages.

It happens in the charts when we try to $.i18n the labels. I suppose that twig messages have better incorporated fallbacks. I'm pretty sure we're using $.i18n in other places too.

It's also normal that it keeps happening on other pages, because XTools remembers your last language.

That being said, we could try to adapt better, which would notably mean falling back to en earlier for language codes we don't have a file for.

PR #527.

Alien333 renamed this task from Possible language code mishandling in yearmonth charts to Adapt better to invalid language codes.Jul 15 2025, 5:20 PM
Alien333 updated the task description. (Show Details)
Alien333 moved this task from General / other to Complete on the XTools board.

Done better by Musikanimal in #571.