getting stderr & stdout output lively modified

This is about getting all output to stderr and stdout localized. Nothing to do with redirecting output to a file (there already are some interesting threads about that issue on this forum).

What I intend to do is capturing all lines of text sent to the screen, compare them with an array of stored lines and replace the matching ones in the screen for their translated equivalents.

I'm aware of TEXTDOMAIN and alike, but unfortunately many scripts are not prepared for localization, so I want to try a different approach, tryng to translate everything carelessly if the script uses $"" or not for calling gettext.

I have been trying 2 ways:

1: Getting many commands that generate writen output intercepted. After editing etc/profile, ~/bashrc, setting aliases, expand_aliases and lots of things, I can get them catched only in interactive mode, but when running a script, no alias at all is keept (nor other settings). F.i., if I type "enable" in the shell, I see that echo has dissapeared (I replace it for my own). But running a script that contents the same command, echo is enabled again!. Should not expand_aliases have avoided this?

2: Some kind of daemon that could replace the standard output and give back the translated messages (or the original ones if not matched). Even it could be enough to append the translated lines to the already shown in english. I guess that I would have to redirect /dev/fd/? , /dev/tty? or something like that but i lack the knowledge to do it, if it can be done. Some tries done with no succes.

Could anybody point a solution, advise, whatever could help?

Thank you in advance.

T. Ram�rez
Ferrol (Spain)

You would need to use C or something like that. This is beyond what I want want to try via a script. perl could handle it though. basicly you will need to allocate a psuedo tty and arrange for the user to interact with the pty. Your program would sit between the user's "real" tty and the psuedo tty you allocate. The program called "script" does all of this, not to translate, but to capture all input and output to a file. So you could obtain the source code to script and study that as a starting point.

I thank you very much your response. Those are bad news, since I have never learned either C or Perl. I'm not sure how but I'll try with Pascal.

Well, that can stand for "way #2". Perhaps I'm not well aware about what can be done with shell scripting and what not. But.. what about the first method? do you/anybody know why aliases don't work when running scripts, in spite of having set shopt -s expand_aliases?. Surely I'm doing something wrong. If not, what is that option supossed to be intended for?

Best,

T. Ram�rez