mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-24 08:07:19 +00:00

It's mostly about making the scripts run if python defaults to python3. Has been tested for each script.
121 lines
4.1 KiB
Python
Executable File
121 lines
4.1 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
#
|
|
# wescamp_import -- generate a shellscript to import a campaign from WesCamp
|
|
#
|
|
# Pipe the output of this command to sh to actually perform the operation
|
|
#
|
|
import sys, os, getopt, shutil
|
|
|
|
if __name__ == "__main__":
|
|
def help():
|
|
sys.stderr.write("""\
|
|
Usage: wescamp_import {-h | wescamp-path campaign-name textdomain}
|
|
Options may be any of these:
|
|
-h, --help Emit this help message and quit
|
|
Requires as first argument a path to a WesCamp checkout
|
|
Requires as second argument a campaign name.
|
|
Call from the top level directory of mainline.
|
|
""")
|
|
|
|
|
|
# Process options
|
|
(options, arguments) = getopt.getopt(sys.argv[1:], "h", ['help',])
|
|
for (switch, val) in options:
|
|
if switch in ('-h', '--help'):
|
|
help()
|
|
sys.exit(0)
|
|
if len(arguments) == 0:
|
|
sys.stderr.write("wescamp_import: a path to a local WesCamp checkout is required.\n")
|
|
sys.exit(1)
|
|
else:
|
|
wescamp_path = arguments[0]
|
|
if len(arguments) == 1:
|
|
sys.stderr.write("wescamp_import: a campaign name is required.\n")
|
|
sys.exit(1)
|
|
else:
|
|
campaign = arguments[1]
|
|
if len(arguments) == 2:
|
|
sys.stderr.write("wescamp_import: a text domain name is required.\n")
|
|
sys.exit(1)
|
|
else:
|
|
textdomain = arguments[2]
|
|
|
|
print """\
|
|
# Generated script to do an import of %(textdomain)s from a WesCamp checkout
|
|
#
|
|
mkdir po/%(textdomain)s
|
|
cp %(wescamp_path)s/%(campaign)s/po/*.po* po/%(textdomain)s
|
|
|
|
cp po/wesnoth/LINGUAS po/%(textdomain)s/
|
|
|
|
cat > po/%(textdomain)s/FINDCFG <<'EOF'
|
|
find data/campaigns/%(campaign)s -name '*.cfg' -print
|
|
find data/campaigns/%(campaign)s -name '*.lua' -print
|
|
EOF
|
|
|
|
cat > po/%(textdomain)s/Makevars <<'EOF'
|
|
# Makefile variables for PO directory in any package using GNU gettext.
|
|
|
|
# Usually the message domain is the same as the package name.
|
|
DOMAIN = %(textdomain)s
|
|
|
|
# These two variables depend on the location of this directory.
|
|
subdir = po/$(DOMAIN)
|
|
top_builddir = ../..
|
|
|
|
# These options get passed to xgettext.
|
|
XGETTEXT_OPTIONS = --from-code=UTF-8 --sort-by-file --keyword=sgettext --keyword=vgettext --keyword=_n:1,2 --keyword=sngettext:1,2 --keyword=vngettext:1,2
|
|
|
|
# This is the copyright holder that gets inserted into the header of the
|
|
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
|
|
# package. (Note that the msgstr strings, extracted from the package's
|
|
# sources, belong to the copyright holder of the package.) Translators are
|
|
# expected to transfer the copyright for their translations to this person
|
|
# or entity, or to disclaim their copyright. The empty string stands for
|
|
# the public domain; in this case the translators are expected to disclaim
|
|
# their copyright.
|
|
COPYRIGHT_HOLDER = Wesnoth development team
|
|
|
|
# This is the email address or URL to which the translators shall report
|
|
# bugs in the untranslated strings:
|
|
# - Strings which are not entire sentences, see the maintainer guidelines
|
|
# in the GNU gettext documentation, section 'Preparing Strings'.
|
|
# - Strings which use unclear terms or require additional context to be
|
|
# understood.
|
|
# - Strings which make invalid assumptions about notation of date, time or
|
|
# money.
|
|
# - Pluralisation problems.
|
|
# - Incorrect English spelling.
|
|
# - Incorrect formatting.
|
|
# It can be your email address, or a mailing list address where translators
|
|
# can write to without being subscribed, or the URL of a web page through
|
|
# which the translators can contact you.
|
|
MSGID_BUGS_ADDRESS =http://bugs.wesnoth.org/
|
|
|
|
# This is the list of locale categories, beyond LC_MESSAGES, for which the
|
|
# message catalogs shall be used. It is usually empty.
|
|
EXTRA_LOCALE_CATEGORIES =
|
|
EOF
|
|
|
|
touch po/%(textdomain)s/POTFILES.in
|
|
|
|
ed po/Makefile.am <<'EOF'
|
|
/^SUBDIRS/s/$/ %(textdomain)s/
|
|
wq
|
|
EOF
|
|
|
|
# Warning: this depends on m4/Makefile being in the list of generated files
|
|
ed configure.ac <<'EOF'
|
|
/m4\/Makefile/-1a
|
|
po/%(textdomain)s/Makefile.in
|
|
.
|
|
wq
|
|
EOF
|
|
|
|
git add po/%(textdomain)s
|
|
|
|
# To be able to review the commit before actually doing it
|
|
# recommended commit-msg: Wescamp import
|
|
git commit configure.ac po/Makefile.am po/%(textdomain)s
|
|
""" % locals()
|