Lines 250-271
sub db_t {
Link Here
|
250 |
my $translations = $cache->get_from_cache($cache_key); |
250 |
my $translations = $cache->get_from_cache($cache_key); |
251 |
unless ($translations) { |
251 |
unless ($translations) { |
252 |
my $schema = Koha::Database->new->schema; |
252 |
my $schema = Koha::Database->new->schema; |
253 |
my $rs = $schema->resultset('L10nSource'); |
253 |
my $source_rs = $schema->resultset('L10nSource'); |
254 |
|
254 |
|
255 |
my @targets = $rs->search( |
255 |
my $sources = $source_rs->search( |
256 |
{ |
256 |
{ |
257 |
'group' => $group, |
257 |
'group' => $group |
258 |
'l10n_targets.language' => $language, |
258 |
} |
259 |
}, |
|
|
260 |
{ |
261 |
join => 'l10n_targets', |
262 |
prefetch => 'l10n_targets', |
263 |
result_class => 'DBIx::Class::ResultClass::HashRefInflator', |
264 |
}, |
265 |
); |
259 |
); |
266 |
$translations = |
260 |
while ( my $source = $sources->next ) { |
267 |
{ map { $_->{key} => $_->{l10n_targets}->[0]{translation} //= $_->{text} } |
261 |
my $translation = |
268 |
@targets }; |
262 |
$source->l10n_targets->search( { language => $language } ); |
|
|
263 |
$translations->{ $source->key } = |
264 |
$translation->count |
265 |
? $translation->first->translation |
266 |
: $source->text; |
267 |
} |
269 |
|
268 |
|
270 |
$cache->set_in_cache($cache_key, $translations); |
269 |
$cache->set_in_cache($cache_key, $translations); |
271 |
} |
270 |
} |
272 |
- |
|
|