Page MenuHomePhabricator

[Failing hack] translate-invalidlanguage: Language code en-foo is not valid
Closed, ResolvedPublic

Description

@Nikerabbit, a while back, I had an issue working on a gadget that had to get messages from a translatable page. Something was failing (I can't remember) and you proposed to me a quick hack to fix it, see code below:

userLang = mw.config.get( 'wgUserLanguage' );
 if ( userLang === 'en' ) {
     userLang = 'en-foo'; // quick hack fix
 }

Today, that hack was the end of me, if not for @Krinkle (Thank you Timo) that saved the day, my mind would have been somewhere else, literally.

Is this hack still needed or has it been removed completely. I'll like to understand the state of things so if someone else is doing this, they can fix it too.

Also, I just tagged Translate extension, not sure which other projects to tag. Thanks!

Event Timeline

For context, this was changed due T279252: TUX should not use a wrong uselang value as fallback. There are still language codes that fall back to English which are unlikely to be translated, like simple.

A proper fix would degrade this error to warning and let Special:Translate handle the warning in the same way, or to provide and use a different api for fetching the strings.

@Nikerabbit moved this task from Backlog to cross projects on the MediaWiki-extensions-Translate board.

Which cross project? Please add a tag indicating what project do you want to fix this, otherwise it won’t be found by the appropriate people. (Or fix it in Translate, but then it probably doesn’t belong in this column.)

I don't think there are tags for individual gadgets for the proposed workaround.

But you are right, maybe this column is not the best place for this. Then again, this task should be reframed from the point of view of Translate if it is to be fixed there.

Gadgets are usually not tracked in Phabricator (there are a few exceptions, though, like Navigation-Popups-Gadget or Wikidata-Gadgets), so if you don’t plan to fix it in Translate, I think it should be declined (and probably reported at m:Tech so that Meta’s interface admins can take care of it). If, however, you do plan to fix it in Translate, it should be in another column.

A fix would be something similar to rETRA21b95f594226: Fix broken Special:PageMigration due to error from MessageCollection API and making sure there is no regression in Special:Translate or Special:TranslationStash. But I am not sure it's needed.

FYI @xSavitar can you try using en as the language again? It should work now.

@Nikerabbit, I think we've fixed this a while ago already. The task can be resolved :)

Thank you very much <3

Nikerabbit claimed this task.

Thanks for the info. Marking as resolved then.