Update to 0.19.1-2

This commit is contained in:
Daiki Ueno 2014-07-07 11:48:26 +09:00
parent 81750ca123
commit 5a1ae756c6
3 changed files with 45 additions and 131 deletions

View File

@ -1,89 +0,0 @@
From 953c7242b96f150c6f4b67d15603c79695e3f4f6 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Mon, 2 Jun 2014 18:04:41 +0900
Subject: [PATCH] msgl-check: Treat missing header errors as warnings
Problem reported by Richard Hughes at
<https://lists.fedoraproject.org/pipermail/devel/2014-June/199539.html>.
After <https://savannah.gnu.org/bugs/?40262>, "msgfmt -c" reports
error on missing PO headers. However, it turned out to be too strict
for the projects using Launchpad Translations. Let's relax the check
for the moment and wait for one or two release cycles.
* gettext-tools/src/msgl-check.c (check_header_entry): Report missing
required headers as warning, instead of error.
---
gettext-tools/src/msgl-check.c | 16 ++++++++++++++--
gettext-tools/tests/msgfmt-10 | 6 +++---
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gettext-tools/src/msgl-check.c b/gettext-tools/src/msgl-check.c
index ee68ae4..64a68f6 100644
--- a/gettext-tools/src/msgl-check.c
+++ b/gettext-tools/src/msgl-check.c
@@ -777,8 +777,18 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
for (cnt = 0; cnt < nfields; ++cnt)
{
+ /* 0.19 change: It would better report error if a required
+ header field is missing. However, traditionally we didn't
+ treat it as error. Let's wait for one or two cycles until we
+ can assume the required header fields are always
+ available in practical PO files. */
+#if 0
int severity =
(cnt < nrequiredfields ? PO_SEVERITY_ERROR : PO_SEVERITY_WARNING);
+#else
+ int severity =
+ PO_SEVERITY_WARNING;
+#endif
const char *field = required_fields[cnt];
size_t len = strlen (field);
const char *line;
@@ -805,7 +815,8 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
field);
po_xerror (severity, mp, NULL, 0, 0, true, msg);
free (msg);
- seen_errors++;
+ if (severity == PO_SEVERITY_ERROR)
+ seen_errors++;
}
}
break;
@@ -821,7 +832,8 @@ check_header_entry (const message_ty *mp, const char *msgstr_string)
field);
po_xerror (severity, mp, NULL, 0, 0, true, msg);
free (msg);
- seen_errors++;
+ if (severity == PO_SEVERITY_ERROR)
+ seen_errors++;
}
}
return seen_errors;
diff --git a/gettext-tools/tests/msgfmt-10 b/gettext-tools/tests/msgfmt-10
index 03ee55b..d747cf8 100755
--- a/gettext-tools/tests/msgfmt-10
+++ b/gettext-tools/tests/msgfmt-10
@@ -48,7 +48,6 @@ msgstr ""
"Project-Id-Version: GNU bison\n"
"PO-Revision-Date: 2001-04-05 19:47+0200\n"
"Last-Translator: ABC DEF <abc@gnu.uucp>\n"
-"Language-Team: test <test@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-9\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -68,9 +67,10 @@ ${MSGFMT} --check -o /dev/null mf-test10.po2 \
2>&1 | grep -v '^==' | sed -e 's|[^ ]*\\msgfmt\.exe|msgfmt|' -e 's|^msgfmt\.exe|msgfmt|' | LC_ALL=C tr -d '\r' > mf-test10.err
cat << EOF > mf-test10.ok
+mf-test10.po2:6: warning: header field 'Language-Team' missing in header
mf-test10.po2:6: warning: header field 'Language' missing in header
-mf-test10.po2:20: number of format specifications in 'msgid_plural' and 'msgstr[1]' does not match
-msgfmt: found 2 fatal errors
+mf-test10.po2:19: number of format specifications in 'msgid_plural' and 'msgstr[1]' does not match
+msgfmt: found 1 fatal error
EOF
: ${DIFF=diff}
--
1.9.0

View File

@ -6,7 +6,7 @@
Summary: GNU libraries and utilities for producing multi-lingual messages
Name: gettext
Version: 0.19.1
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3+ and LGPLv2+
Group: Development/Tools
URL: http://www.gnu.org/software/gettext/
@ -329,6 +329,10 @@ fi
%{_emacs_sitelispdir}/%{name}/*.el
%changelog
* Mon Jul 7 2014 Daiki Ueno <dueno@redhat.com> - 0.19.1-2
- apply patch to msghack.py, for Python 3 compatibility (Closes: #1113425,
thanks to Bohuslav "Slavek" Kabrda)
* Tue Jun 10 2014 Daiki Ueno <dueno@redhat.com> - 0.19.1-1
- update to 0.19.1 release
- switch to xz-compressed archive

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2
## -*- coding: utf-8 -*-
## Copyright (C) 2001, 2004, 2008, 2012 Red Hat, Inc.
## Copyright (C) 2001 Trond Eivind Glomsrød <teg@redhat.com>
@ -20,7 +20,6 @@
A msghack replacement
"""
import string
import sys
class GTMessage:
@ -35,8 +34,8 @@ class GTMessage:
@message The message
@id The messageid associated with the object
"""
self._message=string.strip(message)
self._id=string.strip(id)
self._message=message.strip()
self._id=id.strip()
self._refs=[]
for ref in refs:
self._refs.append(ref)
@ -178,7 +177,7 @@ class GTFile:
msgar.append(GTMessage(message._id,message._message,message._refs))
continue
msg=GTMessage(message._message,message._id,message._refs)
if not msght.has_key(msg._id):
if msg._id not in msght:
msght[msg._id]=msg
msgar.append(msg)
else:
@ -199,7 +198,7 @@ class GTFile:
res=""
for message in self._messages:
msgid=message._id
if msgids.has_key(msgid):
if msgid in msgids:
res=res+"Duplicate: %s\n" % (msgid)
else:
msgids[msgid]=1
@ -259,12 +258,12 @@ class GTFile:
inmsgstr=0
templines=file.readlines()
for line in templines:
lines.append(string.strip(line))
lines.append(line.strip())
for line in lines:
pos=string.find(line,'"')
pos2=string.rfind(line,'"')
pos=line.find('"')
pos2=line.rfind('"')
if line and line[0]=="#":
refs.append(string.strip(line))
refs.append(line.strip())
if inmsgstr==0 and line[:6]=="msgstr":
msgstr=""
inmsgstr=1
@ -342,7 +341,7 @@ class GTMaster:
def printUsage():
"Print the usage messages"
print "Usage: ", str(sys.argv[0])," [OPTION] file.po [ref.po]\n\
print("Usage: ", str(sys.argv[0])," [OPTION] file.po [ref.po]\n\
This program can be used to alter .po files in ways no sane mind would think about.\n\
-o result will be written to FILE\n\
--invert invert a po file by switching msgid and msgstr\n\
@ -350,26 +349,26 @@ This program can be used to alter .po files in ways no sane mind would think abo
--empty empty the contents of the .po file, creating a .pot\n\
--append append entries from ref.po that don't exist in file.po\n\
\n\
Note: It is just a replacement of msghack for backward support.\n"
Note: It is just a replacement of msghack for backward support.\n")
if __name__=="__main__":
output=None
res=None
if("-o") in sys.argv:
if (len(sys.argv)<=sys.argv.index("-o")+1):
print "file.po and ref.po are not specified!\n"
printUsage()
exit(1)
output=sys.argv[sys.argv.index("-o")+1]
if (len(sys.argv)<=sys.argv.index("-o")+1):
print("file.po and ref.po are not specified!\n")
printUsage()
exit(1)
output=sys.argv[sys.argv.index("-o")+1]
sys.argv.remove("-o")
sys.argv.remove(output)
sys.argv.remove(output)
if("--invert") in sys.argv:
if (len(sys.argv)<=sys.argv.index("--invert")+1):
print "file.po is not specified!\n"
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--invert")+1]
if (len(sys.argv)<=sys.argv.index("--invert")+1):
print("file.po is not specified!\n")
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--invert")+1]
gtf=GTFile(file)
res1=gtf.msgidDupes()
if res1:
@ -377,41 +376,41 @@ if __name__=="__main__":
sys.exit(1)
res=str(gtf.invertedStrings())
elif("--empty") in sys.argv:
if (len(sys.argv)<=sys.argv.index("--empty")+1):
print "file.po is not specified!\n"
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--empty")+1]
if (len(sys.argv)<=sys.argv.index("--empty")+1):
print("file.po is not specified!\n")
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--empty")+1]
gtf=GTFile(file)
res=str(gtf.emptyMsgStrings())
elif("--master") in sys.argv:
if (len(sys.argv)<=sys.argv.index("--master")+1):
print "file.po is not specified!\n"
printUsage()
exit(1)
loc=sys.argv.index("--master")+1
if (len(sys.argv)<=sys.argv.index("--master")+1):
print("file.po is not specified!\n")
printUsage()
exit(1)
loc=sys.argv.index("--master")+1
gtfs=[]
for file in sys.argv[loc:]:
gtfs.append(GTFile(file))
master=GTMaster(gtfs)
res=str(master)
elif("--append") in sys.argv:
if (len(sys.argv)<=sys.argv.index("--append")+2):
print "file.po and/or ref.po are not specified!\n"
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--append")+1]
if (len(sys.argv)<=sys.argv.index("--append")+2):
print("file.po and/or ref.po are not specified!\n")
printUsage()
exit(1)
file=sys.argv[sys.argv.index("--append")+1]
file2=sys.argv[sys.argv.index("--append")+2]
gtf=GTFile(file)
gtf2=GTFile(file2)
gtf.append(gtf2)
res=str(gtf)
else:
#print "Not implemented: "+str(sys.argv)
printUsage()
#print("Not implemented: "+str(sys.argv))
printUsage()
sys.exit(1)
if not output:
print res
print(res)
else:
file=open(output,"w")
file.write(res)