Merge lp:~jtv/launchpad/bug-662552-get-tm-or-dummy into lp:launchpad
- bug-662552-get-tm-or-dummy
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11811 |
Proposed branch: | lp:~jtv/launchpad/bug-662552-get-tm-or-dummy |
Merge into: | lp:launchpad |
Diff against target: |
674 lines (+102/-182) 10 files modified
lib/lp/translations/browser/pofile.py (+3/-22) lib/lp/translations/browser/tests/translationmessage-views.txt (+27/-15) lib/lp/translations/browser/translationmessage.py (+17/-44) lib/lp/translations/doc/canonical_url_examples.txt (+4/-4) lib/lp/translations/doc/potmsgset.txt (+7/-29) lib/lp/translations/doc/translationmessage.txt (+13/-12) lib/lp/translations/interfaces/potmsgset.py (+8/-8) lib/lp/translations/model/potmsgset.py (+7/-11) lib/lp/translations/model/translationmessage.py (+0/-7) lib/lp/translations/tests/test_potmsgset.py (+16/-30) |
To merge this branch: | bzr merge lp:~jtv/launchpad/bug-662552-get-tm-or-dummy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+39467@code.launchpad.net |
Commit message
Streamline IPOTMsgSet.
Description of the change
= Bug 662552: Streamline getCurrentDummy
We're getting timeouts on the POFile:+translate page, so I'm fixing up a bunch of relatively non-invasive things that it wastes time on.
In this case, it's IPOTMsgSet.
message = potmsgset.
if message is None:
message = potmsgset.
else:
(The message.setPOFile() part is a hack to get around the fact that some code still relies on TranslationMess
In this branch I replace the entire usage pattern with a single new method:
message = potmsgset.
pofile)
I also eliminated a few assertions that guarded the integrity of this pattern along the way, doing several redundant database lookups to ensure that there is no real current translation message before creating a dummy. That pattern is now explicit, and enshrined in a single place in the code.
About half of the branch is actually lint cleanup. There's a bit of lint left, but that's all related to blank lines around free-standing comment blocks. I'm not yet convinced that "make lint" has a creditable complaint.
Jeroen
Preview Diff
1 | === modified file 'lib/lp/translations/browser/pofile.py' | |||
2 | --- lib/lp/translations/browser/pofile.py 2010-08-31 11:11:09 +0000 | |||
3 | +++ lib/lp/translations/browser/pofile.py 2010-10-28 03:59:47 +0000 | |||
4 | @@ -87,20 +87,7 @@ | |||
5 | 87 | raise NotFoundError( | 87 | raise NotFoundError( |
6 | 88 | "%r is not a valid sequence number." % name) | 88 | "%r is not a valid sequence number." % name) |
7 | 89 | 89 | ||
22 | 90 | # Need to check in our database whether we have already the requested | 90 | return potmsgset.getCurrentTranslationMessageOrDummy(self.context) |
9 | 91 | # TranslationMessage. | ||
10 | 92 | translationmessage = potmsgset.getCurrentTranslationMessage( | ||
11 | 93 | self.context.potemplate, self.context.language) | ||
12 | 94 | |||
13 | 95 | if translationmessage is not None: | ||
14 | 96 | # Already have a valid POMsgSet entry, just return it. | ||
15 | 97 | translationmessage.setPOFile(self.context) | ||
16 | 98 | return translationmessage | ||
17 | 99 | else: | ||
18 | 100 | # Get a fake one so we don't create new TranslationMessage just | ||
19 | 101 | # because someone is browsing the web. | ||
20 | 102 | return potmsgset.getCurrentDummyTranslationMessage( | ||
21 | 103 | self.context.potemplate, self.context.language) | ||
23 | 104 | 91 | ||
24 | 105 | 92 | ||
25 | 106 | class POFileFacets(POTemplateFacets): | 93 | class POFileFacets(POTemplateFacets): |
26 | @@ -846,14 +833,8 @@ | |||
27 | 846 | "POTMsgSets on page not in ascending sequence order") | 833 | "POTMsgSets on page not in ascending sequence order") |
28 | 847 | last = potmsgset | 834 | last = potmsgset |
29 | 848 | 835 | ||
38 | 849 | translationmessage = potmsgset.getCurrentTranslationMessage( | 836 | translationmessage = ( |
39 | 850 | self.context.potemplate, self.context.language) | 837 | potmsgset.getCurrentTranslationMessageOrDummy(self.context)) |
32 | 851 | if translationmessage is None: | ||
33 | 852 | translationmessage = ( | ||
34 | 853 | potmsgset.getCurrentDummyTranslationMessage( | ||
35 | 854 | self.context.potemplate, self.context.language)) | ||
36 | 855 | else: | ||
37 | 856 | translationmessage.setPOFile(self.context) | ||
40 | 857 | view = self._prepareView( | 838 | view = self._prepareView( |
41 | 858 | CurrentTranslationMessageView, translationmessage, | 839 | CurrentTranslationMessageView, translationmessage, |
42 | 859 | self.errors.get(potmsgset)) | 840 | self.errors.get(potmsgset)) |
43 | 860 | 841 | ||
44 | === modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt' | |||
45 | --- lib/lp/translations/browser/tests/translationmessage-views.txt 2010-10-18 22:24:59 +0000 | |||
46 | +++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-10-28 03:59:47 +0000 | |||
47 | @@ -1,4 +1,5 @@ | |||
49 | 1 | = TranslationMessage View = | 1 | TranslationMessage View |
50 | 2 | ======================= | ||
51 | 2 | 3 | ||
52 | 3 | On this section, we are going to test the view class for an | 4 | On this section, we are going to test the view class for an |
53 | 4 | ITranslationMessage object. | 5 | ITranslationMessage object. |
54 | @@ -11,13 +12,14 @@ | |||
55 | 11 | >>> from lp.services.worlddata.interfaces.language import ILanguageSet | 12 | >>> from lp.services.worlddata.interfaces.language import ILanguageSet |
56 | 12 | >>> from lp.translations.publisher import TranslationsLayer | 13 | >>> from lp.translations.publisher import TranslationsLayer |
57 | 13 | 14 | ||
60 | 14 | All the tests will be submitted as comming from Kurem, an editor for the POFile | 15 | All the tests will be submitted as coming from Kurem, an editor for the |
61 | 15 | that we are going to edit. | 16 | POFile that we are going to edit. |
62 | 16 | 17 | ||
63 | 17 | >>> login('kurem@debian.cz') | 18 | >>> login('kurem@debian.cz') |
64 | 18 | 19 | ||
65 | 19 | 20 | ||
67 | 20 | == No plural forms == | 21 | No plural forms |
68 | 22 | --------------- | ||
69 | 21 | 23 | ||
70 | 22 | We are going to see what happens if we get an entry for a language | 24 | We are going to see what happens if we get an entry for a language |
71 | 23 | without the plural form information. | 25 | without the plural form information. |
72 | @@ -29,8 +31,7 @@ | |||
73 | 29 | >>> potmsgset = pofile_tlh.potemplate.getPOTMsgSetByMsgIDText( | 31 | >>> potmsgset = pofile_tlh.potemplate.getPOTMsgSetByMsgIDText( |
74 | 30 | ... u'evolution addressbook') | 32 | ... u'evolution addressbook') |
75 | 31 | >>> current_translationmessage = ( | 33 | >>> current_translationmessage = ( |
78 | 32 | ... potmsgset.getCurrentDummyTranslationMessage( | 34 | ... potmsgset.getCurrentTranslationMessageOrDummy(pofile_tlh)) |
77 | 33 | ... pofile_tlh.potemplate, pofile_tlh.language)) | ||
79 | 34 | >>> translationmessage_page_view = create_view( | 35 | >>> translationmessage_page_view = create_view( |
80 | 35 | ... current_translationmessage, "+translate", layer=TranslationsLayer) | 36 | ... current_translationmessage, "+translate", layer=TranslationsLayer) |
81 | 36 | >>> translationmessage_page_view.initialize() | 37 | >>> translationmessage_page_view.initialize() |
82 | @@ -46,7 +47,8 @@ | |||
83 | 46 | False | 47 | False |
84 | 47 | 48 | ||
85 | 48 | 49 | ||
87 | 49 | == Basic checks == | 50 | Basic checks |
88 | 51 | ------------ | ||
89 | 50 | 52 | ||
90 | 51 | Now, we will use objects that we have in our database, instead of | 53 | Now, we will use objects that we have in our database, instead of |
91 | 52 | dummy ones. | 54 | dummy ones. |
92 | @@ -79,7 +81,8 @@ | |||
93 | 79 | False | 81 | False |
94 | 80 | 82 | ||
95 | 81 | 83 | ||
97 | 82 | == The subview: TranslationMessageView == | 84 | The subview: TranslationMessageView |
98 | 85 | ----------------------------------- | ||
99 | 83 | 86 | ||
100 | 84 | For the next tests, we grab the subview which is what holds information | 87 | For the next tests, we grab the subview which is what holds information |
101 | 85 | that pertains to the POMsgSet rendering itself: | 88 | that pertains to the POMsgSet rendering itself: |
102 | @@ -145,7 +148,8 @@ | |||
103 | 145 | AssertionError: There is no plural form #1 for Spanish (es) language | 148 | AssertionError: There is no plural form #1 for Spanish (es) language |
104 | 146 | 149 | ||
105 | 147 | 150 | ||
107 | 148 | == Web presentation == | 151 | Web presentation |
108 | 152 | ---------------- | ||
109 | 149 | 153 | ||
110 | 150 | Some characters are presented specially in the Web interface, and there are | 154 | Some characters are presented specially in the Web interface, and there are |
111 | 151 | functions to determine whether to advise translators about their presence. | 155 | functions to determine whether to advise translators about their presence. |
112 | @@ -226,7 +230,8 @@ | |||
113 | 226 | >>> transaction.commit() | 230 | >>> transaction.commit() |
114 | 227 | 231 | ||
115 | 228 | 232 | ||
117 | 229 | == Submitting translations == | 233 | Submitting translations |
118 | 234 | ----------------------- | ||
119 | 230 | 235 | ||
120 | 231 | A new translation is submitted through the view. | 236 | A new translation is submitted through the view. |
121 | 232 | 237 | ||
122 | @@ -330,7 +335,8 @@ | |||
123 | 330 | [u'Foo'] | 335 | [u'Foo'] |
124 | 331 | 336 | ||
125 | 332 | 337 | ||
127 | 333 | == Bogus translation submission == | 338 | Bogus translation submission |
128 | 339 | ---------------------------- | ||
129 | 334 | 340 | ||
130 | 335 | What would happen if we get a submit for another msgset that isn't being | 341 | What would happen if we get a submit for another msgset that isn't being |
131 | 336 | considered? | 342 | considered? |
132 | @@ -362,7 +368,8 @@ | |||
133 | 362 | True | 368 | True |
134 | 363 | 369 | ||
135 | 364 | 370 | ||
137 | 365 | == TranslationMessageSuggestions == | 371 | TranslationMessageSuggestions |
138 | 372 | ----------------------------- | ||
139 | 366 | 373 | ||
140 | 367 | This class keeps all suggestions available for a concrete | 374 | This class keeps all suggestions available for a concrete |
141 | 368 | ITranslationMessage. | 375 | ITranslationMessage. |
142 | @@ -529,7 +536,8 @@ | |||
143 | 529 | 0 | 536 | 0 |
144 | 530 | 537 | ||
145 | 531 | 538 | ||
147 | 532 | == Sequence number of new shared POTMsgSets == | 539 | Sequence number of new shared POTMsgSets |
148 | 540 | ---------------------------------------- | ||
149 | 533 | 541 | ||
150 | 534 | Newly added shared POTMsgSets don't have their sequence field set, but | 542 | Newly added shared POTMsgSets don't have their sequence field set, but |
151 | 535 | they do have sequence number when being displayed with translation | 543 | they do have sequence number when being displayed with translation |
152 | @@ -556,7 +564,9 @@ | |||
153 | 556 | >>> subview.sequence | 564 | >>> subview.sequence |
154 | 557 | 1 | 565 | 1 |
155 | 558 | 566 | ||
157 | 559 | == Ordering with unset potemplate values == | 567 | |
158 | 568 | Ordering with unset potemplate values | ||
159 | 569 | ------------------------------------- | ||
160 | 560 | 570 | ||
161 | 561 | Fix for bug #371560: can be removed after message sharing cleanup is done. | 571 | Fix for bug #371560: can be removed after message sharing cleanup is done. |
162 | 562 | Code still uses potmsgset.potemplate when getting a sequence number, and | 572 | Code still uses potmsgset.potemplate when getting a sequence number, and |
163 | @@ -596,7 +606,9 @@ | |||
164 | 596 | ... server_url=server_url) | 606 | ... server_url=server_url) |
165 | 597 | >>> pofile_view.initialize() | 607 | >>> pofile_view.initialize() |
166 | 598 | 608 | ||
168 | 599 | == Sharing and diverging messages == | 609 | |
169 | 610 | Sharing and diverging messages | ||
170 | 611 | ------------------------------ | ||
171 | 600 | 612 | ||
172 | 601 | When there is an existing shared translation, one gets an option | 613 | When there is an existing shared translation, one gets an option |
173 | 602 | to diverge it when on a zoomed-in view (when looking that particular | 614 | to diverge it when on a zoomed-in view (when looking that particular |
174 | 603 | 615 | ||
175 | === modified file 'lib/lp/translations/browser/translationmessage.py' | |||
176 | --- lib/lp/translations/browser/translationmessage.py 2010-09-03 16:01:01 +0000 | |||
177 | +++ lib/lp/translations/browser/translationmessage.py 2010-10-28 03:59:47 +0000 | |||
178 | @@ -67,10 +67,6 @@ | |||
179 | 67 | ) | 67 | ) |
180 | 68 | from lp.translations.interfaces.translationsperson import ITranslationsPerson | 68 | from lp.translations.interfaces.translationsperson import ITranslationsPerson |
181 | 69 | 69 | ||
182 | 70 | # | ||
183 | 71 | # Exceptions and helper classes | ||
184 | 72 | # | ||
185 | 73 | |||
186 | 74 | 70 | ||
187 | 75 | class POTMsgSetBatchNavigator(BatchNavigator): | 71 | class POTMsgSetBatchNavigator(BatchNavigator): |
188 | 76 | 72 | ||
189 | @@ -143,9 +139,6 @@ | |||
190 | 143 | return contents | 139 | return contents |
191 | 144 | 140 | ||
192 | 145 | 141 | ||
193 | 146 | # | ||
194 | 147 | # Standard UI classes | ||
195 | 148 | # | ||
196 | 149 | class CurrentTranslationMessageFacets(POTemplateFacets): | 142 | class CurrentTranslationMessageFacets(POTemplateFacets): |
197 | 150 | usedfor = ITranslationMessage | 143 | usedfor = ITranslationMessage |
198 | 151 | 144 | ||
199 | @@ -176,9 +169,6 @@ | |||
200 | 176 | return Link('../+export', text, icon='download') | 169 | return Link('../+export', text, icon='download') |
201 | 177 | 170 | ||
202 | 178 | 171 | ||
203 | 179 | # | ||
204 | 180 | # Views | ||
205 | 181 | # | ||
206 | 182 | class CurrentTranslationMessageIndexView: | 172 | class CurrentTranslationMessageIndexView: |
207 | 183 | """A view to forward to the translation form.""" | 173 | """A view to forward to the translation form.""" |
208 | 184 | 174 | ||
209 | @@ -298,16 +288,16 @@ | |||
210 | 298 | 288 | ||
211 | 299 | if self.request.method == 'POST': | 289 | if self.request.method == 'POST': |
212 | 300 | if self.user is None: | 290 | if self.user is None: |
216 | 301 | raise UnexpectedFormData, ( | 291 | raise UnexpectedFormData( |
217 | 302 | 'Anonymous users or users who are not accepting our ' | 292 | "Anonymous users or users who are not accepting our " |
218 | 303 | 'licensing terms cannot do POST submissions.') | 293 | "licensing terms cannot do POST submissions.") |
219 | 304 | translations_person = ITranslationsPerson(self.user) | 294 | translations_person = ITranslationsPerson(self.user) |
220 | 305 | if (translations_person.translations_relicensing_agreement | 295 | if (translations_person.translations_relicensing_agreement |
221 | 306 | is not None and | 296 | is not None and |
222 | 307 | not translations_person.translations_relicensing_agreement): | 297 | not translations_person.translations_relicensing_agreement): |
226 | 308 | raise UnexpectedFormData, ( | 298 | raise UnexpectedFormData( |
227 | 309 | 'Users who do not agree to licensing terms ' | 299 | "Users who do not agree to licensing terms " |
228 | 310 | 'cannot do POST submissions.') | 300 | "cannot do POST submissions.") |
229 | 311 | try: | 301 | try: |
230 | 312 | # Try to get the timestamp when the submitted form was | 302 | # Try to get the timestamp when the submitted form was |
231 | 313 | # created. We use it to detect whether someone else updated | 303 | # created. We use it to detect whether someone else updated |
232 | @@ -318,9 +308,9 @@ | |||
233 | 318 | except zope_datetime.DateTimeError: | 308 | except zope_datetime.DateTimeError: |
234 | 319 | # invalid format. Either we don't have the timestamp in the | 309 | # invalid format. Either we don't have the timestamp in the |
235 | 320 | # submitted form or it has the wrong format. | 310 | # submitted form or it has the wrong format. |
239 | 321 | raise UnexpectedFormData, ( | 311 | raise UnexpectedFormData( |
240 | 322 | 'We didn\'t find the timestamp that tells us when was' | 312 | "We didn't find the timestamp that tells us when was" |
241 | 323 | ' generated the submitted form.') | 313 | " generated the submitted form.") |
242 | 324 | 314 | ||
243 | 325 | # Check if this is really the form we are listening for.. | 315 | # Check if this is really the form we are listening for.. |
244 | 326 | if self.request.form.get("submit_translations"): | 316 | if self.request.form.get("submit_translations"): |
245 | @@ -543,7 +533,7 @@ | |||
246 | 543 | elif fallback_language is not None: | 533 | elif fallback_language is not None: |
247 | 544 | # If there's a standard alternative language and no | 534 | # If there's a standard alternative language and no |
248 | 545 | # user-specified language was provided, preselect it. | 535 | # user-specified language was provided, preselect it. |
250 | 546 | alternative_language = fallback_language | 536 | alternative_language = fallback_language |
251 | 547 | second_lang_code = fallback_language.code | 537 | second_lang_code = fallback_language.code |
252 | 548 | else: | 538 | else: |
253 | 549 | # The second_lang_code is None and there is no fallback_language. | 539 | # The second_lang_code is None and there is no fallback_language. |
254 | @@ -685,12 +675,8 @@ | |||
255 | 685 | # current translation, suggestion or the new translation | 675 | # current translation, suggestion or the new translation |
256 | 686 | # field. | 676 | # field. |
257 | 687 | current_translation_message = ( | 677 | current_translation_message = ( |
264 | 688 | potmsgset.getCurrentTranslationMessage( | 678 | potmsgset.getCurrentTranslationMessageOrDummy( |
265 | 689 | self.pofile.potemplate, self.pofile.language)) | 679 | self.pofile)) |
260 | 690 | if current_translation_message is None: | ||
261 | 691 | current_translation_message = ( | ||
262 | 692 | potmsgset.getCurrentDummyTranslationMessage( | ||
263 | 693 | self.pofile.potemplate, self.pofile.language)) | ||
266 | 694 | if (selected_translation_key != | 680 | if (selected_translation_key != |
267 | 695 | msgset_ID_LANGCODE_translation_PLURALFORM_new): | 681 | msgset_ID_LANGCODE_translation_PLURALFORM_new): |
268 | 696 | # It's either current translation or an existing | 682 | # It's either current translation or an existing |
269 | @@ -890,14 +876,6 @@ | |||
270 | 890 | template = ViewPageTemplateFile( | 876 | template = ViewPageTemplateFile( |
271 | 891 | '../templates/currenttranslationmessage-translate-one.pt') | 877 | '../templates/currenttranslationmessage-translate-one.pt') |
272 | 892 | 878 | ||
273 | 893 | # Relevant instance variables: | ||
274 | 894 | # self.translations | ||
275 | 895 | # self.error | ||
276 | 896 | # self.sec_lang | ||
277 | 897 | # self.second_lang_potmsgset | ||
278 | 898 | # self.suggestion_blocks | ||
279 | 899 | # self.pluralform_indices | ||
280 | 900 | |||
281 | 901 | def __init__(self, current_translation_message, request, | 879 | def __init__(self, current_translation_message, request, |
282 | 902 | plural_indices_to_store, translations, force_suggestion, | 880 | plural_indices_to_store, translations, force_suggestion, |
283 | 903 | force_diverge, error, second_lang_code, form_is_writeable): | 881 | force_diverge, error, second_lang_code, form_is_writeable): |
284 | @@ -1053,7 +1031,7 @@ | |||
285 | 1053 | 1031 | ||
286 | 1054 | diverged_and_have_shared = ( | 1032 | diverged_and_have_shared = ( |
287 | 1055 | self.context.potemplate is not None and | 1033 | self.context.potemplate is not None and |
289 | 1056 | self.shared_translationmessage is not None) | 1034 | self.shared_translationmessage is not None) |
290 | 1057 | if diverged_and_have_shared: | 1035 | if diverged_and_have_shared: |
291 | 1058 | pofile = self.shared_translationmessage.ensureBrowserPOFile() | 1036 | pofile = self.shared_translationmessage.ensureBrowserPOFile() |
292 | 1059 | if pofile is None: | 1037 | if pofile is None: |
293 | @@ -1152,10 +1130,10 @@ | |||
294 | 1152 | 1130 | ||
295 | 1153 | def _setOnePOFile(self, messages): | 1131 | def _setOnePOFile(self, messages): |
296 | 1154 | """Return a list of messages that all have a browser_pofile set. | 1132 | """Return a list of messages that all have a browser_pofile set. |
298 | 1155 | 1133 | ||
299 | 1156 | If a pofile cannot be found for a message, it is not included in | 1134 | If a pofile cannot be found for a message, it is not included in |
300 | 1157 | the resulting list. | 1135 | the resulting list. |
302 | 1158 | """ | 1136 | """ |
303 | 1159 | result = [] | 1137 | result = [] |
304 | 1160 | for message in messages: | 1138 | for message in messages: |
305 | 1161 | if message.browser_pofile is None: | 1139 | if message.browser_pofile is None: |
306 | @@ -1167,7 +1145,7 @@ | |||
307 | 1167 | message.setPOFile(pofile) | 1145 | message.setPOFile(pofile) |
308 | 1168 | result.append(message) | 1146 | result.append(message) |
309 | 1169 | return result | 1147 | return result |
311 | 1170 | 1148 | ||
312 | 1171 | def _buildAllSuggestions(self): | 1149 | def _buildAllSuggestions(self): |
313 | 1172 | """Builds all suggestions and puts them into suggestions_block. | 1150 | """Builds all suggestions and puts them into suggestions_block. |
314 | 1173 | 1151 | ||
315 | @@ -1503,7 +1481,6 @@ | |||
316 | 1503 | return "%s_dismissable_button" % self.html_id | 1481 | return "%s_dismissable_button" % self.html_id |
317 | 1504 | 1482 | ||
318 | 1505 | 1483 | ||
319 | 1506 | |||
320 | 1507 | class CurrentTranslationMessageZoomedView(CurrentTranslationMessageView): | 1484 | class CurrentTranslationMessageZoomedView(CurrentTranslationMessageView): |
321 | 1508 | """A view that displays a `TranslationMessage`, but zoomed in. | 1485 | """A view that displays a `TranslationMessage`, but zoomed in. |
322 | 1509 | 1486 | ||
323 | @@ -1533,11 +1510,6 @@ | |||
324 | 1533 | return None | 1510 | return None |
325 | 1534 | 1511 | ||
326 | 1535 | 1512 | ||
327 | 1536 | # | ||
328 | 1537 | # Pseudo-content class | ||
329 | 1538 | # | ||
330 | 1539 | |||
331 | 1540 | |||
332 | 1541 | class TranslationMessageSuggestions: | 1513 | class TranslationMessageSuggestions: |
333 | 1542 | """See `ITranslationMessageSuggestions`.""" | 1514 | """See `ITranslationMessageSuggestions`.""" |
334 | 1543 | 1515 | ||
335 | @@ -1591,6 +1563,7 @@ | |||
336 | 1591 | class Submission: | 1563 | class Submission: |
337 | 1592 | """A submission generated from a TranslationMessage""" | 1564 | """A submission generated from a TranslationMessage""" |
338 | 1593 | 1565 | ||
339 | 1566 | |||
340 | 1594 | def convert_translationmessage_to_submission( | 1567 | def convert_translationmessage_to_submission( |
341 | 1595 | message, current_message, plural_form, pofile, legal_warning_needed, | 1568 | message, current_message, plural_form, pofile, legal_warning_needed, |
342 | 1596 | is_empty=False, packaged=False, local_to_pofile=False): | 1569 | is_empty=False, packaged=False, local_to_pofile=False): |
343 | 1597 | 1570 | ||
344 | === modified file 'lib/lp/translations/doc/canonical_url_examples.txt' | |||
345 | --- lib/lp/translations/doc/canonical_url_examples.txt 2010-07-30 12:56:27 +0000 | |||
346 | +++ lib/lp/translations/doc/canonical_url_examples.txt 2010-10-28 03:59:47 +0000 | |||
347 | @@ -71,8 +71,8 @@ | |||
348 | 71 | Even for a dummy one. | 71 | Even for a dummy one. |
349 | 72 | 72 | ||
350 | 73 | >>> potmsgset = potemplate.getPOTMsgSetBySequence(20) | 73 | >>> potmsgset = potemplate.getPOTMsgSetBySequence(20) |
353 | 74 | >>> translationmessage = potmsgset.getCurrentDummyTranslationMessage( | 74 | >>> translationmessage = potmsgset.getCurrentTranslationMessageOrDummy( |
354 | 75 | ... pofile.potemplate, pofile.language) | 75 | ... pofile) |
355 | 76 | >>> print canonical_url(translationmessage) | 76 | >>> print canonical_url(translationmessage) |
356 | 77 | http://transl.../hoary/+source/evolution/+pots/evolution-2.2/es/20 | 77 | http://transl.../hoary/+source/evolution/+pots/evolution-2.2/es/20 |
357 | 78 | 78 | ||
358 | @@ -109,8 +109,8 @@ | |||
359 | 109 | Even for a dummy PO msgset | 109 | Even for a dummy PO msgset |
360 | 110 | 110 | ||
361 | 111 | >>> potmsgset = potemplate.getPOTMsgSetBySequence(20) | 111 | >>> potmsgset = potemplate.getPOTMsgSetBySequence(20) |
364 | 112 | >>> translationmessage = potmsgset.getCurrentDummyTranslationMessage( | 112 | >>> translationmessage = potmsgset.getCurrentTranslationMessageOrDummy( |
365 | 113 | ... pofile.potemplate, pofile.language) | 113 | ... pofile) |
366 | 114 | >>> print canonical_url(translationmessage) | 114 | >>> print canonical_url(translationmessage) |
367 | 115 | http://translations.../evolution/trunk/+pots/evolution-2.2/es/20 | 115 | http://translations.../evolution/trunk/+pots/evolution-2.2/es/20 |
368 | 116 | 116 | ||
369 | 117 | 117 | ||
370 | === modified file 'lib/lp/translations/doc/potmsgset.txt' | |||
371 | --- lib/lp/translations/doc/potmsgset.txt 2010-10-26 10:31:37 +0000 | |||
372 | +++ lib/lp/translations/doc/potmsgset.txt 2010-10-28 03:59:47 +0000 | |||
373 | @@ -478,8 +478,8 @@ | |||
374 | 478 | ... evolution_potemplate, pt_BR_dummypofile.language) | 478 | ... evolution_potemplate, pt_BR_dummypofile.language) |
375 | 479 | >>> print current | 479 | >>> print current |
376 | 480 | None | 480 | None |
379 | 481 | >>> pt_BR_dummy_current = potmsgset.getCurrentDummyTranslationMessage( | 481 | >>> pt_BR_dummy_current = potmsgset.getCurrentTranslationMessageOrDummy( |
380 | 482 | ... evolution_potemplate, pt_BR_dummypofile.language) | 482 | ... pt_BR_dummypofile) |
381 | 483 | >>> pt_BR_dummy_current.plural_forms | 483 | >>> pt_BR_dummy_current.plural_forms |
382 | 484 | 1 | 484 | 1 |
383 | 485 | >>> pt_BR_dummy_current.translations | 485 | >>> pt_BR_dummy_current.translations |
384 | @@ -508,8 +508,8 @@ | |||
385 | 508 | >>> print apa_dummypofile.language.pluralforms | 508 | >>> print apa_dummypofile.language.pluralforms |
386 | 509 | None | 509 | None |
387 | 510 | >>> apa_dummy_current = ( | 510 | >>> apa_dummy_current = ( |
390 | 511 | ... plural_potmsgset.getCurrentDummyTranslationMessage( | 511 | ... plural_potmsgset.getCurrentTranslationMessageOrDummy( |
391 | 512 | ... evolution_potemplate, apa_dummypofile.language)) | 512 | ... apa_dummypofile)) |
392 | 513 | >>> apa_dummy_current.plural_forms | 513 | >>> apa_dummy_current.plural_forms |
393 | 514 | 2 | 514 | 2 |
394 | 515 | >>> apa_dummy_current.translations | 515 | >>> apa_dummy_current.translations |
395 | @@ -519,8 +519,9 @@ | |||
396 | 519 | 519 | ||
397 | 520 | >>> language_ru = getUtility(ILanguageSet).getLanguageByCode('ru') | 520 | >>> language_ru = getUtility(ILanguageSet).getLanguageByCode('ru') |
398 | 521 | >>> ru_dummypofile = evolution_potemplate.getDummyPOFile(language_ru) | 521 | >>> ru_dummypofile = evolution_potemplate.getDummyPOFile(language_ru) |
401 | 522 | >>> ru_dummy_current = plural_potmsgset.getCurrentDummyTranslationMessage( | 522 | >>> ru_dummy_current = ( |
402 | 523 | ... evolution_potemplate, ru_dummypofile.language) | 523 | ... plural_potmsgset.getCurrentTranslationMessageOrDummy( |
403 | 524 | ... ru_dummypofile)) | ||
404 | 524 | 525 | ||
405 | 525 | >>> print ru_dummypofile.language.pluralforms | 526 | >>> print ru_dummypofile.language.pluralforms |
406 | 526 | 3 | 527 | 3 |
407 | @@ -925,29 +926,6 @@ | |||
408 | 925 | 0 | 926 | 0 |
409 | 926 | 927 | ||
410 | 927 | 928 | ||
411 | 928 | POTMsgSet.getCurrentDummyTranslationMessage | ||
412 | 929 | ------------------------------------------- | ||
413 | 930 | |||
414 | 931 | Sometimes, there are POTMsgSet objects with no translations to a language, | ||
415 | 932 | and we need to get dummy objects which emulate them to do read operations. | ||
416 | 933 | This method give us such dummy objects. | ||
417 | 934 | |||
418 | 935 | >>> spanish_in_mexico = getUtility(ILanguageSet).getLanguageByCode( | ||
419 | 936 | ... 'es_MX') | ||
420 | 937 | >>> potmsgset.getCurrentDummyTranslationMessage( | ||
421 | 938 | ... evolution_potemplate, spanish_in_mexico) is None | ||
422 | 939 | False | ||
423 | 940 | |||
424 | 941 | But, if we already have a TranslationMessage for a POTMsgSet in our database, | ||
425 | 942 | and we request a dummy one, that's broken and we detect it. | ||
426 | 943 | |||
427 | 944 | >>> potmsgset.getCurrentDummyTranslationMessage( | ||
428 | 945 | ... evolution_potemplate, spanish) | ||
429 | 946 | Traceback (most recent call last): | ||
430 | 947 | ... | ||
431 | 948 | AssertionError: There is already a translation message ... | ||
432 | 949 | |||
433 | 950 | |||
434 | 951 | Suggestions for translator credits | 929 | Suggestions for translator credits |
435 | 952 | ---------------------------------- | 930 | ---------------------------------- |
436 | 953 | 931 | ||
437 | 954 | 932 | ||
438 | === modified file 'lib/lp/translations/doc/translationmessage.txt' | |||
439 | --- lib/lp/translations/doc/translationmessage.txt 2010-10-18 22:24:59 +0000 | |||
440 | +++ lib/lp/translations/doc/translationmessage.txt 2010-10-28 03:59:47 +0000 | |||
441 | @@ -10,6 +10,7 @@ | |||
442 | 10 | >>> from lp.translations.interfaces.translationmessage import ( | 10 | >>> from lp.translations.interfaces.translationmessage import ( |
443 | 11 | ... ITranslationMessage) | 11 | ... ITranslationMessage) |
444 | 12 | >>> from lp.translations.interfaces.translator import ITranslatorSet | 12 | >>> from lp.translations.interfaces.translator import ITranslatorSet |
445 | 13 | >>> from lp.translations.model.pofile import DummyPOFile | ||
446 | 13 | 14 | ||
447 | 14 | >>> login('carlos@canonical.com') | 15 | >>> login('carlos@canonical.com') |
448 | 15 | >>> pofile_es = factory.makePOFile(language_code='es') | 16 | >>> pofile_es = factory.makePOFile(language_code='es') |
449 | @@ -18,16 +19,15 @@ | |||
450 | 18 | 19 | ||
451 | 19 | This class links the translations submitted by a translator with the | 20 | This class links the translations submitted by a translator with the |
452 | 20 | associated POFile and POTMsgSet. TranslationMessage and | 21 | associated POFile and POTMsgSet. TranslationMessage and |
454 | 21 | DummyTranslationMessage both implement ITranslationMessage interface: | 22 | DummyTranslationMessage both implement ITranslationMessage: |
455 | 22 | 23 | ||
456 | 23 | >>> translationmessage = factory.makeTranslationMessage( | 24 | >>> translationmessage = factory.makeTranslationMessage( |
457 | 24 | ... potmsgset=potmsgset, pofile=pofile_es) | 25 | ... potmsgset=potmsgset, pofile=pofile_es) |
458 | 25 | >>> verifyObject(ITranslationMessage, translationmessage) | 26 | >>> verifyObject(ITranslationMessage, translationmessage) |
459 | 26 | True | 27 | True |
460 | 27 | 28 | ||
464 | 28 | >>> serbian = getUtility(ILanguageSet)['sr'] | 29 | >>> dummy_message = potmsgset.getCurrentTranslationMessageOrDummy( |
465 | 29 | >>> dummy_message = potmsgset.getCurrentDummyTranslationMessage( | 30 | ... factory.makePOFile('xh')) |
463 | 30 | ... potemplate, serbian) | ||
466 | 31 | >>> verifyObject(ITranslationMessage, dummy_message) | 31 | >>> verifyObject(ITranslationMessage, dummy_message) |
467 | 32 | True | 32 | True |
468 | 33 | 33 | ||
469 | @@ -48,18 +48,19 @@ | |||
470 | 48 | the translation, no matter the number of plural forms defined for the | 48 | the translation, no matter the number of plural forms defined for the |
471 | 49 | language: | 49 | language: |
472 | 50 | 50 | ||
473 | 51 | >>> serbian = getUtility(ILanguageSet)['sr'] | ||
474 | 51 | >>> serbian.pluralforms | 52 | >>> serbian.pluralforms |
475 | 52 | 3 | 53 | 3 |
478 | 53 | >>> current_sr = potmsgset.getCurrentDummyTranslationMessage( | 54 | >>> current_sr = potmsgset.getCurrentTranslationMessageOrDummy( |
479 | 54 | ... potemplate, serbian) | 55 | ... DummyPOFile(potemplate, serbian)) |
480 | 55 | >>> current_sr.plural_forms | 56 | >>> current_sr.plural_forms |
481 | 56 | 1 | 57 | 1 |
482 | 57 | 58 | ||
483 | 58 | >>> divehi = getUtility(ILanguageSet)['dv'] | 59 | >>> divehi = getUtility(ILanguageSet)['dv'] |
484 | 59 | >>> print divehi.pluralforms | 60 | >>> print divehi.pluralforms |
485 | 60 | None | 61 | None |
488 | 61 | >>> current_dv = potmsgset.getCurrentDummyTranslationMessage( | 62 | >>> current_dv = potmsgset.getCurrentTranslationMessageOrDummy( |
489 | 62 | ... potemplate, divehi) | 63 | ... DummyPOFile(potemplate, divehi)) |
490 | 63 | >>> current_dv.plural_forms | 64 | >>> current_dv.plural_forms |
491 | 64 | 1 | 65 | 1 |
492 | 65 | 66 | ||
493 | @@ -73,8 +74,8 @@ | |||
494 | 73 | u'plural' | 74 | u'plural' |
495 | 74 | >>> serbian.pluralforms | 75 | >>> serbian.pluralforms |
496 | 75 | 3 | 76 | 3 |
499 | 76 | >>> current_sr = potmsgset_plural.getCurrentDummyTranslationMessage( | 77 | >>> current_sr = potmsgset_plural.getCurrentTranslationMessageOrDummy( |
500 | 77 | ... potemplate, serbian) | 78 | ... DummyPOFile(potemplate, serbian)) |
501 | 78 | >>> current_sr.plural_forms | 79 | >>> current_sr.plural_forms |
502 | 79 | 3 | 80 | 3 |
503 | 80 | 81 | ||
504 | @@ -83,8 +84,8 @@ | |||
505 | 83 | 84 | ||
506 | 84 | >>> print divehi.pluralforms | 85 | >>> print divehi.pluralforms |
507 | 85 | None | 86 | None |
510 | 86 | >>> current_dv = potmsgset_plural.getCurrentDummyTranslationMessage( | 87 | >>> current_dv = potmsgset_plural.getCurrentTranslationMessageOrDummy( |
511 | 87 | ... potemplate, divehi) | 88 | ... DummyPOFile(potemplate, divehi)) |
512 | 88 | >>> current_dv.plural_forms | 89 | >>> current_dv.plural_forms |
513 | 89 | 2 | 90 | 2 |
514 | 90 | 91 | ||
515 | 91 | 92 | ||
516 | === modified file 'lib/lp/translations/interfaces/potmsgset.py' | |||
517 | --- lib/lp/translations/interfaces/potmsgset.py 2010-08-20 20:31:18 +0000 | |||
518 | +++ lib/lp/translations/interfaces/potmsgset.py 2010-10-28 03:59:47 +0000 | |||
519 | @@ -65,6 +65,7 @@ | |||
520 | 65 | class BrokenTextError(ValueError): | 65 | class BrokenTextError(ValueError): |
521 | 66 | """Exception raised when we detect values on a text that aren't valid.""" | 66 | """Exception raised when we detect values on a text that aren't valid.""" |
522 | 67 | 67 | ||
523 | 68 | |||
524 | 68 | class POTMsgSetInIncompatibleTemplatesError(Exception): | 69 | class POTMsgSetInIncompatibleTemplatesError(Exception): |
525 | 69 | """Raised when a POTMsgSet appears in multiple incompatible templates. | 70 | """Raised when a POTMsgSet appears in multiple incompatible templates. |
526 | 70 | 71 | ||
527 | @@ -134,14 +135,13 @@ | |||
528 | 134 | queries that search for credits messages. | 135 | queries that search for credits messages. |
529 | 135 | """)) | 136 | """)) |
530 | 136 | 137 | ||
539 | 137 | def getCurrentDummyTranslationMessage(potemplate, language): | 138 | def getCurrentTranslationMessageOrDummy(pofile): |
540 | 138 | """Return a DummyTranslationMessage for this message language. | 139 | """Return the current `TranslationMessage`, or a dummy. |
541 | 139 | 140 | ||
542 | 140 | :param potemplate: PO template you want a translation message for. | 141 | :param pofile: PO template you want a translation message for. |
543 | 141 | :param language: language we want a dummy translations for. | 142 | :return: The current translation for `self` in `pofile`, if |
544 | 142 | 143 | there is one. Otherwise, a `DummyTranslationMessage` for | |
545 | 143 | If a TranslationMessage for this language already exists, | 144 | `self` in `pofile`. |
538 | 144 | an exception is raised. | ||
546 | 145 | """ | 145 | """ |
547 | 146 | 146 | ||
548 | 147 | def getCurrentTranslationMessage(potemplate, language): | 147 | def getCurrentTranslationMessage(potemplate, language): |
549 | 148 | 148 | ||
550 | === modified file 'lib/lp/translations/model/potmsgset.py' | |||
551 | --- lib/lp/translations/model/potmsgset.py 2010-10-27 07:56:41 +0000 | |||
552 | +++ lib/lp/translations/model/potmsgset.py 2010-10-28 03:59:47 +0000 | |||
553 | @@ -42,7 +42,6 @@ | |||
554 | 42 | from canonical.launchpad.interfaces.lpstorm import ISlaveStore | 42 | from canonical.launchpad.interfaces.lpstorm import ISlaveStore |
555 | 43 | from canonical.launchpad.readonly import is_read_only | 43 | from canonical.launchpad.readonly import is_read_only |
556 | 44 | from lp.app.errors import UnexpectedFormData | 44 | from lp.app.errors import UnexpectedFormData |
557 | 45 | from lp.translations.interfaces.pofile import IPOFileSet | ||
558 | 46 | from lp.translations.interfaces.potmsgset import ( | 45 | from lp.translations.interfaces.potmsgset import ( |
559 | 47 | BrokenTextError, | 46 | BrokenTextError, |
560 | 48 | IPOTMsgSet, | 47 | IPOTMsgSet, |
561 | @@ -237,18 +236,15 @@ | |||
562 | 237 | else: | 236 | else: |
563 | 238 | return self.msgid_plural.msgid | 237 | return self.msgid_plural.msgid |
564 | 239 | 238 | ||
566 | 240 | def getCurrentDummyTranslationMessage(self, potemplate, language): | 239 | def getCurrentTranslationMessageOrDummy(self, pofile): |
567 | 241 | """See `IPOTMsgSet`.""" | 240 | """See `IPOTMsgSet`.""" |
573 | 242 | 241 | current = self.getCurrentTranslationMessage( | |
574 | 243 | pofile = potemplate.getPOFileByLang(language.code) | 242 | pofile.potemplate, pofile.language) |
575 | 244 | if pofile is None: | 243 | if current is None: |
576 | 245 | pofileset = getUtility(IPOFileSet) | 244 | return DummyTranslationMessage(pofile, self) |
572 | 246 | pofile = pofileset.getDummy(potemplate, language) | ||
577 | 247 | else: | 245 | else: |
582 | 248 | assert self.getCurrentTranslationMessage(potemplate, | 246 | current.setPOFile(pofile) |
583 | 249 | language) is None, ( | 247 | return current |
580 | 250 | 'There is already a translation message in our database.') | ||
581 | 251 | return DummyTranslationMessage(pofile, self) | ||
584 | 252 | 248 | ||
585 | 253 | def _getUsedTranslationMessage(self, potemplate, language, current=True): | 249 | def _getUsedTranslationMessage(self, potemplate, language, current=True): |
586 | 254 | """Get a translation message which is either used in | 250 | """Get a translation message which is either used in |
587 | 255 | 251 | ||
588 | === modified file 'lib/lp/translations/model/translationmessage.py' | |||
589 | --- lib/lp/translations/model/translationmessage.py 2010-10-04 22:56:09 +0000 | |||
590 | +++ lib/lp/translations/model/translationmessage.py 2010-10-28 03:59:47 +0000 | |||
591 | @@ -115,13 +115,6 @@ | |||
592 | 115 | implements(ITranslationMessage) | 115 | implements(ITranslationMessage) |
593 | 116 | 116 | ||
594 | 117 | def __init__(self, pofile, potmsgset): | 117 | def __init__(self, pofile, potmsgset): |
595 | 118 | # Check whether we already have a suitable TranslationMessage, in | ||
596 | 119 | # which case, the dummy one must not be used. | ||
597 | 120 | assert potmsgset.getCurrentTranslationMessage( | ||
598 | 121 | pofile.potemplate, | ||
599 | 122 | pofile.language) is None, ( | ||
600 | 123 | 'This translation message already exists in the database.') | ||
601 | 124 | |||
602 | 125 | self.id = None | 118 | self.id = None |
603 | 126 | self.browser_pofile = pofile | 119 | self.browser_pofile = pofile |
604 | 127 | self.potemplate = pofile.potemplate | 120 | self.potemplate = pofile.potemplate |
605 | 128 | 121 | ||
606 | === modified file 'lib/lp/translations/tests/test_potmsgset.py' | |||
607 | --- lib/lp/translations/tests/test_potmsgset.py 2010-10-26 10:31:37 +0000 | |||
608 | +++ lib/lp/translations/tests/test_potmsgset.py 2010-10-28 03:59:47 +0000 | |||
609 | @@ -13,17 +13,13 @@ | |||
610 | 13 | import pytz | 13 | import pytz |
611 | 14 | import transaction | 14 | import transaction |
612 | 15 | from zope.component import getUtility | 15 | from zope.component import getUtility |
617 | 16 | from zope.security.proxy import ( | 16 | from zope.security.proxy import removeSecurityProxy |
614 | 17 | isinstance as zope_isinstance, | ||
615 | 18 | removeSecurityProxy, | ||
616 | 19 | ) | ||
618 | 20 | 17 | ||
619 | 21 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities | 18 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities |
620 | 22 | from canonical.testing.layers import ZopelessDatabaseLayer | 19 | from canonical.testing.layers import ZopelessDatabaseLayer |
621 | 23 | from lp.app.enums import ServiceUsage | 20 | from lp.app.enums import ServiceUsage |
622 | 24 | from lp.registry.interfaces.person import IPersonSet | 21 | from lp.registry.interfaces.person import IPersonSet |
623 | 25 | from lp.registry.interfaces.product import IProductSet | 22 | from lp.registry.interfaces.product import IProductSet |
624 | 26 | from lp.services.worlddata.interfaces.language import ILanguageSet | ||
625 | 27 | from lp.testing import TestCaseWithFactory | 23 | from lp.testing import TestCaseWithFactory |
626 | 28 | from lp.translations.interfaces.potemplate import IPOTemplateSet | 24 | from lp.translations.interfaces.potemplate import IPOTemplateSet |
627 | 29 | from lp.translations.interfaces.potmsgset import ( | 25 | from lp.translations.interfaces.potmsgset import ( |
628 | @@ -165,31 +161,21 @@ | |||
629 | 165 | translation.potemplate = self.devel_potemplate | 161 | translation.potemplate = self.devel_potemplate |
630 | 166 | self.assertEquals(potmsgset.singular_text, ENGLISH_STRING) | 162 | self.assertEquals(potmsgset.singular_text, ENGLISH_STRING) |
631 | 167 | 163 | ||
657 | 168 | def test_getCurrentDummyTranslationMessage(self): | 164 | def test_getCurrentTranslationMessageOrDummy_returns_real_tm(self): |
658 | 169 | """Test that a DummyTranslationMessage is correctly returned.""" | 165 | pofile = self.factory.makePOFile('nl') |
659 | 170 | 166 | message = self.factory.makeTranslationMessage( | |
660 | 171 | # When there is no POFile, we get a DummyTranslationMessage inside | 167 | pofile=pofile, suggestion=False, is_imported=True) |
661 | 172 | # a DummyPOFile. | 168 | |
662 | 173 | serbian = getUtility(ILanguageSet).getLanguageByCode('sr') | 169 | self.assertEqual( |
663 | 174 | dummy = self.potmsgset.getCurrentDummyTranslationMessage( | 170 | message, |
664 | 175 | self.devel_potemplate, serbian) | 171 | message.potmsgset.getCurrentTranslationMessageOrDummy(pofile)) |
665 | 176 | self.assertTrue(zope_isinstance(dummy, DummyTranslationMessage)) | 172 | |
666 | 177 | 173 | def test_getCurrentTranslationMessageOrDummy_returns_dummy_tm(self): | |
667 | 178 | # If a POFile exists, but there is no current translation message, | 174 | pofile = self.factory.makePOFile('nl') |
668 | 179 | # a dummy translation message is returned. | 175 | potmsgset = self.factory.makePOTMsgSet(pofile.potemplate) |
669 | 180 | sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate) | 176 | |
670 | 181 | dummy = self.potmsgset.getCurrentDummyTranslationMessage( | 177 | message = potmsgset.getCurrentTranslationMessageOrDummy(pofile) |
671 | 182 | self.devel_potemplate, serbian) | 178 | self.assertIsInstance(message, DummyTranslationMessage) |
647 | 183 | self.assertTrue(zope_isinstance(dummy, DummyTranslationMessage)) | ||
648 | 184 | |||
649 | 185 | # When there is a current translation message, an exception | ||
650 | 186 | # is raised. | ||
651 | 187 | translation = self.factory.makeTranslationMessage( | ||
652 | 188 | pofile=sr_pofile, potmsgset=self.potmsgset) | ||
653 | 189 | self.assertTrue(translation.is_current) | ||
654 | 190 | self.assertRaises(AssertionError, | ||
655 | 191 | self.potmsgset.getCurrentDummyTranslationMessage, | ||
656 | 192 | self.devel_potemplate, serbian) | ||
672 | 193 | 179 | ||
673 | 194 | def test_getCurrentTranslationMessage(self): | 180 | def test_getCurrentTranslationMessage(self): |
674 | 195 | """Test how shared and diverged current translation messages | 181 | """Test how shared and diverged current translation messages |
Hi Jeroen,
This branch looks good. I just have one comment on an preexisting typo.
-Edwin
>=== modified file 'lib/lp/ translations/ browser/ tests/translati onmessage- views.txt' translations/ browser/ tests/translati onmessage- views.txt 2010-10-18 22:24:59 +0000 translations/ browser/ tests/translati onmessage- views.txt 2010-10-27 20:18:48 +0000 ssage View ======= ======= ==== worlddata. interfaces. language import ILanguageSet .publisher import TranslationsLayer
>--- lib/lp/
>+++ lib/lp/
>@@ -1,4 +1,5 @@
>-= TranslationMessage View =
>+TranslationMe
>+=====
>
> On this section, we are going to test the view class for an
> ITranslationMessage object.
>@@ -11,13 +12,14 @@
> >>> from lp.services.
> >>> from lp.translations
>
>-All the tests will be submitted as comming from Kurem, an editor for the POFile
>-that we are going to edit.
>+All the tests will be submitted as comming from Kurem, an editor for the
s/comming/coming/
>+POFile that we are going to edit.
>
> >>> login('<email address hidden>')
>
>
>-== No plural forms ==
>+No plural forms
>+---------------
>
> We are going to see what happens if we get an entry for a language
> without the plural form information.