当前位置: 首页>>代码示例>>PHP>>正文


PHP LanguageManagerInterface::isMultilingual方法代码示例

本文整理汇总了PHP中Drupal\Core\Language\LanguageManagerInterface::isMultilingual方法的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManagerInterface::isMultilingual方法的具体用法?PHP LanguageManagerInterface::isMultilingual怎么用?PHP LanguageManagerInterface::isMultilingual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Language\LanguageManagerInterface的用法示例。


在下文中一共展示了LanguageManagerInterface::isMultilingual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: routes

 /**
  * Returns an array of route objects.
  *
  * @return \Symfony\Component\Routing\Route[]
  *   An array of route objects.
  */
 public function routes()
 {
     $routes = array();
     $is_multilingual = $this->languageManager->isMultilingual();
     /* @var $search_api_page \Drupal\search_api_page\SearchApiPageInterface */
     foreach ($this->entityManager->getStorage('search_api_page')->loadMultiple() as $search_api_page) {
         // Default path.
         $default_path = $search_api_page->getPath();
         // Loop over all languages so we can get the translated path (if any).
         foreach ($this->languageManager->getLanguages() as $language) {
             // Check if we are multilingual or not.
             if ($is_multilingual) {
                 $path = $this->languageManager->getLanguageConfigOverride($language->getId(), 'search_api_page.search_api_page.' . $search_api_page->id())->get('path');
             }
             if (empty($path)) {
                 $path = $default_path;
             }
             $args = ['_controller' => 'Drupal\\search_api_page\\Controller\\SearchApiPageController::page', 'search_api_page_name' => $search_api_page->id()];
             // Use clean urls or not.
             if ($search_api_page->getCleanUrl()) {
                 $path .= '/{keys}';
                 $args['keys'] = '';
             }
             $routes['search_api_page.' . $language->getId() . '.' . $search_api_page->id()] = new Route($path, $args, array('_permission' => 'view search api pages'));
         }
     }
     return $routes;
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:34,代码来源:SearchApiPageRoutes.php

示例2: query

 /**
  * {@inheritdoc}
  */
 public function query()
 {
     // Don't filter by language in case the site is not multilingual, because
     // there is no point in doing so.
     if (!$this->languageManager->isMultilingual()) {
         return;
     }
     parent::query();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:12,代码来源:LanguageFilter.php

示例3: importAll

 /**
  * {@inheritdoc}
  */
 public function importAll()
 {
     $address_formats = $this->externalRepository->getAll();
     $country_codes = array_keys($address_formats);
     // It's nicer API-wise to just pass the country codes.
     // The external repository maintains a static cache, so the repeated ->get()
     // calls have minimal performance impact.
     $this->importEntities($country_codes);
     if ($this->languageManager->isMultilingual()) {
         $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
         $this->importTranslations(array_keys($languages));
     }
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:16,代码来源:AddressFormatImporter.php

示例4: buildConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     if ($this->languageManager->isMultilingual()) {
         // Fetch languages.
         $languages = $this->languageManager->getLanguages();
         $langcodes_options = array();
         foreach ($languages as $language) {
             $langcodes_options[$language->getId()] = $language->getName();
         }
         $form['langcodes'] = array('#type' => 'checkboxes', '#title' => $this->t('Language selection'), '#default_value' => $this->configuration['langcodes'], '#options' => $langcodes_options, '#description' => $this->t('Select languages to enforce. If none are selected, all languages will be allowed.'));
     } else {
         $form['langcodes'] = array('#type' => 'value', '#default_value' => $this->configuration['langcodes']);
     }
     return parent::buildConfigurationForm($form, $form_state);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:18,代码来源:Language.php

示例5: buildOptionsForm

 /**
  * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId), '#title' => $this->t('View mode'), '#default_value' => $this->options['view_mode']);
     $options = $this->buildRenderingLanguageOptions();
     $form['rendering_language'] = array('#type' => 'select', '#options' => $options, '#title' => $this->t('Rendering language'), '#default_value' => $this->options['rendering_language'], '#access' => $this->languageManager->isMultilingual());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:EntityRow.php

示例6: import

  /**
   * {@inheritdoc}
   */
  public function import($currencyCode) {
    if ($existingEntity = $this->storage->load($currencyCode)) {
      // Pretend the currency was just imported.
      return $existingEntity;
    }

    $defaultLangcode = $this->languageManager->getDefaultLanguage()->getId();
    $currency = $this->externalRepository->get($currencyCode, $defaultLangcode, 'en');
    $values = [
      'langcode' => $defaultLangcode,
      'currencyCode' => $currency->getCurrencyCode(),
      'name' => $currency->getName(),
      'numericCode' => $currency->getNumericCode(),
      'symbol' => $currency->getSymbol(),
      'fractionDigits' => $currency->getFractionDigits(),
    ];
    $entity = $this->storage->create($values);
    $entity->trustData()->save();
    if ($this->languageManager->isMultilingual()) {
      // Import translations for any additional languages the site has.
      $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
      $languages = array_diff_key($languages, [$defaultLangcode => $defaultLangcode]);
      $langcodes = array_map(function ($language) {
        return $language->getId();
      }, $languages);
      $this->importEntityTranslations($entity, $langcodes);
    }

    return $entity;
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:33,代码来源:CurrencyImporter.php

示例7: getIcon

 /**
  * {@inheritdoc}
  */
 public function getIcon()
 {
     if ($this->languageManager->isMultilingual()) {
         return $this->getEntity()->getIcon();
     }
     return $this->pluginDefinition['icon'];
 }
开发者ID:dev981,项目名称:gaptest,代码行数:10,代码来源:MenuLinkContent.php

示例8: query

 /**
  * {@inheritdoc}
  */
 public function query()
 {
     // We purposefully do not call parent::query() because we do not want the
     // default query behavior for Views fields. Instead, let the entity
     // translation renderer provide the correct query behavior.
     if ($this->languageManager->isMultilingual()) {
         $this->getEntityTranslationRenderer()->query($this->query, $this->relationship);
     }
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:12,代码来源:RenderedEntity.php

示例9: subscribe

 /**
  * {@inheritdoc}
  */
 public function subscribe($mail, $newsletter_id, $confirm = NULL, $source = 'unknown', $preferred_langcode = NULL)
 {
     // Get current subscriptions if any.
     $subscriber = simplenews_subscriber_load_by_mail($mail);
     // If user is not subscribed to ANY newsletter, create a subscription account
     if (!$subscriber) {
         // To subscribe a user:
         //   - Fetch the users uid.
         //   - Determine the user preferred language.
         //   - Add the user to the database.
         //   - Get the full subscription object based on the mail address.
         // Note that step 3 gets subscription data based on mail address because the uid can be 0 (for anonymous users)
         $account = user_load_by_mail($mail);
         // If the site is multilingual:
         //  - Anonymous users are subscribed with their preferred language
         //    equal to the language of the current page.
         //  - Registered users will be subscribed with their default language as
         //    set in their account settings.
         // By default the preferred language is not set.
         if ($this->languageManager->isMultilingual()) {
             if ($account) {
                 $preferred_langcode = $account->getPreferredLangcode();
             } else {
                 $preferred_langcode = isset($preferred_langcode) ? $preferred_langcode : $this->languageManager->getCurrentLanguage();
             }
         } else {
             $preferred_langcode = '';
         }
         $subscriber = Subscriber::create(array());
         $subscriber->setMail($mail);
         if ($account) {
             $subscriber->setUserId($account->id());
         }
         $subscriber->setLangcode($preferred_langcode);
         $subscriber->setStatus(SubscriberInterface::ACTIVE);
         $subscriber->save();
     }
     $newsletter = simplenews_newsletter_load($newsletter_id);
     // If confirmation is not explicitly specified, use the newsletter
     // configuration.
     if ($confirm === NULL) {
         $confirm = $this->requiresConfirmation($newsletter, $subscriber->getUserId());
     }
     if ($confirm) {
         // Create an unconfirmed subscription object if it doesn't exist yet.
         if (!$subscriber->isSubscribed($newsletter_id)) {
             $subscriber->subscribe($newsletter_id, SIMPLENEWS_SUBSCRIPTION_STATUS_UNCONFIRMED, $source);
             $subscriber->save();
         }
         $this->addConfirmation('subscribe', $subscriber, $newsletter);
     } elseif (!$subscriber->isSubscribed($newsletter_id)) {
         // Subscribe the user if not already subscribed.
         $subscriber->subscribe($newsletter_id, SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED, $source);
         $subscriber->save();
     }
     return $this;
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:60,代码来源:SubscriptionManager.php

示例10: getDescription

 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     // We only need to get the description from the actual entity if it may be a
     // translation based on the current language context. This can only happen
     // if the site is configured to be multilingual.
     if ($this->languageManager->isMultilingual()) {
         return $this->getEntity()->getDescription();
     }
     return $this->pluginDefinition['description'];
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:MenuLinkContent.php

示例11: buildVisibilityInterface

 /**
  * Helper function for building the visibility UI form.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return array
  *   The form array with the visibility UI added in.
  */
 protected function buildVisibilityInterface(array $form, FormStateInterface $form_state)
 {
     $form['visibility_tabs'] = ['#type' => 'vertical_tabs', '#title' => $this->t('Visibility'), '#parents' => ['visibility_tabs'], '#attached' => ['library' => ['block/drupal.block']]];
     // @todo Allow list of conditions to be configured in
     //   https://www.drupal.org/node/2284687.
     $visibility = $this->entity->getVisibility();
     foreach ($this->manager->getDefinitions() as $condition_id => $definition) {
         // Don't display the current theme condition.
         if ($condition_id == 'current_theme') {
             continue;
         }
         // Don't display the language condition until we have multiple languages.
         if ($condition_id == 'language' && !$this->language->isMultilingual()) {
             continue;
         }
         /** @var \Drupal\Core\Condition\ConditionInterface $condition */
         $condition = $this->manager->createInstance($condition_id, isset($visibility[$condition_id]) ? $visibility[$condition_id] : []);
         $form_state->set(['conditions', $condition_id], $condition);
         $condition_form = $condition->buildConfigurationForm([], $form_state);
         $condition_form['#type'] = 'details';
         $condition_form['#title'] = $condition->getPluginDefinition()['label'];
         $condition_form['#group'] = 'visibility_tabs';
         $form[$condition_id] = $condition_form;
     }
     if (isset($form['node_type'])) {
         $form['node_type']['#title'] = $this->t('Content types');
         $form['node_type']['bundles']['#title'] = $this->t('Content types');
         $form['node_type']['negate']['#type'] = 'value';
         $form['node_type']['negate']['#title_display'] = 'invisible';
         $form['node_type']['negate']['#value'] = $form['node_type']['negate']['#default_value'];
     }
     if (isset($form['user_role'])) {
         $form['user_role']['#title'] = $this->t('Roles');
         unset($form['user_role']['roles']['#description']);
         $form['user_role']['negate']['#type'] = 'value';
         $form['user_role']['negate']['#value'] = $form['user_role']['negate']['#default_value'];
     }
     if (isset($form['request_path'])) {
         $form['request_path']['#title'] = $this->t('Pages');
         $form['request_path']['negate']['#type'] = 'radios';
         $form['request_path']['negate']['#default_value'] = (int) $form['request_path']['negate']['#default_value'];
         $form['request_path']['negate']['#title_display'] = 'invisible';
         $form['request_path']['negate']['#options'] = [$this->t('Show for the listed pages'), $this->t('Hide for the listed pages')];
     }
     if (isset($form['language'])) {
         $form['language']['negate']['#type'] = 'value';
         $form['language']['negate']['#value'] = $form['language']['negate']['#default_value'];
     }
     return $form;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:61,代码来源:BlockForm.php

示例12: buildForm

 /**
  * {@inheritDoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $options = [];
     foreach ($this->manager->getDefinitions() as $plugin_id => $plugin_definition) {
         $options[$plugin_id] = $plugin_definition['label'];
     }
     $form['type'] = ['#type' => 'select', '#title' => $this->t('Pattern type'), '#default_value' => $this->entity->getType(), '#options' => $options, '#required' => TRUE, '#limit_validation_errors' => array(array('type')), '#submit' => array('::submitSelectType'), '#executes_submit_callback' => TRUE, '#ajax' => array('callback' => '::ajaxReplacePatternForm', 'wrapper' => 'pathauto-pattern', 'method' => 'replace')];
     $form['pattern_container'] = ['#type' => 'container', '#prefix' => '<div id="pathauto-pattern">', '#suffix' => '</div>'];
     // if there is no type yet, stop here.
     if ($this->entity->getType()) {
         $alias_type = $this->entity->getAliasType();
         $form['pattern_container']['pattern'] = array('#type' => 'textfield', '#title' => 'Path pattern', '#default_value' => $this->entity->getPattern(), '#size' => 65, '#maxlength' => 1280, '#element_validate' => array('token_element_validate', 'pathauto_pattern_validate'), '#after_build' => array('token_element_validate'), '#token_types' => $alias_type->getTokenTypes(), '#min_tokens' => 1);
         // Show the token help relevant to this pattern type.
         $form['pattern_container']['token_help'] = array('#theme' => 'token_tree_link', '#token_types' => $alias_type->getTokenTypes());
         // Expose bundle and language conditions.
         if ($alias_type->getDerivativeId() && ($entity_type = $this->entityTypeManager->getDefinition($alias_type->getDerivativeId()))) {
             $default_bundles = [];
             $default_languages = [];
             foreach ($this->entity->getSelectionConditions() as $condition_id => $condition) {
                 if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type->id(), 'node_type'])) {
                     $default_bundles = $condition->getConfiguration()['bundles'];
                 } elseif ($condition->getPluginId() == 'language') {
                     $default_languages = $condition->getConfiguration()['langcodes'];
                 }
             }
             if ($entity_type->hasKey('bundle') && ($bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type->id()))) {
                 $bundle_options = [];
                 foreach ($bundles as $id => $info) {
                     $bundle_options[$id] = $info['label'];
                 }
                 $form['pattern_container']['bundles'] = array('#title' => $entity_type->getBundleLabel(), '#type' => 'checkboxes', '#options' => $bundle_options, '#default_value' => $default_bundles, '#description' => t('Check to which types this pattern should be applied. Leave empty to allow any.'));
             }
             if ($this->languageManager->isMultilingual() && $entity_type->isTranslatable()) {
                 $language_options = [];
                 foreach ($this->languageManager->getLanguages() as $id => $language) {
                     $language_options[$id] = $language->getName();
                 }
                 $form['pattern_container']['languages'] = array('#title' => $this->t('Languages'), '#type' => 'checkboxes', '#options' => $language_options, '#default_value' => $default_languages, '#description' => t('Check to which languages this pattern should be applied. Leave empty to allow any.'));
             }
         }
     }
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $this->entity->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#title' => $this->t('ID'), '#maxlength' => 255, '#default_value' => $this->entity->id(), '#required' => TRUE, '#disabled' => !$this->entity->isNew(), '#machine_name' => array('exists' => 'Drupal\\pathauto\\Entity\\PathautoPattern::load'));
     $form['status'] = ['#title' => $this->t('Enabled'), '#type' => 'checkbox', '#default_value' => $this->entity->status()];
     return parent::buildForm($form, $form_state);
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:49,代码来源:PatternEditForm.php

示例13: blockAccess

 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     return $this->languageManager->isMultilingual();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:7,代码来源:LanguageBlock.php

示例14: blockAccess

 /**
  * {@inheritdoc}
  */
 protected function blockAccess(AccountInterface $account)
 {
     $access = $this->languageManager->isMultilingual() ? AccessResult::allowed() : AccessResult::forbidden();
     return $access->addCacheTags(['config:configurable_language_list']);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:8,代码来源:LanguageBlock.php

示例15: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\user\UserInterface $account */
     $account = $this->entity;
     $user = $this->currentUser();
     $config = \Drupal::config('user.settings');
     $form['#cache']['tags'] = $config->getCacheTags();
     $language_interface = \Drupal::languageManager()->getCurrentLanguage();
     $register = $account->isAnonymous();
     $admin = $user->hasPermission('administer users');
     // Account information.
     $form['account'] = array('#type' => 'container', '#weight' => -10);
     // The mail field is NOT required if account originally had no mail set
     // and the user performing the edit has 'administer users' permission.
     // This allows users without email address to be edited and deleted.
     // Also see \Drupal\user\Plugin\Validation\Constraint\UserMailRequired.
     $form['account']['mail'] = array('#type' => 'email', '#title' => $this->t('Email address'), '#description' => $this->t('A valid email address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email.'), '#required' => !(!$account->getEmail() && $user->hasPermission('administer users')), '#default_value' => !$register ? $account->getEmail() : '');
     // Only show name field on registration form or user can change own username.
     $form['account']['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."), '#required' => TRUE, '#attributes' => array('class' => array('username'), 'autocorrect' => 'off', 'autocapitalize' => 'off', 'spellcheck' => 'false'), '#default_value' => !$register ? $account->getUsername() : '', '#access' => $register || $user->id() == $account->id() && $user->hasPermission('change own username') || $admin);
     // Display password field only for existing users or when user is allowed to
     // assign a password during registration.
     if (!$register) {
         $form['account']['pass'] = array('#type' => 'password_confirm', '#size' => 25, '#description' => $this->t('To change the current user password, enter the new password in both fields.'));
         // To skip the current password field, the user must have logged in via a
         // one-time link and have the token in the URL. Store this in $form_state
         // so it persists even on subsequent Ajax requests.
         if (!$form_state->get('user_pass_reset')) {
             $user_pass_reset = $pass_reset = isset($_SESSION['pass_reset_' . $account->id()]) && \Drupal::request()->query->get('pass-reset-token') == $_SESSION['pass_reset_' . $account->id()];
             $form_state->set('user_pass_reset', $user_pass_reset);
         }
         // The user must enter their current password to change to a new one.
         if ($user->id() == $account->id()) {
             $form['account']['current_pass'] = array('#type' => 'password', '#title' => $this->t('Current password'), '#size' => 25, '#access' => !$form_state->get('user_pass_reset'), '#weight' => -5, '#attributes' => array('autocomplete' => 'off'));
             $form_state->set('user', $account);
             // The user may only change their own password without their current
             // password if they logged in via a one-time login link.
             if (!$form_state->get('user_pass_reset')) {
                 $form['account']['current_pass']['#description'] = $this->t('Required if you want to change the %mail or %pass below. <a href=":request_new_url" title="Send password reset instructions via email.">Reset your password</a>.', array('%mail' => $form['account']['mail']['#title'], '%pass' => $this->t('Password'), ':request_new_url' => $this->url('user.pass')));
             }
         }
     } elseif (!$config->get('verify_mail') || $admin) {
         $form['account']['pass'] = array('#type' => 'password_confirm', '#size' => 25, '#description' => $this->t('Provide a password for the new account in both fields.'), '#required' => TRUE);
     }
     // When not building the user registration form, prevent web browsers from
     // autofilling/prefilling the email, username, and password fields.
     if ($this->getOperation() != 'register') {
         foreach (array('mail', 'name', 'pass') as $key) {
             if (isset($form['account'][$key])) {
                 $form['account'][$key]['#attributes']['autocomplete'] = 'off';
             }
         }
     }
     if ($admin || !$register) {
         $status = $account->get('status')->value;
     } else {
         $status = $config->get('register') == USER_REGISTER_VISITORS ? 1 : 0;
     }
     $form['account']['status'] = array('#type' => 'radios', '#title' => $this->t('Status'), '#default_value' => $status, '#options' => array($this->t('Blocked'), $this->t('Active')), '#access' => $admin);
     $roles = array_map(array('\\Drupal\\Component\\Utility\\Html', 'escape'), user_role_names(TRUE));
     $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => $this->t('Roles'), '#default_value' => !$register ? $account->getRoles() : array(), '#options' => $roles, '#access' => $roles && $user->hasPermission('administer permissions'));
     // Special handling for the inevitable "Authenticated user" role.
     $form['account']['roles'][RoleInterface::AUTHENTICATED_ID] = array('#default_value' => TRUE, '#disabled' => TRUE);
     $form['account']['notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user of new account'), '#access' => $register && $admin);
     $user_preferred_langcode = $register ? $language_interface->getId() : $account->getPreferredLangcode();
     $user_preferred_admin_langcode = $register ? $language_interface->getId() : $account->getPreferredAdminLangcode(FALSE);
     // Is the user preferred language added?
     $user_language_added = FALSE;
     if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) {
         $negotiator = $this->languageManager->getNegotiator();
         $user_language_added = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUser::METHOD_ID, LanguageInterface::TYPE_INTERFACE);
     }
     $form['language'] = array('#type' => $this->languageManager->isMultilingual() ? 'details' : 'container', '#title' => $this->t('Language settings'), '#open' => TRUE, '#access' => !$register || $user->hasPermission('administer users'));
     $form['language']['preferred_langcode'] = array('#type' => 'language_select', '#title' => $this->t('Site language'), '#languages' => LanguageInterface::STATE_CONFIGURABLE, '#default_value' => $user_preferred_langcode, '#description' => $user_language_added ? $this->t("This account's preferred language for emails and site presentation.") : $this->t("This account's preferred language for emails."), '#pre_render' => ['user_langcode' => [$this, 'alterPreferredLangcodeDescription']]);
     // Only show the account setting for Administration pages language to users
     // if one of the detection and selection methods uses it.
     $show_admin_language = FALSE;
     if ($account->hasPermission('access administration pages') && $this->languageManager instanceof ConfigurableLanguageManagerInterface) {
         $negotiator = $this->languageManager->getNegotiator();
         $show_admin_language = $negotiator && $negotiator->isNegotiationMethodEnabled(LanguageNegotiationUserAdmin::METHOD_ID);
     }
     $form['language']['preferred_admin_langcode'] = array('#type' => 'language_select', '#title' => $this->t('Administration pages language'), '#languages' => LanguageInterface::STATE_CONFIGURABLE, '#default_value' => $user_preferred_admin_langcode, '#access' => $show_admin_language, '#empty_option' => $this->t('- No preference -'), '#empty_value' => '');
     // User entities contain both a langcode property (for identifying the
     // language of the entity data) and a preferred_langcode property (see
     // above). Rather than provide a UI forcing the user to choose both
     // separately, assume that the user profile data is in the user's preferred
     // language. This entity builder provides that synchronization. For
     // use-cases where this synchronization is not desired, a module can alter
     // or remove this item.
     $form['#entity_builders']['sync_user_langcode'] = [$this, 'syncUserLangcode'];
     return parent::form($form, $form_state, $account);
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:94,代码来源:AccountForm.php


注:本文中的Drupal\Core\Language\LanguageManagerInterface::isMultilingual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。