4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
28 if (exists $ENV{"HTTP_ACCEPT"}) {
35 print "Content-Type: text/html
\r\n\n" unless($tofile);
37 my $path=$ENV{"PATH_TRANSLATED"};
41 my @locale=`locale -a`;
45 push @{$lang{$`}}, $';
48 my $str_env=$ENV{"HTTP_ACCEPT_LANGUAGE"};
50 my @lang=split/,/,$str_env;
53 foreach my $locale(@lang){
54 goto find_locale if ($locale eq 'en');
55 foreach my $lg(@{$lang{$locale}}){
56 setlocale(LC_MESSAGES,$locale."_".$lg);
57 my $tmp = gettext($locale);
67 setlocale(LC_MESSAGES,$lang);
78 $plik="koha.gettext.c";
86 my (%dgettxt, %dane, %dane2, @dane2);
89 $dgettxt{'iso-8859-1'}=1;
94 <META http-equiv=Content-Type content="text/thml;
95 charset=${\(gettext('iso-8859-1'))}">
106 unless ($_=~/(\.html|\.inc)$/i) {
111 print "$kat$_" if ($tofile);
126 $dane=~s/<html>/$txt/i;
128 $dane=~s/%/&zamien/ges; # change % (specjal symbol)
129 $dane=~s/\\\'/&zamien/ges; # change \'
130 $dane=~s/\\\"/&zamien/ges; # change \"
133 $dane=~s/[\"\']\/?([\w-\/\.]*?\.gif)[\"\']/&zamien($1)/ges;
135 # $dane=~s/messenger\s*\((.*?)\)\s*[\}\{;]/&zamien($1)/ges;
136 # $dane=~s/\.write(ln)?\s*\((.*?)\)\s*[\};]/&zamien($2)/ges;
138 # take out string in field alt
139 $dane=~s/alt\s*=\s*[\"]([^\"]*)[\"]/&zamien($1)/iges;
140 $dane=~s/alt\s*=\s*[\']([^\']*)[\']/&zamien($1)/iges;
142 $dane=~s/<!--.*?-->/&zamien/ges;
143 $dane=~s/<script.*?<\/script>/&zamien/iges;
145 $dane=~s/<[\w\/]\w*\s*((\w*\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[\w-\/?&,\.=%#]*)|[%\d*%]|\w)\s*)*>/&zamien/ges;
146 $dane=~s/<!\[.*?\]>/&zamien/ges;
147 $dane=~s/<![^>]*>/&zamien/ges;
148 $dane=~s/<#.*?#>/&zamien/ges;
151 $dane2=~s/(\s*%\d+%\s*)+/%/gs;
154 foreach my $tmp(split/%/,$dane2){
157 next unless ($tmp_ok=~/\w+/);
158 $dgettxt{$tmp_ok}++ unless $dgettxt{$tmp_ok};
159 $tmp=~s/([\)\(])/\\$1/g;
160 $dane=~s/$tmp/gettext($tmp_ok)/es;
163 while($dane=~/%\d+%/){
164 $dane=~s/%(\d+)%/$dane2{$1}/g;
173 foreach my $tmp(sort keys %dgettxt){
175 print PK "gettext(\"$tmp\");\n";
182 ###########################################################
186 unless ($dgettxt{$_[0]}) {
189 $tmp=~s/$_[0]/gettext($&)/es;
190 unless ($dane{$tmp}) {
195 return "%${\($dane{$tmp})}%";