l10n_server-2.x-dev/l10n_remote/src/TranslationContribution.php

l10n_remote/src/TranslationContribution.php
<?php

namespace Drupal\l10n_remote;

/**
 * Translation contribution.
 *
 * This class represents translation conributions.
 */
class TranslationContribution {

  /**
   * The translation data. Typically from incoming request.
   *
   * @var array
   *   Translation data.
   */
  protected array $data;

  /**
   * Contructs a TranslationContribution object.
   *
   * @param array $data
   *   Translation data.
   */
  public function __construct(array $data) {
    $this->data = $data;
  }

  /**
   * Get the translation langcode.
   *
   * @return string
   *   The langcode.
   */
  public function getLangcode(): string {
    return $this->data['langcode'];
  }

  /**
   * Get the translation source string.
   *
   * @return string
   *   The source string.
   */
  public function getSource(): string {
    return $this->data['source'];
  }

  /**
   * Get the translation string.
   *
   * @return string
   *   The translation.
   */
  public function getTranslation(): string {
    return $this->data['translation'];
  }

  /**
   * Get the context of the source string.
   *
   * @return string|null
   *   The context.
   */
  public function getContext(): ?string {
    return !empty($data['context']) ? $data['context'] : NULL;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc