aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Roles
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Roles')
-rw-r--r--perllib/FixMyStreet/Roles/Translatable.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Roles/Translatable.pm b/perllib/FixMyStreet/Roles/Translatable.pm
index 43cb063d1..cc66f9621 100644
--- a/perllib/FixMyStreet/Roles/Translatable.pm
+++ b/perllib/FixMyStreet/Roles/Translatable.pm
@@ -22,6 +22,19 @@ sub _translate {
my $table = lc $self->result_source->source_name;
my $id = $self->id;
+ # Deal with the fact problem table has denormalized copy of category string
+ if ($table eq 'problem' && $col eq 'category') {
+ my $body_id = $self->bodies_str_ids->[0];
+ return $fallback unless $body_id && $body_id =~ /^[0-9]+$/;
+ my $contact = $schema->resultset("Contact")->find( {
+ body_id => $body_id,
+ category => $fallback,
+ } );
+ return $fallback unless $contact; # Shouldn't happen, but some tests
+ $table = 'contact';
+ $id = $contact->id;
+ }
+
if (ref $schema) {
my $translation = $schema->resultset('Translation')->find({
lang => $schema->lang,