You are here

public function EntityTranslationDefaultHandler::getDefaultLanguage in Entity Translation 7

Overrides EntityTranslationHandlerInterface::getDefaultLanguage

See also

EntityTranslationHandlerInterface::getDefaultLanguage()

3 calls to EntityTranslationDefaultHandler::getDefaultLanguage()
EntityTranslationDefaultHandler::entityFormLanguageWidget in includes/translation.handler.inc
EntityTranslationDefaultHandler::getFormLanguage in includes/translation.handler.inc
Retrieves the active form language.
EntityTranslationDefaultHandler::getLanguage in includes/translation.handler.inc

File

includes/translation.handler.inc, line 911
Default translation handler for the translation module.

Class

EntityTranslationDefaultHandler
Class implementing the default entity translation behaviours.

Code

public function getDefaultLanguage() {
  $settings = variable_get('entity_translation_settings_' . $this->entityType . '__' . $this->bundle, array());
  if (!empty($settings['default_language'])) {
    switch ($settings['default_language']) {
      case ENTITY_TRANSLATION_LANGUAGE_DEFAULT:
        $langcode = language_default()->language;
        break;
      case ENTITY_TRANSLATION_LANGUAGE_CURRENT:
        $langcode = $GLOBALS[LANGUAGE_TYPE_CONTENT]->language;
        break;
      case ENTITY_TRANSLATION_LANGUAGE_AUTHOR:
        $langcode = $GLOBALS['user']->language;
        break;
      default:

        // An actual language code has been explicitly configured.
        $langcode = $settings['default_language'];
    }
  }
  else {

    // Fall back to the default language to keep backward compatibility.
    $langcode = language_default()->language;
  }
  return $langcode;
}