Topic on Talk:Directionality support

Accessing dir in JavaScript

3
Samwilson (talkcontribs)

What is the recommended way to retrieve directionality client-side? It doesn't look like mw.language has anything.

Amire80 (talkcontribs)

If the wiki has the ULS extension installed, you can do $.uls.data.getDir( 'xy' ) (where xy is the language code).

Samwilson (talkcontribs)

@Amire80: Ah, good to know, thanks! I wonder if something like this should be added to core.

From what I know at the moment, it looks like the way to get it without ULS is to inspect the DOM and find the dir attribute of a .mw-content-ltr or .mw-content-ltr element (which is a bit weird, considering that if one was trying to make that a simpler query they'd have to already know the direction!).

Reply to "Accessing dir in JavaScript"