Version 1
[yaffs-website] / web / core / modules / language / src / Plugin / LanguageNegotiation / LanguageNegotiationUI.php
diff --git a/web/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php b/web/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php
new file mode 100644 (file)
index 0000000..cf699c3
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\language\Plugin\LanguageNegotiation;
+
+use Drupal\language\LanguageNegotiationMethodBase;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Identifies the language from the interface text language selected for page.
+ *
+ * @LanguageNegotiation(
+ *   id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI::METHOD_ID,
+ *   types = {Drupal\Core\Language\LanguageInterface::TYPE_CONTENT},
+ *   weight = 9,
+ *   name = @Translation("Interface"),
+ *   description = @Translation("Use the detected interface language.")
+ * )
+ */
+class LanguageNegotiationUI extends LanguageNegotiationMethodBase {
+
+  /**
+   * The language negotiation method id.
+   */
+  const METHOD_ID = 'language-interface';
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLangcode(Request $request = NULL) {
+    return $this->languageManager ? $this->languageManager->getCurrentLanguage()->getId() : NULL;
+  }
+
+}