The code above is meant to translate an rss feed.sub get_by_id { my ($self, $feed_id) = @_; my $feed = $self->single({id => $feed_id}); my $xml_feed = XML::Feed->parse(URI->new($feed->url)); $xml_feed->{'url'} = $feed->url; use WWW::Translate::Apertium; foreach ($xml_feed->entries) { my $engine = WWW::Translate::Apertium->new(lang_pair => 'en-ca'); my $translated_string = $engine->translate($_->content->body); #This change $_->content->body $_->content($translated_string); } return $xml_feed; }
The template above displays the translated content. However, if I would like to do[% FOREACH entry IN feed.entries %] TRANSLATED:[% entry.content.body %] [% END %]
It would seem I want to add an attribute (body_alt) to an XML::Feed::Content object. Am I on the right track? I want to believe $_->content->{body_alt} = $translated_string would do what I want, but i'm sure all you guys are about to point out why it doesn't do what I think it should (see second template).[% FOREACH entry IN feed.entries %] ORIGINAL:[% entry.content.body %] TRANSLATED:[% entry.content.body_alt %] [% END %]
In reply to Moose? Add a new attribute to a XML::Feed::Content object? by uG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |