Item11507: Internationalisation of the mailnotify script

pencil
Priority: Enhancement
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Extension
Component: MailerContrib
Branches: trunk
Reported By: TarekUnger
Waiting For:
Last Change By: GeorgeClark
The Emails send by the mailnotify are always english.

Possible solution (mailnotify): set the language per command line
use strict;

BEGIN {
    require 'setlib.cfg';
}

my $verbose = 1;
my @webs = ();
my @exwebs = ();
my $nonews = 0;
my $nochanges = 0;
my $language = undef;

# Called from the command line
foreach my $arg ( @ARGV ) {
    if( $arg eq "-q" ) {
        $verbose = 0;
    } elsif ( $arg =~ /-language=(.*)/ ) {
        $language = $1;
    } elsif ( $arg eq "-nonews" ) {
        $nonews = 1;
    } elsif ( $arg eq "-nochanges" ) {
        $nochanges = 1;
    } elsif ( $arg =~ m/^-(.*)/ ) {
        push( @exwebs, $1 );
    } else {
        push( @webs, $arg );
    }
}

use Foswiki();
use Foswiki::Contrib::MailerContrib ();

new Foswiki();

if ( $language ) {
    require Foswiki::Func;
    Foswiki::Func::setPreferenceValue( 'LANGUAGE', $language )
}

Foswiki::Contrib::MailerContrib::mailNotify(
    \@webs, $verbose, \@exwebs, $nonews, $nochanges );

usage:
perl -I bin tools/mailnotify -language=xyz

-- TarekUnger - 06 Feb 2012

This opened a can of worms, when it emerged that there was no way to reset the user language once it has been initialised.

I've addressed this problem.

-- CrawfordCurrie - 30 Apr 2014

 
Topic revision: r6 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy