[ 'name' => t('Custom language'), 'description' => t('A custom language type.'), 'locked' => FALSE, ], 'fixed_custom_language_type' => [ 'locked' => TRUE, 'fixed' => ['custom_language_negotiation_method'], ], ]; } /** * Perform alterations on language types. * * @param array $language_types * Array of language type definitions. * * @see hook_language_types_info() * @ingroup language_negotiation */ function hook_language_types_info_alter(array &$language_types) { if (isset($language_types['custom_language_type'])) { $language_types['custom_language_type_custom']['description'] = t('A far better description.'); } } /** * Perform alterations on language negotiation methods. * * @param array $negotiation_info * Array of language negotiation method definitions. * * @ingroup language_negotiation */ function hook_language_negotiation_info_alter(array &$negotiation_info) { if (isset($negotiation_info['custom_language_method'])) { $negotiation_info['custom_language_method']['config'] = 'admin/config/regional/language/detection/custom-language-method'; } } /** * Allow modules to alter the language fallback candidates. * * @param array $candidates * An array of language codes whose order will determine the language fallback * order. * @param array $context * A language fallback context. * * @see \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates() */ function hook_language_fallback_candidates_alter(array &$candidates, array $context) { $candidates = array_reverse($candidates); } /** * Allow modules to alter the fallback candidates for specific operations. * * @param array $candidates * An array of language codes whose order will determine the language fallback * order. * @param array $context * A language fallback context. * * @see \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates() */ function hook_language_fallback_candidates_OPERATION_alter(array &$candidates, array $context) { // We know that the current OPERATION deals with entities so no need to check // here. if ($context['data']->getEntityTypeId() == 'node') { $candidates = array_reverse($candidates); } } /** * @} End of "addtogroup hooks". */