Lunarpages Web Hosting Forum

Author Topic: Different languages in nms Formmail  (Read 1145 times)

Offline Kool

  • Newbie
  • *
  • Posts: 3
Different languages in nms Formmail
« on: June 12, 2006, 10:56:44 PM »
In the nms formmail Script is a subroutine(listed below) to confirm the sended items.
I receive from the form the hidden field $language.
How can I modify the text 'Thank you' and the text "Below is what you submitted $torecipient on $date" depending on the given language?

sub success_page_html_preamble {
  my ($self, $date) = @_;

  my $title = $self->escape_html( $self->{FormConfig}{'title'} || 'Thank You' );
  my $torecipient = 'to ' . $self->escape_html($self->{FormConfig}{'recipient'});
  $torecipient = '' if $self->{Hide_Recipient};
  my $attr = $self->body_attributes;

    print <<END;
  <head>
     <title>$title</title>
END

    $self->output_style_element;

    print <<END;
     <style>
       h1.title {
                   text-align : center;
                }
     </style>
  </head>
  <body $attr>
    <h1 class="title">$title</h1>
    <p>Below is what you submitted $torecipient on $date</p>
    <p><hr size="1" width="75%" /></p>
END
}

Offline GMTurner

  • Berserker Poster
  • *****
  • Posts: 7479
    • Turner's Lounge
Re: Different languages in nms Formmail
« Reply #1 on: June 13, 2006, 04:22:49 AM »
It will depend on how many language options you have. If there is just one language (but not English) you could just change what is there. If there are two possible language choices, you could create an if-then clause for that part. If there are more than two languages, then you could create a series of if-then-else statements to go through the various language options or perhaps use some sort of associative array...

now, having said all of that, I'm not familiar enough with PERL to know exactly how to do it in that script... but it would be something similar to...

Code: [Select]
print <<END;
     <style>
       h1.title {
                   text-align : center;
                }
     </style>
  </head>
  <body $attr>
    <h1 class="title">$title</h1>
    <p>
END

if statements would go here checking $language to see which string to output

print <<END;
    </p>
    <p><hr size="1" width="75%" /></p>
END
}
The above information may or may not reflect current policy, opinions, or views since it was likely made almost 10 years ago.

Offline Kool

  • Newbie
  • *
  • Posts: 3
Re: Different languages in nms Formmail
« Reply #2 on: June 13, 2006, 08:21:34 AM »
my problem is a PERL- (not an if-else-)problem .


When writing "if ($language == "f") .......
I get the error message:
Global symbol "$language" requires explicit package name at (eval 8) line 1377.
BEGIN failed--compilation aborted at feedback-test.pl line 3518.

leighsww

  • Guest
Re: Different languages in nms Formmail
« Reply #3 on: June 14, 2006, 01:57:11 AM »
Did you change these settings in the .pl file to the given language?

Code: [Select]
$locale            = '';
$charset           = 'iso-8859-1';

The default $charset is the iso-8859-1, so you'll have to change it to the correct one for your needs.

Here's the README file to set the configs for the $locale:

http://nms-cgi.sourceforge.net/formmail_compat-3.14c1/README

Beyond what the README file says, I have never tried changing languages, so I've no clue on how this ends up working/looking  :?

Offline Kool

  • Newbie
  • *
  • Posts: 3
Re: Different languages in nms Formmail
« Reply #4 on: June 14, 2006, 04:05:00 AM »
It is a Perl problem, not an charset problem.

leighsww

  • Guest
Re: Different languages in nms Formmail
« Reply #5 on: June 16, 2006, 06:03:43 PM »
You will probably need to read and implement this in the code:

http://perldoc.perl.org/utf8.html

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6428
Re: Different languages in nms Formmail
« Reply #6 on: June 17, 2006, 08:35:25 AM »
I get the error message:
Global symbol "$language" requires explicit package name at (eval 8) line 1377.
BEGIN failed--compilation aborted at feedback-test.pl line 3518.

You said earlier that $language came in from a form (in the URL query string), but here, Perl is complaining that it can't find any such variable. Do you have the code in place to get the language variable out of the query string? It doesn't do it automagically. Check your code and see if $language is being pulled out of the query string like the other form variables.

Phil
Visit My Site

E-mail Me
-= From the ashes shall rise a sooty tern =-