languages tag should have lang and/or hreflang attributes in links
Closed, ResolvedPublic


The links to individual languages in the <languages /> tag from the page translation feature should have lang and or hreflang attributes. This would make it easier to e.g. apply CSS to certain languages, for example to highlight the official languages used on a wiki, or in user stylesheets to apply custom styling to languages of the user's choosing. The same should also apply to the span tag for the current language.

One practical usecase where I could've used this: this diff on, which is a hack until T156589 is fixed.

jhsoby created this task.Feb 7 2017, 11:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 7 2017, 11:11 PM
Nikerabbit triaged this task as Normal priority.Feb 8 2017, 7:23 AM
Nikerabbit added a project: Easy.
Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptFeb 8 2017, 7:23 AM

hreflang is only valid for link elements. lang can be used, because we display autonyms as link text (it doesn't not imply anything about the link target though).

jhsoby added a comment.Feb 8 2017, 9:19 AM

Yes, that's true. For my usecase even a class attribute would suffice though - all I want is the ability to (easily) target a specific language. 😊

Omidfi added a subscriber: Omidfi.Oct 1 2017, 5:41 AM

I'd love to help with this but couldn't figure out exactly at what page this is hapenning.

Restricted Application added subscribers: jeblad, Danmichaelo. · View Herald TranscriptOct 1 2017, 5:41 AM
Omidfi claimed this task.Oct 1 2017, 7:57 AM

Any translatable page with <languages /> tag which has some translations into different languages.

Omidfi added a comment.EditedOct 4 2017, 6:14 PM

Thanks, I can reproduce now.

Sesms like it's from this file:


However no matter how I make changes there, I don't see the effects on the page.

For example on Line 264

$classes[] = 'mw-pt-languages-ui';

Which outputs:

<span class="mw-pt-languages-ui mw-pt-languages-selected mw-pt-progress mw-pt-progress--complete">English</span>

If I change it to

$classes[] = 'lorem-ipsum';

I expect to find a class called lorem-ipsum on that page. But nope!

Is there any caching somewhere? I'm using the mediawiki vagrant, and it has been working great so far.

Change 382436 had a related patch set uploaded (by Omidfi; owner: Omidfi):
[mediawiki/extensions/Translate@master] Add lang attribute to languages in <languages>

Change 382436 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Add lang attribute to languages in <languages>

Nikerabbit closed this task as Resolved.