RTL on a multilanguage site

Im working on a site that has multi language, one of them being Arabic. This means reading from right to left. The problem is, after switching to Arabic and the page NOT having an Arabic version available, im still getting the rtl class being applied. How can i get it to add the class only if Arabic content exists, and not in the fall back language? Currently its running english from right to left :frowning:

Check if the content file exists:

if($page->content($langCode)->exists()) {
  // add rtl class

Ah ha! Thanks… this did it…

$dir = '';
if($page->content('ar')->exists()) {
  $dir = $site->language()->direction();

<html class="<?= $dir ?>">

@anon77445132 My full tag looks like this, I just shortned it for brevity on the forum:

<html lang="<?= site()->language() ? site()->language()->code() : 'en' ?>" prefix="<?= $prefix ?>" class="<?= $dir ?>">
1 Like