You are here

public static function PersianDateHelper::monthNamesAbbr in Persian Date for Drupal 8 8.4

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

Constructs a translated array of month name abbreviations

Parameters

bool $required: (optional) If FALSE, the returned array will include a blank value. Defaults to FALSE.

Return value

array An array of month abbreviations.

Overrides DateHelper::monthNamesAbbr

File

src/PersianDateHelper.php, line 96

Class

PersianDateHelper

Namespace

Drupal\persian_date

Code

public static function monthNamesAbbr($required = FALSE) {

  // Force the key to use the correct month value, rather than
  // starting with zero.
  $monthnames = [
    1 => t('فروردین', [], [
      'context' => 'Abbreviated month name',
    ]),
    2 => t('اردیبهشت', [], [
      'context' => 'Abbreviated month name',
    ]),
    3 => t('خرداد', [], [
      'context' => 'Abbreviated month name',
    ]),
    4 => t('تیر', [], [
      'context' => 'Abbreviated month name',
    ]),
    5 => t('مرداد', [], [
      'context' => 'Abbreviated month name',
    ]),
    6 => t('شهریور', [], [
      'context' => 'Abbreviated month name',
    ]),
    7 => t('مهر', [], [
      'context' => 'Abbreviated month name',
    ]),
    8 => t('آبان', [], [
      'context' => 'Abbreviated month name',
    ]),
    9 => t('آذر', [], [
      'context' => 'Abbreviated month name',
    ]),
    10 => t('دی', [], [
      'context' => 'Abbreviated month name',
    ]),
    11 => t('بهمن', [], [
      'context' => 'Abbreviated month name',
    ]),
    12 => t('اسفند', [], [
      'context' => 'Abbreviated month name',
    ]),
  ];
  $none = [
    '' => '',
  ];
  return !$required ? $none + $monthnames : $monthnames;
}