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 code above is meant to translate an rss feed.
[% FOREACH entry IN feed.entries %] TRANSLATED:[% entry.content.body %] [% END %]
The template above displays the translated content. However, if I would like to do
[% FOREACH entry IN feed.entries %] ORIGINAL:[% entry.content.body %] TRANSLATED:[% entry.content.body_alt %] [% 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).

In reply to Moose? Add a new attribute to a XML::Feed::Content object? by uG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.