public function TMGMTI18nStringSourcePluginController::getExistingLangCodes in Translation Management Tool 7
Gets existing translation language codes of the job item source.
Returns language codes that can be used as the source language for a translation job.
Parameters
TMGMTJobItem $job_item: The job item.
Return value
array Array of language codes.
Overrides TMGMTDefaultSourcePluginController::getExistingLangCodes
File
- sources/
i18n_string/ tmgmt_i18n_string.plugin.inc, line 123 - Provides the i18n string source controller.
Class
- TMGMTI18nStringSourcePluginController
- Translation plugin controller for i18n strings.
Code
public function getExistingLangCodes(TMGMTJobItem $job_item) {
$existing_lang_codes = array();
$languages = language_list();
if ($object = $this
->getI18nObjectWrapper($job_item)) {
$existing_lang_codes = array_keys($languages);
foreach ($object
->load_strings() as $string) {
foreach ($languages as $language) {
if ($language->language == $this
->getSourceLangCode($job_item)) {
continue;
}
// Remove languages for which we fail to find translation.
if (in_array($language->language, $existing_lang_codes) && !$string
->get_translation($language->language)) {
$existing_lang_codes = array_diff($existing_lang_codes, array(
$language->language,
));
}
}
}
}
return $existing_lang_codes;
}