Merge lp:~vorlon/apt-ddtp-tools/trunk into lp:apt-ddtp-tools

Proposed by Steve Langasek
Status: Needs review
Proposed branch: lp:~vorlon/apt-ddtp-tools/trunk
Merge into: lp:apt-ddtp-tools
Diff against target: 286 lines (+45/-53)
8 files modified
UbuntuChecklist (+11/-9)
po2translation.py (+14/-14)
potmodify.py (+1/-1)
series.sh (+1/-3)
translation2po.py (+8/-8)
ubuntu/packages/ddtp-upload/debian/changelog (+6/-0)
ubuntu/verify-translation-file.py (+3/-3)
utils.py (+1/-15)
To merge this branch: bzr merge lp:~vorlon/apt-ddtp-tools/trunk
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+441028@code.launchpad.net
To post a comment you must log in.
lp:~vorlon/apt-ddtp-tools/trunk updated
109. By Steve Langasek

Update release codenames to something recent ('lunar' instead of 'lucid'). Point to the option to do a one-time translation import instead of telling people to prod the LP devs.

Unmerged revisions

109. By Steve Langasek

Update release codenames to something recent ('lunar' instead of 'lucid'). Point to the option to do a one-time translation import instead of telling people to prod the LP devs.

108. By Steve Langasek

update for lunar

107. By Steve Langasek

python2->python3

106. By Steve Langasek

apt_pkg: bytes not string

105. By Steve Langasek

python2->python3

104. By Steve Langasek

Spelling

103. By Steve Langasek

bytes vs str vs unicode, python2 vs python3

102. By Steve Langasek

It *says* it only understands strings and files, but it actually only understands bytes

101. By Steve Langasek

python3 whitespace

100. By Steve Langasek

More python2->python3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UbuntuChecklist'
--- UbuntuChecklist 2020-04-16 12:01:22 +0000
+++ UbuntuChecklist 2023-04-14 03:34:28 +0000
@@ -18,30 +18,32 @@
18Most data is imported and exported via bzr now, you need the18Most data is imported and exported via bzr now, you need the
19dirs:19dirs:
2020
21ubuntu/bzr-po-exports/bzr-ddtp-ubuntu-lucid that links to21ubuntu/bzr-po-exports/bzr-ddtp-ubuntu-lunar that points to
22lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lucid for the exported po files22lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lunar for the exported po files
2323
24ubuntu/bzr-pot-imports/bzr-ddtp-pot-lucid that links to24ubuntu/bzr-pot-imports/bzr-ddtp-pot-lunar that points to
25lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-pot-lucid for the pot files that LP25lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-pot-lunar for the pot files that LP
26will import from you26will import from you
2727
2828
29== Opening a new series (for a new ubuntu release) ==29== Opening a new series (for a new ubuntu release) ==
3030
31Go to https://launchpad.net/ddtp-ubuntu/+addseries and add something31Go to https://launchpad.net/ddtp-ubuntu/+addseries and add something
32like: "natty", "The translations for Ubuntu 11.04 'natty'".32like: "lunar", "The translations for Ubuntu 23.04 'lunar'".
3333
34Go to34Go to
35https://translations.launchpad.net/ddtp-ubuntu/natty/+translations-settings35https://translations.launchpad.net/ddtp-ubuntu/lunar/+translations-settings
36and select target branch like "lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-natty" and36and select target branch like "lp:~ubuntu-core-dev/ddtp-ubuntu/ddtp-lunar" and
37make sure to set the syncronisation settings to import "pot and37make sure to set the syncronisation settings to import "pot and
38translations".38translations".
3939
40Upload pot files and wait/prod LP devs to import them.40Push your branch containing the pot files and then request a one-time
41translation import at
42https://translations.launchpad.net/ddtp-ubuntu/lunar/+request-bzr-import
4143
42== Support for alternative series ==44== Support for alternative series ==
4345
44If a update is needed for a alternative series (like "lucid"),46If an update is needed for an alternative series (like "kinetic"),
45you need to alter the file "series.sh". Then everything should47you need to alter the file "series.sh". Then everything should
46work magically.48work magically.
4749
4850
=== modified file 'po2translation.py'
--- po2translation.py 2020-04-16 12:01:22 +0000
+++ po2translation.py 2023-04-14 03:34:28 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python21#!/usr/bin/python3
22
3import apt_pkg3import apt_pkg
4import gettext4import gettext
@@ -29,13 +29,13 @@
29 have_translation=False29 have_translation=False
30 try:30 try:
31 (short_descr, long_descr_chunks) = parse_descr(descr)31 (short_descr, long_descr_chunks) = parse_descr(descr)
32 except UnicodeDecodeError, e:32 except UnicodeDecodeError as e:
33 logging.warn("decoding of '%s' failed, ignoring (not utf8?)" % descr)33 logging.warn("decoding of '%s' failed, ignoring (not utf8?)" % descr)
34 return ""34 return ""
3535
36 # we need it as a unicode type so that twrap later works correctly36 # we need it as a unicode type so that twrap later works correctly
37 # FIXME: use ugettext() instead37 # FIXME: use ugettext() instead
38 short_descr_trans = utf8_str_to_unicode_type(translation.gettext(short_descr))38 short_descr_trans = translation.gettext(short_descr)
39 if short_descr_trans is None:39 if short_descr_trans is None:
40 logging.debug("Found empty translation chunk for '%s'" % pkg)40 logging.debug("Found empty translation chunk for '%s'" % pkg)
41 # we have no translation for this chunk41 # we have no translation for this chunk
@@ -50,12 +50,12 @@
50 if chunk == "":50 if chunk == "":
51 chunk_translated = ""51 chunk_translated = ""
52 else:52 else:
53 chunk_translated = utf8_str_to_unicode_type(translation.gettext(chunk))53 chunk_translated = translation.gettext(chunk)
54 # *sigh* more hacks, the theory is that a test54 # *sigh* more hacks, the theory is that a test
55 # like if chunk.count("\n") > 1 means we need55 # like if chunk.count("\n") > 1 means we need
56 # to strip away the final newline56 # to strip away the final newline
57 if not chunk_translated:57 if not chunk_translated:
58 chunk_translated = utf8_str_to_unicode_type(translation.gettext(chunk[:-1]))58 chunk_translated = translation.gettext(chunk[:-1])
59 59
60 # check if we only do full translation records60 # check if we only do full translation records
61 if not chunk_translated:61 if not chunk_translated:
@@ -77,7 +77,7 @@
77 # build a Translation package record77 # build a Translation package record
78 res = ""78 res = ""
79 res = "Package: %s\n" % pkg79 res = "Package: %s\n" % pkg
80 res += "Description-md5: %s\n" % str(apt_pkg.md5sum(descr+"\n"))80 res += "Description-md5: %s\n" % str(apt_pkg.md5sum(descr.encode()+b"\n"))
81 res += "Description-%s: %s\n" % (lang, short_descr_trans)81 res += "Description-%s: %s\n" % (lang, short_descr_trans)
82 long_descr_str = ""82 long_descr_str = ""
83 for chunk in long_descr_chunks_trans:83 for chunk in long_descr_chunks_trans:
@@ -102,7 +102,7 @@
102 long_descr_str += "\n .\n%s" % chunk102 long_descr_str += "\n .\n%s" % chunk
103 res += "%s\n\n" % long_descr_str103 res += "%s\n\n" % long_descr_str
104 # convert back to a utf8 encoded string104 # convert back to a utf8 encoded string
105 return unicode_type_to_utf8_str(res)105 return res
106106
107def po2translation(inf, out, pofile, lang, fulltrans=False):107def po2translation(inf, out, pofile, lang, fulltrans=False):
108 if not os.path.exists("mo/%s/LC_MESSAGES" % lang):108 if not os.path.exists("mo/%s/LC_MESSAGES" % lang):
@@ -112,7 +112,7 @@
112 localedir= os.getcwd()+"/mo"112 localedir= os.getcwd()+"/mo"
113 translation = gettext.translation('packages', localedir, [lang])113 translation = gettext.translation('packages', localedir, [lang])
114 if not translation:114 if not translation:
115 print "Error creating translation object"115 print("Error creating translation object")
116 sys.exit(1)116 sys.exit(1)
117 translation.add_fallback(NoneTranslationFallback())117 translation.add_fallback(NoneTranslationFallback())
118118
@@ -132,13 +132,13 @@
132132
133133
134if __name__ == "__main__":134if __name__ == "__main__":
135 logging.basicConfig(level=logging.INFO, 135 logging.basicConfig(level=logging.INFO,
136 format="%(asctime)s %(message)s")136 format="%(asctime)s %(message)s")
137137
138 if len(sys.argv) < 4:138 if len(sys.argv) < 4:
139 print "need a Packages file a po file and a language as argument"139 print("need a Packages file a po file and a language as argument")
140 print "it will search for the mo file in "140 print("it will search for the mo file in ")
141 print "mo/$lang/LC_MESSAGES/packages.mo"141 print("mo/$lang/LC_MESSAGES/packages.mo")
142 sys.exit(1)142 sys.exit(1)
143143
144 inf = open(sys.argv[1])144 inf = open(sys.argv[1])
@@ -154,5 +154,5 @@
154 logging.error("Can't find '%s', exiting" % pofile)154 logging.error("Can't find '%s', exiting" % pofile)
155 sys.exit(1)155 sys.exit(1)
156156
157 logging.debug("working on %s" % pofile)157 logging.debug("working on %s" % pofile)
158 po2translation(inf, out, pofile, lang, fulltrans)158 po2translation(inf, out, pofile, lang, fulltrans)
159159
=== modified file 'potmodify.py'
--- potmodify.py 2020-04-16 12:01:22 +0000
+++ potmodify.py 2023-04-14 03:34:28 +0000
@@ -1,4 +1,4 @@
1#! /usr/bin/python21#! /usr/bin/python3
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# Copyright (C) 2008 István Nyitrai <sianis@gmail.com>4# Copyright (C) 2008 István Nyitrai <sianis@gmail.com>
55
=== modified file 'series.sh'
--- series.sh 2020-04-16 12:01:22 +0000
+++ series.sh 2023-04-14 03:34:28 +0000
@@ -1,7 +1,5 @@
11
2# the series to use (default auto-detect)2# the series to use (default auto-detect)
3#SERIES=$(lsb_release -s -c)3SERIES="$(distro-info -d)"
4SERIES="focal"
54
6DIST="$SERIES"5DIST="$SERIES"
7
86
=== modified file 'translation2po.py'
--- translation2po.py 2020-04-16 12:01:22 +0000
+++ translation2po.py 2023-04-14 03:34:28 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python21#!/usr/bin/python3
22
3import string3import string
4import apt_pkg4import apt_pkg
@@ -110,7 +110,7 @@
110"Content-Transfer-Encoding: 8bit\\n"110"Content-Transfer-Encoding: 8bit\\n"
111\n111\n
112""")112""")
113 all_chunks = set()113 all_chunks = set()
114 parser = apt_pkg.TagFile(inf)114 parser = apt_pkg.TagFile(inf)
115 parser_trans = apt_pkg.TagFile(open(transf))115 parser_trans = apt_pkg.TagFile(open(transf))
116 while parser.step():116 while parser.step():
@@ -122,13 +122,13 @@
122 # we have a descr for that pkg122 # we have a descr for that pkg
123 if descr != None and descr_trans != None:123 if descr != None and descr_trans != None:
124 md5_trans = parser_trans.section.get("Description-md5")124 md5_trans = parser_trans.section.get("Description-md5")
125 md5 = str(apt_pkg.md5sum(descr+"\n"))125 md5 = str(apt_pkg.md5sum(descr.encode()+b"\n"))
126 #print "'%s'" % descr126 #print "'%s'" % descr
127 #print "'%s'" % descr_trans127 #print "'%s'" % descr_trans
128 #print "md5: %s -> trans: %s " % (md5, md5_trans)128 #print "md5: %s -> trans: %s " % (md5, md5_trans)
129 if md5 == md5_trans:129 if md5 == md5_trans:
130 res = descr_to_po(pkg, descr, descr_trans, all_chunks)130 res = descr_to_po(pkg, descr, descr_trans, all_chunks)
131 out.write(res.encode('utf-8'))131 out.write(res)
132132
133133
134if __name__ == "__main__":134if __name__ == "__main__":
@@ -136,10 +136,10 @@
136 #sys.exit(1)136 #sys.exit(1)
137137
138 if len(sys.argv) < 4:138 if len(sys.argv) < 4:
139 print "%s Packages Translation lang" % sys.argv[0]139 print("%s Packages Translation lang" % sys.argv[0])
140 print "need a Packages file and a Translation-$LANG file "140 print("need a Packages file and a Translation-$LANG file ")
141 print "and a lang (e.g. Packages Translation-de de) "141 print("and a lang (e.g. Packages Translation-de de) ")
142 print " it will generate a po file from that"142 print(" it will generate a po file from that")
143 sys.exit(1)143 sys.exit(1)
144144
145 inf = open(sys.argv[1])145 inf = open(sys.argv[1])
146146
=== modified file 'ubuntu/packages/ddtp-upload/debian/changelog'
--- ubuntu/packages/ddtp-upload/debian/changelog 2020-04-16 12:01:22 +0000
+++ ubuntu/packages/ddtp-upload/debian/changelog 2023-04-14 03:34:28 +0000
@@ -1,3 +1,9 @@
1ddtp-translations (20230413.1) lunar; urgency=medium
2
3 * new translations update
4
5 -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 13 Apr 2023 19:13:28 -0700
6
1ddtp-translations (20200110.1) focal; urgency=medium7ddtp-translations (20200110.1) focal; urgency=medium
28
3 * new translations update9 * new translations update
410
=== modified file 'ubuntu/verify-translation-file.py'
--- ubuntu/verify-translation-file.py 2020-04-16 12:01:22 +0000
+++ ubuntu/verify-translation-file.py 2023-04-14 03:34:28 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python21#!/usr/bin/python3
22
3import apt_pkg3import apt_pkg
4import sys4import sys
@@ -13,8 +13,8 @@
13 tf.section.get("Package") and 13 tf.section.get("Package") and
14 tf.section.get("Description-md5") and14 tf.section.get("Description-md5") and
15 tf.section.get("Description-%s" % locale)):15 tf.section.get("Description-%s" % locale)):
16 print "Invalid: '%s'" % tf.section16 print("Invalid: '%s'" % tf.section)
17 print17 print()
18 bad = True18 bad = True
19 break19 break
2020
2121
=== modified file 'utils.py'
--- utils.py 2020-04-16 12:01:22 +0000
+++ utils.py 2023-04-14 03:34:28 +0000
@@ -8,18 +8,6 @@
8 return string.encode('utf-8')8 return string.encode('utf-8')
9 return unicode(string, 'latin1').encode('utf-8')9 return unicode(string, 'latin1').encode('utf-8')
1010
11def utf8_str_to_unicode_type(s):
12 """ take a utf8 encoded str and return a unicode object """
13 if not s:
14 return s
15 return s.decode('utf-8')
16
17def unicode_type_to_utf8_str(u):
18 """ take a unicode object and return a utf8 encoded str object """
19 if not u:
20 return u
21 return u.encode('utf-8')
22
23def parse_descr(descr):11def parse_descr(descr):
24 """ input. debian description (str)12 """ input. debian description (str)
25 output (short_descr: (str), long_descr_chunks: (list of str)13 output (short_descr: (str), long_descr_chunks: (list of str)
@@ -34,7 +22,6 @@
34 short_descr = raw.strip()22 short_descr = raw.strip()
35 # new chunk23 # new chunk
36 elif raw.strip() == ".":24 elif raw.strip() == ".":
37 current = utf8_str_to_unicode_type(current)
38 long_descr_chunks.append(current)25 long_descr_chunks.append(current)
39 current = ""26 current = ""
40 # two spaces is handled differently (as a raw format, see debian policy)27 # two spaces is handled differently (as a raw format, see debian policy)
@@ -57,9 +44,8 @@
57 else:44 else:
58 current = raw.strip()45 current = raw.strip()
59 # add last chunk46 # add last chunk
60 current = utf8_str_to_unicode_type(current)
61 long_descr_chunks.append(current)47 long_descr_chunks.append(current)
62 return (utf8_str_to_unicode_type(short_descr), long_descr_chunks)48 return (short_descr, long_descr_chunks)
6349
6450
6551

Subscribers

People subscribed via source and target branches

to all changes: