Initial checkin of the suit of scripts and files needed to leverage

translations from localized mozilla/netscape language packs into embed.jar.


git-svn-id: svn://10.0.0.236/trunk@125573 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tao%netscape.com 2002-07-22 17:23:58 +00:00
parent cf73a02489
commit 0c28c38cf0
6 changed files with 851 additions and 0 deletions

View File

@ -0,0 +1,46 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Author: Tao Cheng <tao@netscape.com>
# Date : July 22, 2002
#
# Run the main script, "make-l10n-jar.sh", to leverage translations from the
# language packs of existing localized Netscape 7.0 client.
#
run> make-l10n-jar.sh ${langcode} ver1 ver2
# this will produce embed.jar-${langcode} & installed-chrome.txt-${langcode}
# and leverage ... see comments in make-l10n-jar.sh

View File

@ -0,0 +1,202 @@
#!/usr/bin/sh
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Note: use this template, jar.mn-ab-CD, to produce a sample jar.mn-${langcode}
#
# locale/ab-CD/navigator/navigator-title.dtd
# locale/ab-CD/global/about.html
# locale/ab-CD/global/brand.dtd
# locale/ab-CD/global/brand.properties
#
# locale/ab-CD/communicator/wallet/wallet.properties > script & edit diff
# locale/ab-CD/global/ldapAutoCompErrs.properties
# locale/ab-CD/global/printing.properties
# locale/ab-CD/global/regionNames.properties
# locale/ab-CD/global/tabbrowser.dtd
# locale/ab-CD/navigator/navigator.dtd
# locale/ab-CD/navigator/pageInfo.dtd
# locale/ab-CD/navigator/navigator.properties
# locale/ab-CD/navigator/turboDialog.dtd
# locale/ab-CD/pipnss/pipnss.properties
#
embed.jar:
locale/ab-CD/global/about.html (embed_jar/locale/en-US/global/about.html)
locale/ab-CD/global/brand.dtd (embed_jar/locale/en-US/global/brand.dtd)
locale/ab-CD/global/brand.properties (embed_jar/locale/en-US/global/brand.properties)
locale/ab-CD/navigator/navigator-title.dtd (embed_jar/locale/en-US/navigator/navigator-title.dtd)
locale/ab-CD/navigator/navigator.properties (embed_jar/locale/en-US/navigator/navigator.properties)
locale/ab-CD/pipnss/contents.rdf
locale/ab-CD/pipnss/pipnss.properties
locale/ab-CD/navigator-platform/contents.rdf
locale/ab-CD/navigator-platform/navigator.properties
locale/ab-CD/communicator/layout/xmlparser.properties
locale/ab-CD/communicator/layout/HtmlForm.properties
locale/ab-CD/communicator/layout/ImageDocument.properties
locale/ab-CD/communicator/wallet/cookie.properties
locale/ab-CD/communicator/wallet/CookieViewer.dtd
locale/ab-CD/communicator/wallet/CookieViewer.properties
locale/ab-CD/communicator/wallet/index.html
locale/ab-CD/communicator/wallet/privacy.dtd
locale/ab-CD/communicator/wallet/privacy.html
locale/ab-CD/communicator/wallet/sample1.html
locale/ab-CD/communicator/wallet/sample10.html
locale/ab-CD/communicator/wallet/sample2.html
locale/ab-CD/communicator/wallet/SignonViewer.dtd
locale/ab-CD/communicator/wallet/SignonViewer.properties
locale/ab-CD/communicator/wallet/WalletPreview.dtd
locale/ab-CD/communicator/wallet/WalletViewer.dtd
locale/ab-CD/communicator/wallet/sample3.html
locale/ab-CD/communicator/wallet/sample4.html
locale/ab-CD/communicator/wallet/sample5.html
locale/ab-CD/communicator/wallet/sample6.html
locale/ab-CD/communicator/wallet/sample7.html
locale/ab-CD/communicator/wallet/sample8.html
locale/ab-CD/communicator/wallet/sample9.html
locale/ab-CD/communicator/wallet/wallet.properties
locale/ab-CD/communicator/wallet/WalletEditor.dtd
locale/ab-CD/communicator/wallet/WalletEditor.properties
locale/ab-CD/communicator/security/caps.properties
locale/ab-CD/communicator/pref/pref-smart_browsing.dtd
locale/ab-CD/communicator/pref/pref-colors.dtd
locale/ab-CD/communicator/pref/pref.dtd
locale/ab-CD/communicator/pref/pref-applications.properties
locale/ab-CD/communicator/pref/pref-tabs.dtd
locale/ab-CD/communicator/pref/pref-smartupdate.dtd
locale/ab-CD/communicator/pref/pref-security.dtd
locale/ab-CD/communicator/pref/pref-themes.dtd
locale/ab-CD/communicator/pref/pref-appearance.dtd
locale/ab-CD/communicator/pref/pref-winhooks.dtd
locale/ab-CD/communicator/pref/prefutilities.properties
locale/ab-CD/communicator/pref/pref-advanced.dtd
locale/ab-CD/communicator/pref/pref-debug.dtd
locale/ab-CD/communicator/pref/pref-cache.dtd
locale/ab-CD/communicator/pref/pref-applications-edit.dtd
locale/ab-CD/communicator/pref/preftree.dtd
locale/ab-CD/communicator/pref/pref-charset.dtd
locale/ab-CD/communicator/pref/pref-offline.dtd
locale/ab-CD/communicator/pref/pref-scripts.dtd
locale/ab-CD/communicator/pref/pref-navigator.dtd
locale/ab-CD/communicator/pref/pref-policies.dtd
locale/ab-CD/communicator/pref/pref-debug2.dtd
locale/ab-CD/communicator/pref/pref-proxy-manual.dtd
locale/ab-CD/communicator/pref/pref-languages.dtd
locale/ab-CD/communicator/pref/pref-languages.properties
locale/ab-CD/communicator/pref/pref-mousewheel.dtd
locale/ab-CD/communicator/pref/pref-search.dtd
locale/ab-CD/communicator/pref/pref-debug1.dtd
locale/ab-CD/communicator/pref/pref-proxies.dtd
locale/ab-CD/communicator/pref/pref-history.dtd
locale/ab-CD/communicator/pref/pref-fonts.dtd
locale/ab-CD/communicator/security.properties
locale/ab-CD/communicator/contents.rdf
locale/ab-CD/global-platform/contents.rdf
locale/ab-CD/global-platform/platformDialogOverlay.dtd
locale/ab-CD/global-platform/platformKeys.properties
locale/ab-CD/global-platform/wizard.properties
locale/ab-CD/forms/contents.rdf
locale/ab-CD/forms/htmlforms.dtd
locale/ab-CD/global/charsetOverlay.dtd
locale/ab-CD/global/commonDialog.dtd
locale/ab-CD/global/commonDialogs.properties
locale/ab-CD/global/config.dtd
locale/ab-CD/global/console.dtd
locale/ab-CD/global/console.properties
locale/ab-CD/global/contents.rdf
locale/ab-CD/global/dialog.properties
locale/ab-CD/global/dialogOverlay.dtd
locale/ab-CD/global/downloadProgress.dtd
locale/ab-CD/global/downloadProgress.properties
locale/ab-CD/global/filepicker.dtd
locale/ab-CD/global/filepicker.properties
locale/ab-CD/global/finddialog.properties
locale/ab-CD/global/intl.css
locale/ab-CD/global/keys.properties
locale/ab-CD/global/languageNames.properties
locale/ab-CD/global/ldapAutoCompErrs.properties
locale/ab-CD/global/nsHelperAppDlg.dtd
locale/ab-CD/global/nsHelperAppDlg.properties
locale/ab-CD/global/nsTreeSorting.properties
locale/ab-CD/global/nsWebBrowserPersist.properties
locale/ab-CD/global/plugins.properties
locale/ab-CD/global/printdialog.dtd
locale/ab-CD/global/printing.properties
locale/ab-CD/global/printProgress.dtd
locale/ab-CD/global/replacedialog.dtd
locale/ab-CD/global/about.dtd
locale/ab-CD/global/accept2locale.properties
locale/ab-CD/global/appstrings.properties
locale/ab-CD/global/charsetDetectorsOverlay.dtd
locale/ab-CD/global/charsetTitles.properties
locale/ab-CD/global/finddialog.dtd
locale/ab-CD/global/nsProgressDialog.dtd
locale/ab-CD/global/nsProgressDialog.properties
locale/ab-CD/global/regionNames.properties
locale/ab-CD/global/tabbrowser.dtd
locale/ab-CD/global/tabbrowser.properties
locale/ab-CD/global/textcontext.dtd
locale/ab-CD/global/wizardManager.properties
locale/ab-CD/global/wizardOverlay.dtd
locale/ab-CD/global/xpcom.properties
locale/ab-CD/necko/contents.rdf
locale/ab-CD/necko/redirect_loop.dtd
locale/ab-CD/necko/necko.properties
locale/ab-CD/pippki/certManager.dtd
locale/ab-CD/pippki/contents.rdf
locale/ab-CD/pippki/deviceManager.dtd
locale/ab-CD/pippki/newserver.dtd
locale/ab-CD/pippki/newserver.properties
locale/ab-CD/pippki/PageInfoOverlay.dtd
locale/ab-CD/pippki/pippki.dtd
locale/ab-CD/pippki/pippki.properties
locale/ab-CD/pippki/pref-masterpass.dtd
locale/ab-CD/pippki/pref-security.dtd
locale/ab-CD/pippki/pref-ssl.dtd
locale/ab-CD/pippki/pref-validation.dtd
locale/ab-CD/pippki/PrefOverlay.dtd
locale/ab-CD/navigator/contents.rdf
locale/ab-CD/navigator/linkToolbar.dtd
locale/ab-CD/navigator/metadata.dtd
locale/ab-CD/navigator/metadata.properties
locale/ab-CD/navigator/navigator.dtd
locale/ab-CD/navigator/pageInfo.dtd
locale/ab-CD/navigator/pageInfo.properties
locale/ab-CD/navigator/turboDialog.dtd
locale/ab-CD/navigator/turboMenu.properties
locale/ab-CD/navigator/viewSource.dtd

View File

@ -0,0 +1,75 @@
#!/usr/bin/sh
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
#
# Author: Tao Cheng <tao@netscape.com>
# Date : July 22, 2002
#
# use to this script to leverage transation from localized jar, xx-XX_jar, into the US embed_jar/
toLoc=$1
if [ "$toLoc" = "" ]
then
echo "Usage: $0 toLocale"
exit 1
fi
# leverage
subsKeyVal.pl embed_jar/locale/en-US/communicator/wallet/wallet.properties ${toLoc}_jar/locale/${toLoc}/communicator/wallet/wallet.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/global/ldapAutoCompErrs.properties ${toLoc}_jar/locale/${toLoc}/global/ldapAutoCompErrs.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/global/printing.properties ${toLoc}_jar/locale/${toLoc}/global/printing.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/global/regionNames.properties ${toLoc}_jar/locale/${toLoc}/global/regionNames.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/global/tabbrowser.dtd ${toLoc}_jar/locale/${toLoc}/global/tabbrowser.dtd ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/navigator/navigator.dtd ${toLoc}_jar/locale/${toLoc}/navigator/navigator.dtd ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/navigator/pageInfo.dtd ${toLoc}_jar/locale/${toLoc}/navigator/pageInfo.dtd ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/navigator/navigator.properties ${toLoc}_jar/locale/${toLoc}/navigator/navigator.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/navigator/turboDialog.dtd ${toLoc}_jar/locale/${toLoc}/navigator/turboDialog.dtd ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/pipnss/pipnss.properties ${toLoc}_jar/locale/${toLoc}/pipnss/pipnss.properties ${toLoc}
subsKeyVal.pl embed_jar/locale/en-US/pippki/PageInfoOverlay.dtd ${toLoc}_jar/locale/${toLoc}/pippki/PageInfoOverlay.dtd ${toLoc}
#
# copying
cp embed_jar/locale/en-US/communicator/wallet/wallet.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/communicator/wallet/wallet.properties
cp embed_jar/locale/en-US/global/ldapAutoCompErrs.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/global/ldapAutoCompErrs.properties
cp embed_jar/locale/en-US/global/printing.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/global/printing.properties
cp embed_jar/locale/en-US/global/regionNames.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/global/regionNames.properties
cp embed_jar/locale/en-US/global/tabbrowser.dtd.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/global/tabbrowser.dtd
cp embed_jar/locale/en-US/navigator/navigator.dtd.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/navigator/navigator.dtd
cp embed_jar/locale/en-US/navigator/pageInfo.dtd.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/navigator/pageInfo.dtd
cp embed_jar/locale/en-US/navigator/navigator.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/navigator/navigator.properties
cp embed_jar/locale/en-US/navigator/turboDialog.dtd.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/navigator/turboDialog.dtd
cp embed_jar/locale/en-US/pipnss/pipnss.properties.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/pipnss/pipnss.properties
cp embed_jar/locale/en-US/pippki/PageInfoOverlay.dtd.${toLoc} embed_jar-${toLoc}/locale/${toLoc}/pippki/PageInfoOverlay.dtd

View File

@ -0,0 +1,120 @@
#!/usr/bin/sh
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Author: Tao Cheng <tao@netscape.com>
# Date : July 22, 2002
#
# needed scripts:
# make-jars.pl, mozLock.pm, leverage.sh,
# and strsubs.pl if $2, $3 present
#
# note: you can get the most recent copies of make-jars.pl and mozLock.pm
# from mozilla/config
#
# needed file: jar.mn-ab-CD
#
langcode=$1
if [ "$langcode" = "" ]
then
echo "Usage: $0 langcode [localeVer1 localeVer2]"
exit 1
fi
# 1. copy jar.mn-ab-CD
# 2. replace all ab-CD to ${langcode}
# 3. make 1st ver of jar
echo ""
echo "-- calling make-jars.pl ..."
echo ""
make-jars.pl -s ${langcode}_jar < jar.mn-${langcode}
#
# expand it
#
echo ""
echo "-- calling unzip ..."
echo ""
unzip embed.jar -d embed_jar-${langcode}
#
# 4. rename embed.jar and installed-chrome.txt
#
mv embed.jar embed.jar-${langcode}
mv installed-chrome.txt installed-chrome.txt-${langcode}
#
# 5. run leverage.sh to leverage the xlations from ${langcode}_jar into embed_jar/locale/en-US/
# and then replace the English files in embed_jar-${langcode}
#
echo ""
echo "-- calling leverage.sh ${langcode} ..."
echo ""
leverage.sh ${langcode}
#
# 6. update localeVersion if they are outdated
#
ver1=$2
ver2=$3
echo ""
echo "-- from ${ver1} to ${ver2} ?? ..."
echo ""
if [ "$ver1" != "$ver2" ]
then
echo "-- updating localeVersion in embed_jar-${langcode} from ${ver1} to ${ver2}"
find embed_jar-${langcode} -name "contents.rdf" -exec grep -l ${ver1} {} \; -exec strsubs.pl ${ver1} ${ver2} {} \;
echo "-- removing *.org"
find embed_jar-${langcode} -name "contents*.rdf.*" -exec rm {} \;
fi
#
#
echo ""
echo "-- generating embed_jar-${langcode}/installed-chrome.txt ..."
echo ""
grep --invert "locale" installed-chrome.txt-en-US > embed_jar-${langcode}/installed-chrome.txt
cat installed-chrome.txt-${langcode} >> embed_jar-${langcode}/installed-chrome.txt
echo "locale,install,select,${langcode}" >> embed_jar-${langcode}/installed-chrome.txt
#
echo ""
echo "-- generating embed_jar-${langcode}/embed.jar ..."
echo ""
cp -r embed_jar/{content,skin} embed_jar-${langcode}
cd embed_jar-${langcode}
zip embed.jar -r content skin locale
zip embed_jar-${langcode}.zip embed.jar installed-chrome.txt
#
echo ""
echo "--DONE: ${langcode} embed.jar and installed-chrome.txt is in"
echo " `pwd`/embed_jar-${langcode}.zip !! --"
exit 0

View File

@ -0,0 +1,132 @@
#!/usr/bin/perl
#
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Author: Tao Cheng <tao@netscape.com>
# Date : Aug. 6, 2001
#
require 'getopts.pl';
#
# Usage: $progname [Options] fromString toString [file|directory]*
#
#
sub usage {
die
"\n::\n",
"\n",
" Usage: $progname [Options] fromString toString [file|directory]* \n",
"\n",
" $progname takes one or more filenames or directories as input\n",
" arguments. It substitutes instances of \'fromString\'with \'toString\' \n",
" in the provided files or directories.\n",
"\n",
" $progname enters a given directory and its sub-directories\n",
" to process all text files encountered.\n",
"\n",
" Options:\n",
" -h Print help (this message)\n",
" -p pattern_str substitute only when the line matches pattern_str \n",
"\n::\n",
"\n";
}
sub strop
{
open (INFILE, $_[0]);
$newfile = $_[0] . ".new";
$orgfile = $_[0] . ".org";
print ">> writing to: $newfile\n\n";
open (TMPFILE, "> $newfile");
$aline;
while ( <INFILE> ) {
if (/$patstr/ && /$oldstr/) {
print "\n>> current line: $_";
$_ =~ s/$oldstr/$newstr/;
print TMPFILE $_;
}
else {
print TMPFILE $_;
}
}
# while
close (INFILE);
close (TMPFILE);
#
# backup the file and put the new one in place
print " --> renaming $_[0] to $orgfile ... \n";
rename($_[0], $orgfile);
print " --> renaming $newfile to $_[0] ...\n";
rename($newfile, $_[0]);
print ">> done!\n\n";
}
#--------------------------------------------------------------------------
# main body
#--------------------------------------------------------------------------
#
# Extract base part of this script's name
($progname) = $0 =~ /([^\/]+)$/;
#
&usage if (!&Getopts('p:h') || ($#ARGV < 2));
&usage if ($opt_h); # help option
#
$count = 0;
$oldstr = $ARGV[$count++];
$newstr = $ARGV[$count++];
$patstr = ($opt_p)?($opt_p):"";
@myargv = $ARGV[$count];
print "\n:: oldstr =$oldstr\n",
":: newstr =$newstr\n",
":: patstr =$patstr\n",
":: target file\(s\) = @myargv \n\n";
#
#
$count = 0;
foreach $arg (@myargv) {
print ">> file $count: $myargv[$count]\n\n";
&strop($arg);
$count++;
}
#
printf "\n";

View File

@ -0,0 +1,276 @@
#!/usr/bin/perl
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Tao Cheng <tao@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Author: Tao Cheng <tao@netscape.com>
# Date : July 1, 2002
#
require 'getopts.pl';
#
# Usage: $progname [Options] en_file l10n_file
#
#
sub usage {
die
"\n::\n",
"\n",
" Usage: $progname [Options] en_file l10n_file l10n_code\n",
"\n",
" $progname takes one or more filenames or directories as input\n",
" arguments. It substitutes instances of \'fromString\'with \'toString\' \n",
" in the provided files or directories.\n",
"\n",
" $progname enters a given directory and its sub-directories\n",
" to process all text files encountered.\n",
"\n",
" Options:\n",
" -h Print help (this message)\n",
" -p pattern_str substitute only when the line matches pattern_str \n",
"\n::\n",
"\n";
}
sub getKeyVal
{
my (@tokens, $key, $value, $pos);
if (/^#/) {
# print "comment:$_";
}
else {
$pos = index($_, "=");
if ($pos) {
$key = substr($_, 0, $pos);
$value = substr($_, $pos+1);
#print "\n-- before (pos,key,value)=($pos,$key,$value)";
# trim white space
$key =~ s/^[\s]|[\s]$//;
$value =~ s/^[\s]|[\s]$|[\r\n]$//g;
@tokens = ($key,$value);
#print "\n-- getKeyVal: (pos,key,value)=($pos,$key,$value)";
}
}
@tokens;
}
#
# arg 0: Arr
#
sub dumpArr
{
my (@Arr, $count, $arr);
$count = 0;
@Arr = @_;
foreach $arr (@Arr) {
print "\n$count:", $Arr[$count];
++$count;
}
print "\n** End of dumpArr \n";
}
sub getEntity
{
my (@tokens, $token, @pair, $key, $value, $remaining, $del, $pos, $pos1, $pos2);
if (/\<\!ENTITY/) {
@tokens = split(/\s/, $_);
#print "\n pos=$pos";
#dumpArr(@tokens);
if ($#tokens > 1) {
if ($tokens[1]) {
$key = $tokens[1];
}
elsif ($tokens[2]) {
$key = $tokens[2];
}
$pos1 = index($_, "\"");
$pos2 = rindex($_, "\"");
#print "\n-- (pos1,pos2,key,value)=($pos1,$pos2,$key,$value)";
if ($pos2 > $pos1) {
$value = substr($_, $pos1 + 1, $pos2-$pos1-1);
#print "\n-- getEntity(): (pos1,pos2,key,value)=($pos1,$pos2,$key,$value)";
@pair = ($key,$value);
}
}
}
else {
# print "-- getEntity(), comment:$_";
}
@pair;
}
sub buildGlossary
{
open (INFILE, $_[0]);
my (@tokens, $count, $blank, %keyValueTab, $isDTD);
$isDTD = 0;
if ($_[0] =~ /dtd$/) {
$isDTD = 1;
print "\n ** $_[0]: isDTD! **";
}
$count = 0;
$nonblank = 0;
while ( <INFILE> ) {
if ($isDTD) {
@tokens = &getEntity($_);
}
else {
@tokens = &getKeyVal($_);
}
if ($#tokens > 0) {
#print "\n ** tokens=($tokens[0],$tokens[1])";
$keyValueTab{$tokens[0]} = $tokens[1];
$count++;
if ($tokens[1]) {
$nonblank++;
}
}
}
# while
close (INFILE);
print "\n>> buildGlossary(), count=$count, nonblank=$nonblank\n\n";
%keyValueTab;
}
sub replaceEntries()
{
my ($outf, @tokens, $hits, $miss, $value, $l10n_code);
if ($_[1]) {
$l10n_code = "." . $_[1];
}
else {
$l10n_code = ".l10n";
}
$outf = $_[0] . $l10n_code;
open (INFILE, $_[0]);
open (OUTFILE, "> $outf");
# &dumpTable(%glossaryTab);
$isDTD = 0;
if ($_[0] =~ /dtd$/) {
$isDTD = 1;
print "\n ** $_[0]: isDTD! **";
}
$hits = 0;
$miss = 0;
while ( <INFILE> ) {
if ($isDTD) {
@tokens = &getEntity($_);
}
else {
@tokens = &getKeyVal($_);
}
if ($#tokens > 0 && $tokens[0]) {
#print "\n ** replaceEntries: tokens=($tokens[0],$tokens[1])";
$value = $glossaryTab{$tokens[0]};
if ($value) {
#print "\n replaceEntries(hit) : (key,value)=($tokens[0],$value)";
$hits++;
#print "$tokens[0]=$value\n";
if ($isDTD) {
my ($pos1, $aline);
$pos1 = index($_, "\"");
$aline = substr($_, 0, $pos1+1) . $value . "\"\>\n";
#print "\n--aline=$aline\n";
print OUTFILE $aline;
}
else {
print OUTFILE "$tokens[0]=$value\n";
}
}
else {
print "\n replaceEntries(miss) : (key,value)=($tokens[0],$value)";
$miss++;
$aline = $_;
$aline =~ s/[\r\n]$//;
print OUTFILE "$aline\n";
}
}
else {
print OUTFILE $_
}
}
# while
close (INFILE);
close (OUTFILE);
print "\n--replaceEntries hits=$hits, miss=$miss, done!\n\n";
}
#
# dump a hash table to the console
#
sub dumpTable()
{
my (%Table, $name, $lineno);
$lineno = 0;
%Table = @_;
foreach $name (sort keys %Table) {
++$lineno;
print "\n dumpTable: $lineno: $name=$Table{$name}";
}
}
#--------------------------------------------------------------------------
# main body
#--------------------------------------------------------------------------
#
# Extract base part of this script's name
($progname) = $0 =~ /([^\/]+)$/;
#
#&usage if (!&Getopts('p:h') || ($#ARGV < 2));
&usage if ($opt_h); # help option
#
$count = 0;
$en_file = $ARGV[$count++];
$l10n_file = $ARGV[$count++];
$l10n_code = $ARGV[$count++];
@myargv = $ARGV[$count];
print "\n:: en_file =$en_file\n",
":: l10n_file =$l10n_file\n",
":: l10n_code =$l10n_code\n";
#
#
%glossaryTab = &buildGlossary($l10n_file);
#&dumpTable(%glossaryTab);
#
&replaceEntries($en_file, $l10n_code);
#
printf "\n";