Merge lp:~henninge/launchpad/recife-gettext-check-messages into lp:~launchpad/launchpad/recife

Proposed by Henning Eggers on 2010-11-18
Status: Merged
Approved by: Gavin Panella on 2010-11-18
Approved revision: no longer in the source branch.
Merged at revision: 9200
Proposed branch: lp:~henninge/launchpad/recife-gettext-check-messages
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 193 lines (+42/-43)
2 files modified
lib/lp/translations/doc/gettext-check-messages.txt (+34/-38)
lib/lp/translations/scripts/gettext_check_messages.py (+8/-5)
To merge this branch: bzr merge lp:~henninge/launchpad/recife-gettext-check-messages
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2010-11-18 Approve on 2010-11-18
Review via email: mp+41155@code.launchpad.net

Description of the Change

== Details ==

Updates the gettext-check-messages script to use "upstream" and "ubuntu" instead of "imported" and "current" and also make the treatment of both symmetric. The essence of the latter is that both the is_current_upstream flag and the is_current_ubuntu flag are unset if the message has an error whereas before "imported" messages where left unchanged.

== Test ==

bin/test -vvm lp.translations -t gettext-check-messages

== Lint ==

Lint complains about Moin headers in the test but that should be fixed in devel or even the test converted to a uinttest.

To post a comment you must log in.
Henning Eggers (henninge) wrote :

Some background for the non-translations reviewer:
One of the main changes in the recife feature branch is that the concept of "imported" and "current" translations was replaced by "upstream" and "ubuntu" translations. Thus the "is_imported" flag on a TranslationMessage was renamed to "is_current_upstream" and the "is_current" flag to "is_current_ubuntu". The semantics around these flags were also changed as the one refers to a project while the other to the ubuntu package that this project is linked to.

Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/doc/gettext-check-messages.txt'
2--- lib/lp/translations/doc/gettext-check-messages.txt 2010-09-06 10:40:54 +0000
3+++ lib/lp/translations/doc/gettext-check-messages.txt 2010-11-18 15:04:11 +0000
4@@ -51,8 +51,8 @@
5
6 >>> UTC = timezone('UTC')
7
8- >>> nl_file = factory.makePOFile('nl')
9- >>> template = nl_file.potemplate
10+ >>> pofile = factory.makePOFile()
11+ >>> template = pofile.potemplate
12
13 A sample translatable message is flagged as containing a C-style format
14 string. This means that any "%d" sequences and such are significant.
15@@ -65,24 +65,24 @@
16 >>> potmsgset.flags
17 [u'c-format']
18
19-The sample message has an imported translation, and a current
20-translation in Launchpad that differs from the imported one.
21+The sample message has an upstream translation, and an Ubuntu
22+in Launchpad that differs from the upstream one.
23
24- >>> current_message = factory.makeTranslationMessage(
25- ... pofile=nl_file, potmsgset=potmsgset, translator=template.owner,
26+ >>> ubuntu_message = factory.makeTranslationMessage(
27+ ... pofile=pofile, potmsgset=potmsgset, translator=template.owner,
28 ... reviewer=template.owner, translations=[u'%d c'])
29- >>> current_message = removeSecurityProxy(current_message)
30+ >>> ubuntu_message = removeSecurityProxy(ubuntu_message)
31
32- >>> imported_message = factory.makeTranslationMessage(
33- ... pofile=nl_file, potmsgset=potmsgset, translator=template.owner,
34+ >>> upstream_message = factory.makeTranslationMessage(
35+ ... pofile=pofile, potmsgset=potmsgset, translator=template.owner,
36 ... reviewer=template.owner, translations=[u'%d i'],
37 ... lock_timestamp=datetime.now(UTC))
38- >>> imported_message = removeSecurityProxy(imported_message)
39+ >>> upstream_message = removeSecurityProxy(upstream_message)
40
41- >>> imported_message.is_current_ubuntu = False
42- >>> current_message.is_current_upstream = False
43- >>> imported_message.is_current_upstream = True
44- >>> current_message.is_current_ubuntu = True
45+ >>> upstream_message.is_current_ubuntu = False
46+ >>> ubuntu_message.is_current_upstream = False
47+ >>> upstream_message.is_current_upstream = True
48+ >>> ubuntu_message.is_current_ubuntu = True
49
50
51 == Basic operation ==
52@@ -91,7 +91,7 @@
53 and re-does the gettext check. Which messages it checks is specified as
54 a plain SQL WHERE clause.
55
56- >>> run_checker(['-vv', "-w id=%s" % quote(current_message.id)])
57+ >>> run_checker(['-vv', "-w id=%s" % quote(ubuntu_message.id)])
58 DEBUG Checking messages matching: id=...
59 DEBUG Checking message ...
60 DEBUG Commit point.
61@@ -108,15 +108,15 @@
62 If a translation fails to validate against its potmsgset, the script
63 detects the problem when it checks that message.
64
65- >>> current_message.is_current_ubuntu
66+ >>> ubuntu_message.is_current_ubuntu
67 True
68
69- >>> current_message.translations = [u'%s c']
70+ >>> ubuntu_message.translations = [u'%s c']
71
72- >>> run_checker(["-w id=%s" % quote(current_message.id)])
73+ >>> run_checker(["-w id=%s" % quote(ubuntu_message.id)])
74 DEBUG Checking messages matching: id=...
75 DEBUG Checking message ...
76- INFO ... (current): format specifications ... are not the same
77+ INFO ... (ubuntu): format specifications ... are not the same
78 DEBUG Commit point.
79 COMMIT
80 DEBUG Commit point.
81@@ -129,17 +129,17 @@
82
83 The failed message is demoted to a mere suggestion.
84
85- >>> current_message.is_current_ubuntu
86+ >>> ubuntu_message.is_current_ubuntu
87 False
88
89
90 == Output ==
91
92-Besides current messages, the script's output also distinguishes
93-imported ones, and ones that are completely unused. The imported message
94+Besides Ubuntu messages, the script's output also distinguishes
95+upstream ones, and ones that are completely unused. The upstream message
96 happens to produce validation errors.
97
98- >>> imported_message.translations = [u'%s %s i']
99+ >>> upstream_message.translations = [u'%s %s i']
100
101 In this example we'd like to see a nicely predictable ordering, so we
102 add a sort order using the -o option.
103@@ -151,39 +151,35 @@
104 DEBUG Commit point.
105 COMMIT
106 DEBUG Checking message ...
107- INFO ... (imported): number of format specifications ... does not match...
108+ INFO ... (upstream): number of format specifications ... does not match...
109 DEBUG Commit point.
110 COMMIT
111 INFO Done.
112 INFO Messages checked: 2
113 INFO Validation errors: 2
114- INFO Messages disabled: 0
115+ INFO Messages disabled: 1
116 INFO Commit points: 2
117
118-In this case the imported message is checked twice: once all by itself
119-and once as a potential alternative to the current message. That's why
120-the number of validation errors is greater than the number of messages
121-checked.
122-
123-The script also notes when a message is both current and imported.
124-
125- >>> imported_message.is_current_ubuntu = True
126- >>> run_checker(["-w id=%s" % quote(imported_message.id)])
127+The script also notes when a message is shared between upstream and Ubuntu.
128+
129+ >>> upstream_message.is_current_ubuntu = True
130+ >>> upstream_message.is_current_upstream = True
131+ >>> run_checker(["-w id=%s" % quote(upstream_message.id)])
132 DEBUG ...
133- INFO ... (current, imported): number of format specifications ...
134+ INFO ... (ubuntu, upstream): number of format specifications ...
135
136
137 == Dry runs ==
138
139 The --dry-run option makes the script abort all its database changes.
140
141- >>> current_message.is_current_ubuntu = True
142+ >>> ubuntu_message.is_current_ubuntu = True
143
144- >>> run_checker(["-w id=%s" % quote(current_message.id), '--dry-run'])
145+ >>> run_checker(["-w id=%s" % quote(ubuntu_message.id), '--dry-run'])
146 INFO Dry run. Not making any changes.
147 DEBUG Checking messages matching: id=...
148 DEBUG Checking message ...
149- INFO ... (current): format specifications ... are not the same
150+ INFO ... (ubuntu): format specifications ... are not the same
151 DEBUG Commit point.
152 ABORT
153 DEBUG Commit point.
154
155=== modified file 'lib/lp/translations/scripts/gettext_check_messages.py'
156--- lib/lp/translations/scripts/gettext_check_messages.py 2010-09-28 14:06:50 +0000
157+++ lib/lp/translations/scripts/gettext_check_messages.py 2010-11-18 15:04:11 +0000
158@@ -37,8 +37,7 @@
159
160 This script takes a given set of messages (specified as an SQL
161 "WHERE" clause) and checks each of them. Messages that are found
162- faulty are deactivated, and where appropriate, imported messages
163- they were overriding are activated instead.
164+ faulty are deactivated.
165 """
166
167 _check_count = 0
168@@ -80,9 +79,9 @@
169 """Report gettext validation error for active message."""
170 currency_markers = []
171 if bad_message.is_current_ubuntu:
172- currency_markers.append('current')
173+ currency_markers.append('ubuntu')
174 if bad_message.is_current_upstream:
175- currency_markers.append('imported')
176+ currency_markers.append('upstream')
177 if currency_markers == []:
178 currency_markers.append('unused')
179 currency = ', '.join(currency_markers)
180@@ -117,8 +116,12 @@
181 # instead of the bad one.
182
183 self._log_bad_message(translationmessage, error)
184- if translationmessage.is_current_ubuntu:
185+ is_current_anywhere = (
186+ translationmessage.is_current_ubuntu or
187+ translationmessage.is_current_upstream)
188+ if is_current_anywhere:
189 translationmessage.is_current_ubuntu = False
190+ translationmessage.is_current_upstream = False
191 self._disable_count += 1
192
193 def _do_commit(self):

Subscribers

People subscribed via source and target branches