User talk:Equazcion/SidebarTranslate
List out of date
[edit]The list is currently out of date, probably since the introduction of WikiData. However, it seems we can do without the list alltogether, as the English strings are readily available in the title attribute of each link. — Edokter (talk) — 15:14, 3 November 2013 (UTC)
- Do you mean that you can use the title-attribute to replace the link-text? That sounds like it'd be awesome and efficient. :)
- Because I don't want to have to mouse-over every single link to find what I'm looking for... (Eg. Finnish at the Main Page is hard to find, if you don't know the language's name). –Quiddity (talk) 21:43, 3 November 2013 (UTC)
- That is what I mean. It could do with a rewrite anyway, and possibly turned into a gadget. — Edokter (talk) — 23:04, 3 November 2013 (UTC)
- I changed it per this suggestion. It seems to be working. If you see any glaring issues feel free to tweak. equazcion → 03:45, 4 Nov 2013 (UTC)
- I seem to have broken the google translate links though, working on that now. equazcion → 04:22, 4 Nov 2013 (UTC)
- I just finished a total rewrite and fixed the google translate links. Again if there are any issues let me know or feel free to fix 'em. equazcion → 05:51, 4 Nov 2013 (UTC)
- I also just added a sort feature. Finding particular languages was difficult since the language list wasn't sorted by the new names. equazcion → 06:58, 4 Nov 2013 (UTC)
- That is what I mean. It could do with a rewrite anyway, and possibly turned into a gadget. — Edokter (talk) — 23:04, 3 November 2013 (UTC)
Problems
[edit]The 2 Norwegian links, and the Serbian and the Serbian-Croatian links are not getting correctly translated (eg Main Page). I'm not sure what the problem is. Thanks :) –Quiddity (talk) 05:38, 4 November 2013 (UTC)
- Hmm, a reload seems to have fixed it. Never mind! –Quiddity (talk) 05:44, 4 November 2013 (UTC)
Second rewrite
[edit]I just sort of rewrote this again. The separate functions meant lots of redundant things were happening, including two separate iterations over the whole language list. I combined them and also combined several redundant jQuery selections. I think the code is a lot more compact and efficient this way. I tested these changes across several browsers and everything seems fine. Post if there are any issues. equazcion → 09:44, 9 Nov 2013 (UTC)
Discussion moved from VPR
[edit]- I support, though I'd suggest using something different then a dotted circle for the translate link, a double arrow perhaps or translate icon. Also,
addOnloadHook()
is pretty outdated as well; use$(document).ready()
instead. — Edokter (talk) — 22:37, 8 November 2013 (UTC)- Done both now. equazcion → 23:50, 8 Nov 2013 (UTC)
- A bullet doesn't cover it either, and it looks weird with a featered star. I'll go find (or create) an icon. — Edokter (talk) — 10:53, 9 November 2013 (UTC)
- Done both now. equazcion → 23:50, 8 Nov 2013 (UTC)
I moved the above here for continuation so as not to not muddy up the gadget proposal. As for icons, just make sure you test any prospects on long languages lists. I've been trying a bunch of options that seem nice but turn out odd or obtrusive when displayed miniaturized and repetitively. Plain bullets seemed in the end to be the most practical, but open to suggestions. equazcion → 11:05, 9 Nov 2013 (UTC)
- Possible "translate" icon? VanIsaacWS Vexcontribs 11:58, 9 November 2013 (UTC)
- Too wide. Trying something based on Google Translate icon. — Edokter (talk) — 12:10, 9 November 2013 (UTC)
- How's this? (Code here.) — Edokter (talk) — 12:33, 9 November 2013 (UTC)
- It looks relatively nice but I think it's still a bit in-your-face for constant display. I do like it though -- I made a simply toggle thing to show the translate links on the fly. Import User:Equazcion/SidebarTranslateBeta.js to try this and let me know what you think. equazcion → 17:41, 9 Nov 2013 (UTC)
- In this draft I also made the links open in new windows per the section below. equazcion → 17:44, 9 Nov 2013 (UTC)
- I don't like the toggle, it means an extra click. How about showing the G when hovering over the list? — Edokter (talk) — 19:38, 9 November 2013 (UTC)
Both events seem to trigger on mouse-in repeatedly, no matter what. Not sure why... equazcion → 20:05, 9 Nov 2013 (UTC)
- I always end up with the previous version of the beta script stuck in my cache... importScript has latency. — Edokter (talk) — 20:08, 9 November 2013 (UTC)
- I see the problem; .hover takes two functions. — Edokter (talk) — 20:08, 9 November 2013 (UTC)
- Nice, works now. I missed that. I have the cache problem often too, by the way. equazcion → 20:09, 9 Nov 2013 (UTC)
- I think this looks pretty nice. I'm gonna go ahead and replace the live version. equazcion → 20:13, 9 Nov 2013 (UTC)
- I am going to prettify the code a bit. — Edokter (talk) — 20:26, 9 November 2013 (UTC)
- Er, that tends to be a matter of preference... also keep in mind I combined lines into chains, even though they might not be quite as pretty, because those perform better. equazcion → 20:29, 9 Nov 2013 (UTC)
- Don't worry, it's only formatting, no functional changes. — Edokter (talk) — 20:37, 9 November 2013 (UTC)
- I'm saying that too is generally a matter of preference :) but go ahead on the beta and hopefully we'll agree. equazcion → 20:40, 9 Nov 2013 (UTC)
- Some of the extra spacing made things difficult to read (for me). I toned it down somewhat, and I also went back to a self-close A tag ( <a/> ) as it looks cleaner and there's no need for open and close tags there. I didn't test your version but the jQuery documentation suggests using self-closed tags in those instances. I left most of your changes though. equazcion → 21:18, 9 Nov 2013 (UTC)
- jQuery accepts any format, even
<a>
. I did reinstate the spaces in the array, as it creates a wrapping hell in the edit windows when narrow, which makes it totally unreadable. — Edokter (talk) — 21:31, 9 November 2013 (UTC)
- jQuery accepts any format, even
- Don't worry, it's only formatting, no functional changes. — Edokter (talk) — 20:37, 9 November 2013 (UTC)
- Er, that tends to be a matter of preference... also keep in mind I combined lines into chains, even though they might not be quite as pretty, because those perform better. equazcion → 20:29, 9 Nov 2013 (UTC)
- I am going to prettify the code a bit. — Edokter (talk) — 20:26, 9 November 2013 (UTC)
- I see the problem; .hover takes two functions. — Edokter (talk) — 20:08, 9 November 2013 (UTC)
External link
[edit]Should the translated page open in a new tab/window? — Edokter (talk) — 13:49, 9 November 2013 (UTC)
- Gave the link class="external", but is not caught by exlink gadget because it is fired too early. This may change when this does become a gadget. — Edokter (talk) — 14:05, 9 November 2013 (UTC)
- Yes they probably should open in a new window. I added target=_blank in my latest draft. equazcion → 17:45, 9 Nov 2013 (UTC)
- I notice that the link passed to Google is missing the 'http:'. I can see no fault in
.replace( 'https:', 'http:' )
. — Edokter (talk) — 21:28, 9 November 2013 (UTC)- Apparently mediawiki's interwiki links no longer include http(s), so it seems that replacement is no longer necessary. equazcion → 21:34, 9 Nov 2013 (UTC)
- I just realized that, then got an edit conflict. — Edokter (talk) — 21:36, 9 November 2013 (UTC)
- Apparently mediawiki's interwiki links no longer include http(s), so it seems that replacement is no longer necessary. equazcion → 21:34, 9 Nov 2013 (UTC)
Per-line animation
[edit]Per Edokter pointing out animation issues in long lists, I switched to a per-line animation for now. It works on long lists and actually seems a bit nicer. Plus it's fun to play with. Hopefully everyone else else likes it too but post if there are any issues. equazcion → 10:33, 10 Nov 2013 (UTC)
- Looks nice, but I predict it will ignite the fury of the anti-animation crowd, which can be an issue with turning it into a gadget. I'd say: keep it simple and lose the sliding. — Edokter (talk) — 11:11, 10 November 2013 (UTC)
- The sliding also increases the risk of long items wrapping (because the animation uses more space), causing the rest of the list to be pushed down. — Edokter (talk) — 11:15, 10 November 2013 (UTC)
- I like the inverse effect. But it makes the sliding all the more over the top... Can we please lose it? — Edokter (talk) — 21:50, 10 November 2013 (UTC)
- It seems apparent that you're not a fan of the slide effect, and as I said, if other people seem to have a problem with it, I'm happy to toss it (just as I'm fine going with whatever people generally think is best). For now I disagree and would like to keep it in, pending any further feedback. I'm not sure yet about the inverse effect and I'm trying it out for a while to see if it would be a good change for the live script. equazcion → 22:33, 10 Nov 2013 (UTC)
Misfires
[edit]I experience more and more misfires as time goes by, I don't know why. Perhaps importScript is malfunctioning (but the script is loaded in console) or is clashing with something else, collapsibleNav maybe... What is wrong? (Chrome 30 on XP) — Edokter (talk) — 21:39, 10 November 2013 (UTC)
- Every time the beta script is modified the script fails to load altogether (not even a cached older version loads). Not sure if that's what you're referring to. I need to do a hard refresh to get it loaded. I'm not sure why that's happening, but it's just a minor annoyance for us in development. equazcion → 21:43, 10 Nov 2013 (UTC)
- That sometimes helps, but a normal reload fails again. (Firefox as well.) — Edokter (talk) — 21:51, 10 November 2013 (UTC)
Untranslated languages
[edit]@Equazcion: Continuing on the discussion started at the pump, I had noted that after installing the script I was not seeing Belarusian, Venetian, Tarantino, Lombard, Lak and Buryat (Russia) as translated. Here is a screenshot showing this. The article the screenshot of the sidebar is taken from is United States. Cheers.--Fuhghettaboutit (talk) 05:45, 11 November 2013 (UTC)
- I am seeing those on the end as in the screenshot -- they would need to be given English names at WikiData, I believe, in order to show up here. I'm not sure where exactly to input those names within the WikiData site, but maybe Edokter has that info? In the meantime I'm curious about Belarusian though, because that one comes up as its English name for me. Are you not seeing "Belarusian" in the list? equazcion → 05:54, 11 Nov 2013 (UTC)
- Sorry, I know next to nothing about Wikidata. Those that are not translated do not have the English language name in its title attribute. While Беларуская does have Bellarusian, Беларуская (тарашкевіца) (be-x-old) does not. It could be Wikidata, or the project itself is no configured properly. — Edokter (talk) — 08:05, 11 November 2013 (UTC)
- Ah, my mistake, it's Belarusian (Taraškievica) I am not seeing, as shown in the screenshot, not Belarusian.--Fuhghettaboutit (talk) 09:16, 11 November 2013 (UTC)
- Apparently WikiData doesn't handle this. Based on bugzilla:56904, I've gone ahead and hard-coded these languages that could continue to go missing long-term. Bypass your cache if you're still seeing the original language names for these. equazcion → 13:34, 11 Nov 2013 (UTC)
- Ah, my mistake, it's Belarusian (Taraškievica) I am not seeing, as shown in the screenshot, not Belarusian.--Fuhghettaboutit (talk) 09:16, 11 November 2013 (UTC)
- Sorry, I know next to nothing about Wikidata. Those that are not translated do not have the English language name in its title attribute. While Беларуская does have Bellarusian, Беларуская (тарашкевіца) (be-x-old) does not. It could be Wikidata, or the project itself is no configured properly. — Edokter (talk) — 08:05, 11 November 2013 (UTC)
Gadget time
[edit]I think this functionality would be suitable as a gadget. John Vandenberg (chat) 12:48, 19 November 2013 (UTC)
- Proposal is ongoing here: Wikipedia:Village_pump_(proposals)#Make_SidebarTranslate_into_a_gadget equazcion → 18:34, 19 Nov 2013 (UTC)
Translation of this gadget
[edit]Has this gadget already been translated to other languages? (I'd like it in German...) --Neitram (talk) 18:50, 22 November 2013 (UTC)
- Honestly I don't know. I wouldn't be able to do that myself -- but this isn't actually a gadget yet. It's just a "script" for now, but once it becomes a gadget (which I think may be soon) it's likely to get more attention and possibly get translated. Do you mean for the German Wikipedia? Because you're probably better off asking there. equazcion → 20:18, 22 Nov 2013 (UTC)
- Thanks. I inquired here; it seems we have an old script at [1] (no longer maintained), and APPER wrote a one-line script for me at [2] which works; though it does not resort the list. But I'm happy with it until your gadget will become availabe in german wikipedia. --Neitram (talk) 10:41, 4 December 2013 (UTC)
- Taking another look it kinda looks like you could just import the script from this wiki. If you want to try it you can put this in your common.js at the German Wikipedia instead:
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Equazcion/SidebarTranslate.js&action=raw&ctype=text/javascript');
- I'm not sure if the Google Translate links will work, and the few languages that needed to be hard-coded may not get translated. But nearly everything else should work including the sort feature. equazcion → 17:19, 4 Dec 2013 (UTC)
- That works great, thanks a lot! The Google Translate links do work, but they translate to English. Which is fine for me. Only some languages do not appear properly in German, including Cantonese, Chinese (Min Nan), Classical Chinese, Egyptian Spoken Arabic, Fiji Hindi, Low Saxon (Netherlands), Simple English, Venetian, and Western Punjabi. --Neitram (talk) 21:36, 2 January 2014 (UTC)
- Thanks. I inquired here; it seems we have an old script at [1] (no longer maintained), and APPER wrote a one-line script for me at [2] which works; though it does not resort the list. But I'm happy with it until your gadget will become availabe in german wikipedia. --Neitram (talk) 10:41, 4 December 2013 (UTC)
Main page
[edit]It seems the gadget no longer triggers on the main page, or any other page using {{Main Page interwikis}}. It used to. — Edokter (talk) — 11:42, 8 December 2013 (UTC)
- I found the problem; the interwikis on the main page do not contain the article names in the title attributes, which makes the regex fail. On any article (ie. Moon), the title attribute contains
Luna – Spanish
, but on the main page, it only containsSpanish
. Can you fix the regex? — Edokter (talk) — 19:02, 15 December 2013 (UTC)
- Seems to work as advertised. Gadget updated. — Edokter (talk) — 19:12, 16 December 2013 (UTC)
"Original language mame"
[edit]A handy feature was seeing the actual translated term for the artcle title, which is now replaced with the above. It would be more intuitive to just swap the language names and retain the article title, so the title attribute "Luna – Spanish" becomes "Luna – Español". That also negates any i18n requirements. — Edokter (talk) — 19:16, 16 December 2013 (UTC)
- I just changed the beta script to do this, however I'm not sure if it's all that intuitive, in terms of making the language list more useful for English speakers. It's difficult for English speakers to determine which is the original language name and which is the article name. It might be good to keep some sort of labeling in the tooltip that indicates which is which. equazcion → 19:37, 16 Dec 2013 (UTC)
- I doubt many English speakers look that much at the tooltips anyway, except when they want to, and then only look for specific languages. So I don't think that's too much of a problem. — Edokter (talk) — 19:48, 16 December 2013 (UTC)
- I'll update the gadget. I don't anticipate any complaints. — Edokter (talk) — 11:57, 19 December 2013 (UTC)
- I doubt many English speakers look that much at the tooltips anyway, except when they want to, and then only look for specific languages. So I don't think that's too much of a problem. — Edokter (talk) — 19:48, 16 December 2013 (UTC)
IE8
[edit]Script fails in IE8; list is empty and the main div remains hidden. — Edokter (talk) — 12:59, 22 December 2013 (UTC)
- Ping @Equazcion:. — Edokter (talk) — 16:41, 4 February 2014 (UTC)
- Going back to the beta, IE finally shows an error: Line 39 - Object doesn't support this property or method. Line 39 is:
var unsup = ( googleSupported.indexOf(langMatches[2]) < 0 ) ? '#FA8540' : '#4085FA';
- — Edokter (talk) — 11:35, 7 February 2014 (UTC)
ULS Compact language links (Beta Feature) - bug - undefined
[edit]If I enable the new BetaFeature "Compact language links", along with this gadget, there's a breakage on any page that has more than 10(?) languages. screenshot. Instead of a list of languages, I just see "undefined" (which links to undefined! :)
I'm not sure if I should also mention this at mw:Talk:Universal Language Selector/Design/Interlanguage links, or who is best placed to fix it, so I'll just leave it here, and let you triage. HTH. –Quiddity (talk) 20:29, 15 March 2014 (UTC)
Love it!
[edit]I love this feature! Sofia Koutsouveli (talk) 14:55, 21 March 2014 (UTC)
Titles with en dash
[edit]If a foreign language article contains an en dash then the title part after the en dash is displayed on the link before an en dash and the language name. For example on 2014 Australian Open – Men's Singles I see:
Another example: The Double (2011 film) displays Eiskaltes Duell – German
Tested in Firefox, IE, Opera, Safari on Windows Vista. PrimeHunter (talk) 22:18, 12 May 2014 (UTC)
- Still happening (or happening again?) as of this posting. See On Air – Live at the BBC Volume 2, where the entries for French, Italian, Russian, and Spanish (whose articles don't contain an en dash) look fine, but those for Finnish, Georgian, German, and Norwegian (whose articles contain an en dash) all show "Live at the BBC Volume 2" before the language name. (This is on FF 31.3.0 for Linux. Oh, and I'm using the gadget.) - dcljr (talk) 01:22, 27 January 2016 (UTC)
- Can this be fixed simply by making the change:
var langReg = /(.*? – )?(.*)/;
→var langReg = /(.*? – )?([^–]*)/;
- to the gadget code? - dcljr (talk) 02:44, 27 January 2016 (UTC)
- Can this be fixed simply by making the change:
- The problem also occurs on Chrome, FWIW, I've encountered it on German Revolution of 1918–19 with the Bulgarian article bg:Германска_революция_(1918_–_1919). It's not just the presence of an en dash but an en dash followed by an underscore (a space) that's the issue. Could we get this fixed Equazcion? Alcherin (talk) 17:22, 20 May 2017 (UTC)
Use with Gadget?
[edit]Is this, should this, be enabled along with the Gadget?
Shouldn't/Doesn't the gadget duplicate the functions of this script and, therefore, obviate the need to run this script?
However, it is only when both are enabled that the orange text "Google Translate..." appears. --CmdrDan (talk) 23:45, 25 May 2014 (UTC)
- You should not use both at the same time. Use either the user script or the gadget. The user script is used for testing before updates are moved to the gadget. — Edokter (talk) — 11:23, 26 May 2014 (UTC)