There is a list of language codes in SiteDisplay.js, starting around line 195:
// Get RTL/LTR direction for the site. We can't use String.prototype.startsWith, since // that is unavailable in IE11, and doesn't take multiple values anyway. Use // String.prototype.match with a list of the language codes that should be RTL // this.siteID is based on the URL form of the wiki, and we assume that wikis that are // meant to be RTL are in the form `⧼rtl language code⧽.*`, and any URL that does not // match this is for an LTR wiki. See T274602 and T274313 const isRTL = this.siteID.match( /^(ar|azb|ckb|dv|fa|glk|he|ks|lrc|mzn|nqo|pnb|ps|sd|ug|ur|yi)_/ ); // mw-content-ltr and -rtl classes are not enough to ensure that the text is formatted // in the correct direction, so add a manual direction attribute. See T287649 // We still add those classes because they are also used by jQuery.makeCollapsible // to know if the collapse button should be on the right or left. this.$feedDiv = $( '<div>' ) .attr( 'id', 'ext-globalwatchlist-feed-site-' + this.siteID ) .attr( 'dir', isRTL ? 'rtl' : 'ltr' ) .addClass( 'ext-globalwatchlist-feed-site' ) .addClass( isRTL ? 'mw-content-rtl' : 'mw-content-ltr' ) .append( headerTemplate.render( headerParams ), $content );
Using a hardcoded list that may change over time has always been a poor solution, but at the time, we weren’t able to find a better approach. Now there may be a more reliable one:
- When saving user settings, get the list of wikis they have chosen to watch.
- Get a variable $wgSiteMatrixSites provided for Extension:SiteMatrix to retrieve site information.
- If isn't defined, or doesn't include all the needed info, use the existing hardcoded list as a backup.
- Otherwise, extract the direction (RTL/LTR) for each selected wiki and store it alongside the corresponding wiki URL in the user’s settings.
- Replace the existing hardcoded list with logic that checks the stored directions in the user settings, loading each site’s language direction dynamically.
