Thread View: news.software.readers
7 messages
7 total messages
Started by Bertel Lund Hansen
Wed, 14 Sep 2005 09:00
[Dialog] Automatic choice of language in a script
Author: Bertel Lund Hansen
Date: Wed, 14 Sep 2005 09:00
Date: Wed, 14 Sep 2005 09:00
73 lines
3214 bytes
3214 bytes
Hi all
I use an event script to put a message in my postings if they are
crossposted or if FollowUp is set. The text is Danish and of
little interest for English-speaking people.
Is there a way to make the script choose between different
languages automatically? It would be okay if it has a default
choice and otherwise is triggered by groupnames containing
"english" or "deutsch".
Here is the script though I don't suppose that the language part
depends on the rest. The comments are in Danish, and the script
is modified from one of the Wiki scripts.
program OnBeforeSendingMessage;
// Udskift evt. teksten:
const
messageXPost = 'Xpostet til:';
messageFut = 'Fut til:';
messageInfo = 'Svar herpå sendes dertil hvis det ikke aktivt
forhindres.';
// {$define EMPTYLINE} // Laver en tom linje mellem info og sig.
const
headerFollowupTo = 'Followup-To:';
headerNewsgroups = 'Newsgroups:';
function OnBeforeSendingMessage (var message: TStringlist;
servername: string; isEmail: boolean):boolean;
var
i, sigline: integer;
s, futGroup, xpostGroups: string;
begin
result:=true; // False hvis beskeden ikke skal sendes.
if isEmail then exit;
for i:=0 to message.count-1 do begin
s:= message.strings[i];
if s='' then break;
// +1 i de to linjer skipper et kolon som allerede findes i
variablerne.
if Pos(headerFollowupTo,s)>0 then
futGroup:=copy(s,length(headerFollowupTo)+1,999);
if Pos(headerNewsgroups,s)>0 then
if Pos(',',s)>0 then
xpostGroups:=copy(s,length(headerNewsgroups)+1,999);
end;
for i:=message.count-1 downto 0 do
if message.strings[i]='-- ' then break;
// Sørg for at der er noget at indsætte foran.
if i<1 then
sigline:=message.count+1
else
sigline:=i;
{$ifdef EMPTYLINE}
if (futGroup>'') or (xpostGroups>'') then
message.Insert(sigline,'');
{$endif}
if futGroup>'' then begin
message.Insert(sigline,messageInfo);
message.Insert(sigline,messageFut+futGroup);
end;
if xpostGroups>'' then
message.Insert(sigline,messageXPost+xpostGroups);
end;
Begin
End.
--
Bertel
http://bertel.lundhansen.dk/ http://fiduso.dk/
Re: [Dialog] Automatic choice of language in a script
Author: Korbinian Abenthum
Date: Tue, 27 Sep 2005 01:36
Date: Tue, 27 Sep 2005 01:36
20 lines
2168 bytes
2168 bytes
Bertel Lund Hansen wrote: > I use an event script to put a message in my postings if they are > crossposted or if FollowUp is set. The text is Danish and of > little interest for English-speaking people. > > Is there a way to make the script choose between different > languages automatically? It would be okay if it has a default > choice and otherwise is triggered by groupnames containing > "english" or "deutsch". http://www.40tude.com/DIALOG/wiki/index.php/ScriptFup2Warning_include It's not thoroughly tested ATM, and it's not quite easy to configure. If you notice anything or got problems, please let me know. -- "Do you have any notion what happens when a city is sacked, Sansa? No, you wouldn't, would you? All you know of life you learned from singers, and there is such a dearth of good sacking songs."
Re: [Dialog] Automatic choice of language in a script
Author: MLC
Date: Tue, 27 Sep 2005 07:09
Date: Tue, 27 Sep 2005 07:09
14 lines
1767 bytes
1767 bytes
martedì 27 settembre 2005 Korbinian Abenthum ha scritto: > http://www.40tude.com/DIALOG/wiki/index.php/ScriptFup2Warning_include right link: http://www.40tude.com/dialog/wiki/index.php/ScriptFup2Warning_include Thanks for your script :-) -- Maria Luisa C - 27/09/2005 9.09.20 The price of Prozac went up 50 percent last year. When Prozac users were asked about it, they said, 'Whatever.' -
Re: [Dialog] Automatic choice of language in a script
Author: Bertel Lund Hansen
Date: Tue, 27 Sep 2005 10:41
Date: Tue, 27 Sep 2005 10:41
39 lines
2441 bytes
2441 bytes
Korbinian Abenthum skrev:
> http://www.40tude.com/DIALOG/wiki/index.php/ScriptFup2Warning_include
Just to be on the safe side I also correct the link:
http://www.40tude.com/dialog/wiki/index.php/ScriptFup2Warning_include
> It's not thoroughly tested ATM, and it's not quite easy to configure. If you
> notice anything or got problems, please let me know.
Thanks a lot. I have run a few tests, and it works like I wanted.
I made a few changes. Here is an example. In the beginning I
declare two variables so I can use them to hold two texts:
var
newsgroupPatterns : TStringList;
Ftext, Xtext : String;
[...]
// Language Version 2: Deutsch
Ftext := 'Follow-Up nach: $F'+CFW_NEWLINE+'Antworten werden dazu gesendet, wenn man es nicht ändert.'+CFW_NEWLINE;
Xtext := 'Crossposted nach: $N'+CFW_NEWLINE;
newsgroupPatterns := TStringList.Create;
newsgroupPatterns.Add( 'de.' ); //Group Pattern 1
CFW_AddLanguage (newsgroupPatterns, true, Ftext, Xtext, Xtext+Ftext);
This way one only has to edit the output in one place. I also made
sure that all messages end with an empty line. I haven't checked
if that will conflict with other settings.
I made an unimportant change by copying the include-file directly
into the program file. I don't quite understand why you split it
up?
--
Bertel
http://bertel.lundhansen.dk/ http://fiduso.dk/
Re: [Dialog] Automatic choice of language in a script
Author: Korbinian Abenthum
Date: Tue, 27 Sep 2005 12:25
Date: Tue, 27 Sep 2005 12:25
12 lines
1813 bytes
1813 bytes
MLC wrote: > martedì 27 settembre 2005 Korbinian Abenthum ha scritto: >> http://www.40tude.com/DIALOG/wiki/index.php/ScriptFup2Warning_include > right link: > http://www.40tude.com/dialog/wiki/index.php/ScriptFup2Warning_include Aargh! Hmm, I should turn that Replace-String script off at last :) -- "A girl should be bloody too." - Jaqen H'ghar
Re: [Dialog] Automatic choice of language in a script
Author: Korbinian Abenthum
Date: Tue, 27 Sep 2005 12:39
Date: Tue, 27 Sep 2005 12:39
35 lines
2704 bytes
2704 bytes
Bertel Lund Hansen wrote: > http://www.40tude.com/dialog/wiki/index.php/ScriptFup2Warning_include > I made a few changes. Here is an example. In the beginning I > declare two variables so I can use them to hold two texts: [...] Of course. I figured it'd be best to keep it as flexible as possible. > newsgroupPatterns.Add( 'de.' ); You realize that this pattern matches non German speaking groups, too? Like alt.suicide.holiday > I also made sure that all messages end with an empty line. I haven't > checked if that will conflict with other settings. It shouldn't. > I made an unimportant change by copying the include-file directly into > the program file. I don't quite understand why you split it up? Because it's easier if you have more than one OnBeforeSending script, like a Boxquote, Footnote, Now-Playing and Generate-MID script. It's not exactly easy for non-programmers to merge these scripts into one, and users couldn't remove a script without help. If you keep all scripts in separate include file, you only have insert two lines into your OnBeforeSending script. That way, people can usually merge any number of scripts on their own. -- "You send hired knives to kill a fourteenyear-old girl and still quibble about honor?" (Eddard Stark)
Re: [Dialog] Automatic choice of language in a script
Author: Bertel Lund Hansen
Date: Tue, 27 Sep 2005 14:52
Date: Tue, 27 Sep 2005 14:52
18 lines
1684 bytes
1684 bytes
Korbinian Abenthum skrev: > You realize that this pattern matches non German speaking groups, too? > Like alt.suicide.holiday Oops - and I even saw the note about the comma. I'll fix it. >> I made an unimportant change by copying the include-file directly into >> the program file. I don't quite understand why you split it up? > Because it's easier if you have more than one OnBeforeSending script, like a > Boxquote, Footnote, Now-Playing and Generate-MID script. I see. -- Bertel http://bertel.lundhansen.dk/ http://fiduso.dk/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads