function lingotek_field_language_alter in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lingotek.module \lingotek_field_language_alter()
- 7.2 lingotek.module \lingotek_field_language_alter()
- 7.3 lingotek.module \lingotek_field_language_alter()
- 7.5 lingotek.module \lingotek_field_language_alter()
- 7.6 lingotek.module \lingotek_field_language_alter()
Implements hook_field_language_alter().
File
- ./
lingotek.module, line 1814
Code
function lingotek_field_language_alter(&$display_language, $context) {
// If we have no language set on the entity itself, do nothing.
if (!isset($context['entity']->language) || empty($context['entity']->language)) {
return;
}
// Comments may be in a state where content only exists in the source language
// because Lingotek translation hasn't finished yet, or synchonization with
// Lingotek hasn't yet occurred. In this case, fall back to displaying
// the default language for each field.
foreach ($display_language as $field => $display_language_code) {
if (!isset($context['entity']->{$field}[$display_language_code])) {
$display_language[$field] = $context['entity']->language;
}
}
}