protected function i18n_string_textgroup_default::multiple_translation_load in Internationalization 7
Load multiple translations from db
@todo Optimize when we've already got the source object
Parameters
$conditions: Array of field values to use as query conditions.
$langcode: Language code to search.
$index: Field to use as index for the result.
Return value
array Array of string objects with translation set.
1 call to i18n_string_textgroup_default::multiple_translation_load()
- i18n_string_textgroup_default::multiple_translation_search in i18n_string/
i18n_string.inc - Search multiple translations with key combinations.
File
- i18n_string/
i18n_string.inc, line 888 - API for internationalization strings
Class
- i18n_string_textgroup_default
- Textgroup handler for i18n_string API
Code
protected function multiple_translation_load($conditions, $langcode) {
$conditions += array(
'language' => $langcode,
'textgroup' => $this->textgroup,
);
// We may be querying all translations at the same time or just one language.
// The language field needs some special treatment though.
$query = db_select('i18n_string', 's')
->fields('s');
$query
->leftJoin('locales_target', 't', 's.lid = t.lid');
$query
->fields('t', array(
'translation',
'language',
'i18n_status',
));
foreach ($conditions as $field => $value) {
// Single array value, reduce array
if (is_array($value) && count($value) == 1) {
$value = reset($value);
}
if ($value === '*') {
continue;
}
elseif ($field == 'language') {
$query
->condition('t.language', $value);
}
else {
$query
->condition('s.' . $field, $value);
}
}
return $this
->multiple_translation_build($query
->execute()
->fetchAll(), $langcode);
}