1#!/usr/bin/perl
2#
3# usage: ./mergelocale.pl skeleton.pm0 lang1.pmd lang2.pmd
4# the script then creates locales_mrtg.pm
5#
6# If you want to modify a locale, modify the pmd file and rerun
7# this script and copy the generated locales_mrtg.pm to the run directory.
8#
9# If you want to translate a locale, copy one of the existing locales and
10# translate. Then rerun and copy.
11#
12#################################################################
13#
14# Distributed under the GNU copyleft
15#
16###################################################################
17
18open(OUTFILE,"> locales_mrtg.pm");
19
20@patchdb=(
21'PATCHTAG\s*00',
22'PATCHTAG\s*10',
23'PATCHTAG\s*20',
24'PATCHTAG\s*30',
25'PATCHTAG\s*40',
26'PATCHTAG\s*50',
27'PATCHTAG\s*60',
28);
29
30while(@ARGV){
31  push(@languages,shift);
32};
33
34foreach $patchtag (@patchdb)
35{
36  for $i (@languages)
37  {
38    open(LANGF,"< $i");
39    $patch="";
40    while(<LANGF>)
41    {
42      if(/\#.\S*PATCHTAG/)
43      {
44        $patch=/$patchtag/;
45      }
46      else
47      {
48        if($patch) { print OUTFILE $_; };
49      };
50    };
51  };
52};
53