function field_valid_language

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)
cle7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)
elmsmedia7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)
icor7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)
meedjum_blog7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)
mooc7 field.multilingual.inc field_valid_language($langcode, $default = TRUE)

Ensures that a given language code is valid.

Checks whether the given language is one of the enabled languages. Otherwise, it returns the current, global language; or the site's default language, if the additional parameter $default is TRUE.

Parameters

$langcode: The language code to validate.

$default: Whether to return the default language code or the current language code in case $langcode is invalid.

Return value

A valid language code.

Related topics

7 calls to field_valid_language()
ctools_entity_field_value_ctools_access_settings in sites/all/modules/ulmus/ctools/plugins/access/entity_field_value.inc
Settings form for the 'by entity_bundle' access plugin
ctools_entity_field_value_ctools_access_settings_submit in sites/all/modules/ulmus/ctools/plugins/access/entity_field_value.inc
Compress the entity bundles allowed to the minimum.
editableviews_entity_form in sites/all/modules/ulmus/editableviews/editableviews.module
Form builder for an editable view.
editableviews_handler_field_field_edit::edit_form in sites/all/modules/ulmus/editableviews/handlers/editableviews_handler_field_field_edit.inc
Add the form element for this handler's field to the form.
entity_metadata_field_get_language in sites/all/modules/ulmus/entity/modules/callbacks.inc
Helper for determining the field language to be used.

... See full list

File

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

Code

function field_valid_language($langcode, $default = TRUE) {
  $enabled_languages = field_content_languages();
  if (in_array($langcode, $enabled_languages)) {
    return $langcode;
  }
  global $language_content;
  return $default ? language_default('language') : $language_content->language;
}