NULL)); } /** * Check if a module is registered as a translation handler for a given entity. * * @param $obj_type * The type of the entity whose fields are to be translated. * @param $handler * The name of the handler to be checked. * @return * TRUE, if the handler is allowed to manage field translations. */ function field_multilingual_check_translation_handler($obj_type, $handler) { $obj_info = field_info_fieldable_types($obj_type); return isset($obj_info['translation_handlers'][$handler]); } /** * Helper function to ensure 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. * * @param $langcode * The language code to validate. * @param $default * Whether to return the default language code or the current language code in * case $langcode is invalid. * @return * A valid language code. */ function field_multilingual_valid_language($langcode, $default = TRUE) { $enabled_languages = field_multilingual_content_languages(); if (in_array($langcode, $enabled_languages)) { return $langcode; } // @todo Currently, node language neutral code is an empty string. Node passes // $node->language as language parameter to field_attach_form(). We might // want to unify the two "language neutral" language codes. if ($langcode === '') { return FIELD_LANGUAGE_NONE; } global $language; $langcode = $default ? language_default('language') : $language->language; if (in_array($langcode, $enabled_languages)) { return $langcode; } // @todo Throw a more specific exception. throw new FieldException('No valid content language could be found.'); }