You are here

public static function PersianLanguageDiscovery::isPersian in Persian Date for Drupal 8 8.4

Same name and namespace in other branches
  1. 8 src/PersianLanguageDiscovery.php \Drupal\persian_date\PersianLanguageDiscovery::isPersian()

Return value

bool

13 calls to PersianLanguageDiscovery::isPersian()
BlockContentTranslationHandler::entityFormEntityBuild in src/TranslationHandler/BlockContentTranslationHandler.php
Entity builder method.
CommentTranslationHandler::entityFormEntityBuild in src/TranslationHandler/CommentTranslationHandler.php
Entity builder method.
ContentTranslationHandler::entityFormEntityBuild in src/TranslationHandler/ContentTranslationHandler.php
Entity builder method.
NodeTranslationHandler::entityFormEntityBuild in src/TranslationHandler/NodeTranslationHandler.php
Entity builder method.
PersianDateFormatter::format in src/Service/Formatter/PersianDateFormatter.php
Formats a date, using a date type or a custom date format string.

... See full list

File

src/PersianLanguageDiscovery.php, line 19

Class

PersianLanguageDiscovery

Namespace

Drupal\persian_date

Code

public static function isPersian() {
  if (self::$isPersian === null) {

    // only convert farsi on multi lingual sites
    $isMultiLingual = count(\Drupal::languageManager()
      ->getLanguages()) > 1;
    if ($isMultiLingual) {
      $language = \Drupal::languageManager()
        ->getCurrentLanguage()
        ->getId();
      if ($language !== 'fa') {
        self::$isPersian = false;
      }
      else {
        self::$isPersian = true;
      }
    }
    else {
      self::$isPersian = true;
    }
  }
  return self::$isPersian;
}