Re: Internationalizing Linux

Nicholas J. Leon (nicholas@binary9.net)
Sat, 5 Dec 1998 19:24:56 -0500 (EST)


# as for the program, how about something like this for a start?

Here's version 1.1 :) It allows changing the language file via
-l <language file>

and allows the user to

cat file | thisprog

or

thisprog file

It recognizes the language file as being as before
'kernelsz<white space>language-based-message'

and presumes that the input file will have
%%kernelsz

tags that we will shove our string inplace of.

(sorry, this wasn't necessary to do, but I was bored and its been a good
two weeks since I've done Perl programming[1]: I'm going through
withdrawl :)

#!/bin/perl

use strict;
use Getopt::Std;

my $msgfile='messages.english';
my %msgs;
my %opts;

getopts('l:',\%opts);

$msgfile=$opts{l} if defined $opts{l};

open(MSGS,"<$msgfile") || die $!;

while (<MSGS>) {
$msgs{$1}=$2 if /^([^\s]+)\s+(.+)/;
}
close MSGS;

while (<>) {
s/%%([^\s]+)/$msgs{$1}/g;
print;
}

[1] Do you know how hard it is to go from Unix programming to Windows 95
programming?? Even though I started my career as a win2.0 programmer.

G'day!

-- n i c h o l a s j l e o n
/ elegance through simplicity /
/ good fortune through truth / http://mrnick.binary9.net
/ not all questions have answers / mailto:nicholas@binary9.net

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/