1 field.multilingual.inc _field_language_suggestion($available_languages, $language_suggestion, $field_name)

Process the given language suggestion based on the available languages.

If a non-empty language suggestion is provided it must appear among the available languages, otherwise it will be ignored.

Parameters

$available_languages: An array of valid language codes.

$language_suggestion: A language code or an array of language codes keyed by field name.

$field_name: The name of the field being processed.

Return value

An array of valid language codes.:

Related topics

File

core/modules/field/field.multilingual.inc, line 144
Functions implementing Field API multilingual support.

Code

function _field_language_suggestion($available_languages, $language_suggestion, $field_name) {
  // Handle possible language suggestions.
  if (!empty($language_suggestion)) {
    // We might have an array of language suggestions keyed by field name.
    if (is_array($language_suggestion) && isset($language_suggestion[$field_name])) {
      $language_suggestion = $language_suggestion[$field_name];
    }

    // If we have a language suggestion and the suggested language is available,
    // we return only it.
    if (in_array($language_suggestion, $available_languages)) {
      $available_languages = array($language_suggestion);
    }
  }

  return $available_languages;
}