protected function LocaleSourcePluginUi::getTranslationData in Translation Management Tool 8
Helper function to create translation data list for the sources page list.
Parameters
array $strings: Result of the search query returned by tmgmt_i18n_string_get_strings().
string $type: I18n object type.
Return value
array Structured array with translation data.
1 call to LocaleSourcePluginUi::getTranslationData()
- LocaleSourcePluginUi::overviewForm in sources/
locale/ src/ LocaleSourcePluginUi.php - Builds the overview form for the source entities.
File
- sources/
locale/ src/ LocaleSourcePluginUi.php, line 127
Class
- LocaleSourcePluginUi
- Locale source plugin UI.
Namespace
Drupal\tmgmt_localeCode
protected function getTranslationData($strings, $type) {
$objects = array();
// Source language of locale strings is always english.
$source_language = 'en';
foreach ($strings as $string) {
$id = $string->lid;
// Get existing translations and current job items for the entity
// to determine translation statuses
$current_job_items = tmgmt_job_item_load_latest('locale', $type, $id, $source_language);
$objects[$id] = array(
'id' => $id,
'object' => $string,
);
// Load entity translation specific data.
foreach ($this
->getLanguages() as $langcode => $language) {
$translation_status = 'current';
if ($langcode == $source_language) {
$translation_status = 'original';
}
elseif ($string->{$langcode} === NULL) {
$translation_status = 'missing';
}
$objects[$id]['current_job_items'][$langcode] = isset($current_job_items[$langcode]) ? $current_job_items[$langcode] : NULL;
$objects[$id]['translation_statuses'][$langcode] = $translation_status;
}
}
return $objects;
}