Page MenuHomePhabricator

Move the device language detection code to utils
Closed, ResolvedPublic

Description

Currently we use a snippet [1] to detect the device language for event logging purposes. The new language overlay proposed at T123384 also needs this code so that the primary device language can be shown in the preferred languages section. In my current WIP patch I decided not to extend the existing language overlay to create the new one because the overlay templates are completely different and it would be unfair for the users of the new overlay to download the old template too. Since inheriting is out of question, we need a place to put that language detection code. I suggested we do it in utils.js [2]. @Jdlrobson thinks it's not a good idea. What do others think?

[1] https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/resources/skins.minerva.scripts/init.js#L128
[2] https://gerrit.wikimedia.org/r/#/c/268114/

Event Timeline

bmansurov raised the priority of this task from to Needs Triage.
bmansurov updated the task description. (Show Details)
bmansurov added a project: MobileFrontend.

I hadn't quite clicked that we already had this code in skins.minerva.scripts/init.js so I guess my point about bloating JS is irrelevant.

If the use case is for only the language overlay
why not just pass it in as an argument to the LanguageOverlay in the same file.

overlayManager.add( /^\/languages$/, function () {

Applying YAGNI, we should never create generic methods until we are sure we need them due to code duplication.

bmansurov claimed this task.

Fair enough.