MediaWiki talk:Gadget-SidebarTranslate.js

Compact Language Links
Hi Equazcion, Legoktm, Edokter,

Apparently this gadget overrides the Compact Language Links beta feature when both are enabled.

Would any of you mind trying making them work together?

Thanks! --Amir E. Aharoni (talk) 12:38, 16 May 2016 (UTC)
 * OK, so there's a message here at the top that asks to discuss changes in the talk page before changes, which is what I did back in May, but there's no reply :/
 * Some things in this gadget break when used together with the Compact Language Links beta feature, and I'm going to attempt to fix them myself.
 * Initially, I don't plan to make any functional changes, but only to fix the JS errors that are caused by completely rewriting the link elements. They should rather be kept as-is, with the  attribute, even though the name is written in English, because this attribute is used by other scripts. The language name in English should be inserted in its own   tag with the   attribute.
 * Mentioning Equazcion, Legoktm and Edokter again in the hope that somebody will notice... --Amir E. Aharoni (talk) 09:42, 10 September 2016 (UTC)
 * I'm working on my version in a "branch" of sorts at User:Amire80/Gadget-SidebarTranslate.js. --Amir E. Aharoni (talk) 11:35, 10 September 2016 (UTC)
 * TL;DR: Please review User:Amire80/Gadget-SidebarTranslate.js. It should resolve all the issues with Compact Language Links, and it fixes several other bugs along the way. If it works for you, please replace the gadget code with that version, but remove the style (marked with XXX).
 * OK, so here's my report of working on this over the weekend:
 * The issue with Compact Language Links is that it produces a JS error: "Cannot read property 'toLowerCase' of null TypeError: Cannot read property 'toLowerCase' of null". The message is different in Firefox, but the reason for it is the same: It is trying to apply a toLowerCase method on the lang attribute, which doesn't exist on the Google Translate link. A full solution for this is suggested in https://phabricator.wikimedia.org/T135378 . Until it's resolved, I worked around it by applying a semi-invalid "tokipona" language code to the Google Translate links. It's a very weird and undesirable hack, but it resolves the issue for now.
 * Some other issues that I resolved:
 * The code is refreshed according to the Wikimedia JavaScript coding conventions: whitespace, $ signs for jQuery variables, triple-equal signs.
 * The issue with the be-x-old language is resolved. Its name had an invisible control character. It is now properly handled by hardLangs.
 * The Google Translate link is now in a separate variable, which is more readable and easier to manipulate.
 * The lang and style attributes are not removed from the list items. It was mostly unnecessary and it broke ULS. The English language name is now in a separate element with the "en" lang. It's also a bit weird, but gadgets are weird to begin with :)
 * Bhojpuri and South Azerbaijani are added to hardLangs.
 * With all these changes applied, the gadget works together with Compact Language Links enabled, shows all the language names in English and doesn't produce JS errors.
 * Since this affects hundreds of users, it would be nice if somebody could review this. If it looks OK, please replace the gadget code with the version at User:Amire80/Gadget-SidebarTranslate.js, but remove the line with XXX, which applies a style, because when this code is used as a gadget that line is unnecessary.
 * Thank you. --Amir E. Aharoni (talk) 09:55, 11 September 2016 (UTC)
 * I removed the extra-weird "tokipona" hack, because it didn't work well anyway and replaced it with a CSS solution and using the standard "en" language code. It's still a hack, but a relatively cleaner one. Merging https://gerrit.wikimedia.org/r/#/c/309731/ is still a cleaner solution. --Amir E. Aharoni (talk) 09:41, 12 September 2016 (UTC)

... Aaaaand, because I'm impatient, I just applied the changes :)

Nothing seems to be broken, but if something does break, please revert, accept my apology, and let me know. Thanks!

These people may be curious: Equazcion, Legoktm, Edokter, Runab WMF, Whatamidoing (WMF), Elitre (WMF). --Amir E. Aharoni (talk) 11:06, 14 September 2016 (UTC)

Titles with en dash
The bug reported at User talk:Equazcion/SidebarTranslate is still in the gadget. PrimeHunter (talk) 00:34, 5 June 2017 (UTC)

Interface-protected edit request on 10 February 2020
For background, see the previous section and T244715

Please change the value of LangReg to /(.* – )?(.*)/ (my proposed fix) or /(.*? – )?([^–]*)/ (Dcljr's proposed fix in 2016). I do not know which is more suitable. GZWDer (talk) 15:31, 10 February 2020 (UTC)
 * @GZWDer: I've implemented your fix (I don't think Dcljr's works). Thanks, Writ Keeper &#9863;&#9812; 18:57, 10 February 2020 (UTC)

Bug: Need to remove lang tags
Hi, I'd like to report a bug that I've noticed using Vector 2022. In the new skin, each of the links includes a 'lang' attribute indicating the language of the link's destination (e.g. the HTML for a link to Chinese Wikipedia looks like this: ).

Because this gadget changes all the links to be in English, the 'lang' attribute is no longer correct and needs to be stripped out. This incorrect use causes display issues, as some browsers use the 'lang' attribute to decide which font to use. I've included a screenshot showing how the words "Chinese" and "Korean" are in a different font to the rest of the page. This is because my browser (Firefox 109.0 on Ubuntu 22.04.1) uses a different font to render Chinese and Korean text, and the 'lang' attribute is causing my browser to incorrectly believe those words are written in Chinese and Korean respectively. Thanks, Iago Qnsi  (User talk:IagoQnsi) 23:57, 21 January 2023 (UTC)

Bug: displaying repeated language links
This gadget displaying repeated language links of 1 language KuldeepBurjBhalaike (Talk) 09:44, 11 July 2023 (UTC)