You are here

CurrentLangname.php in More Global Variables 8

File

src/Plugin/GlobalVariable/CurrentLangname.php
View source
<?php

namespace Drupal\mgv\Plugin\GlobalVariable;

use Drupal\mgv\Plugin\GlobalVariable;

/**
 * Class CurrentLangname.
 *
 * @package Drupal\mgv\Plugin\GlobalVariable
 *
 * @Mgv(
 *   id = "current_langname",
 * );
 */
class CurrentLangname extends GlobalVariable {

  /**
   * {@inheritdoc}
   */
  public function getValue() {

    // Print the current langname, e.g. 'english' or 'french'.
    return \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getName();
  }

}

Classes

Namesort descending Description
CurrentLangname Class CurrentLangname.