Page MenuHomePhabricator

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.

Event Timeline

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).

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. 😊

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

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

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>