Merge lp:~henninge/launchpad/recife-current-tm-view-1 into lp:~launchpad/launchpad/recife

Proposed by Henning Eggers
Status: Merged
Merged at revision: 9208
Proposed branch: lp:~henninge/launchpad/recife-current-tm-view-1
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 683 lines (+113/-208)
9 files modified
lib/lp/testing/factory.py (+9/-5)
lib/lp/translations/browser/tests/test_translationmessage_view.py (+13/-72)
lib/lp/translations/browser/tests/translationmessage-views.txt (+3/-3)
lib/lp/translations/browser/translationmessage.py (+47/-82)
lib/lp/translations/doc/poexport-language-pack.txt (+4/-6)
lib/lp/translations/doc/potmsgset.txt (+23/-25)
lib/lp/translations/doc/remove-translations-by.txt (+7/-8)
lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt (+1/-1)
lib/lp/translations/templates/currenttranslationmessage-translate-one.pt (+6/-6)
To merge this branch: bzr merge lp:~henninge/launchpad/recife-current-tm-view-1
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code Approve
Steve Kowalik (community) code* Approve
Review via email: mp+41690@code.launchpad.net

Description of the change

= Converting CurrentTranslationMessageView Part 1 =

This branch updates the CurrentTranslationMessageView to work with the new sharing model which loses the concept of "imported" or "packaged" (same thing, different name) translations and replaces them with the concept "translations on the other side". The "other side" is either Ubuntu or upstream, depending from where you look.

There are three changes in this branch:

1. A general renaming of "imported" to "other" to fit the new model.
2. Removal of "can_dismiss_packaged" because "other" translations cannot be dismissed. This also includes removal of related tests and a css class.
3. The view had member variables for "imported_translationmessage" and "shared_sharedtranslationmessage" while the latter was left None if it was identical to the context (the "Current Translation Message"), the former was assigned the context. This antisymmetry has been fixed with the renaming to "other_translationmessage" which is now set to None, too, if the context is used on both sides (ubuntu and upstream). This entailed having to fix some places that depended on the old definition.

== Tests ==

I have run all lp.translations tests on this branch and they pass fine.

bin/test -vvcm lp.translations \
  -t test_translationmessage_view \
  -t translationmessage-views.txt \
  -t xx-translationmessage-translate.txt

== Demo/QA ==

This will be QA'ed with the full feature branch. The big thing to notice now when running this branch is that "Packaged" has been replaced with "Other" on the translate page.

== Lint ==

There are lint issues which I will fix in the next branch.

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Sorry, the following files are from a a different branch:

lib/lp/testing/factory.py
lib/lp/translations/doc/poexport-language-pack.txt
lib/lp/translations/doc/potmsgset.txt
lib/lp/translations/doc/remove-translations-by.txt

Luckily they are orthogonal to the other changes. The branch is lp:~henninge/launchpad/recife-kill-ut-in-tests-1. It is about replacing calls to "updateTranslation" in tests with calls to the factory method "makeCurrentTranslationMessage". This is quite mechanical but the factory method had to be extended to include sanitation, something that "updateTranslation" used to do.

You can chose to ignore these files or review them along with the others. Your pick. ;-)

Revision history for this message
Steve Kowalik (stevenk) wrote :

Hi Henning,

These changes look fine to me -- and a bonus about removing a lot of code.

My only concern is the use of "Other", but I'm not going to block the branch for that nitpick.

review: Approve (code*)
Revision history for this message
Henning Eggers (henninge) wrote :

Never mind my last comment. Those changes have already been reviewed, just not landed ...

/me is very forgetful atm. :(

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve (code)
Revision history for this message
Данило Шеган (danilo) wrote :

Henning, thanks for taking care of this. I've only gone through your
MP, and wonder one thing.

У сре, 24. 11 2010. у 08:05 +0000, Henning Eggers пише:

> 2. Removal of "can_dismiss_packaged" because "other" translations cannot be dismissed. This also includes removal of related tests and a css class.

I am not so sure it can't be "dismissed": the problem is that if
date_reviewed on the current translation is older than the "other"
current translation, you'll always have one unreviewed translation. The
solution to that is to just update the date_reviewed on the current
translation. I haven't looked at the code changes, but we do want to
preserve this behavior if it works today. If it doesn't, well,
something for another day.

Revision history for this message
Henning Eggers (henninge) wrote :

Thanks for commenting on that. I had forgotten how exactly that worked and from that misjudged the situation.

I reverted this change in lp:~henninge/launchpad/recife-current-tm-view-3 and got it to work with the new model, even the test that Jeroen had to deactivate. All good but later than expected.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/testing/factory.py'
2--- lib/lp/testing/factory.py 2010-11-21 20:46:19 +0000
3+++ lib/lp/testing/factory.py 2010-11-24 08:04:10 +0000
4@@ -282,6 +282,9 @@
5 from lp.translations.model.translationimportqueue import (
6 TranslationImportQueueEntry,
7 )
8+from lp.translations.utilities.sanitize import (
9+ sanitize_translations_from_webui
10+ )
11
12
13 SPACE = ' '
14@@ -2536,7 +2539,7 @@
15 assert not (diverged and current_other), (
16 "A diverged message can't be current on the other side.")
17 if pofile is None:
18- pofile = self.makePOFile('nl')
19+ pofile = self.makePOFile()
20 if potmsgset is None:
21 potmsgset = self.makePOTMsgSet(pofile.potemplate, sequence=1)
22 if translator is None:
23@@ -2544,10 +2547,11 @@
24 if reviewer is None:
25 reviewer = self.makePerson()
26 if translations is None:
27- translations = [self.getUniqueString()]
28- if isinstance(translations, list):
29- # Support the list-of-strings format for convenience.
30- translations = dict(enumerate(translations))
31+ translations = {0: self.getUniqueString()}
32+ else:
33+ translations = sanitize_translations_from_webui(
34+ potmsgset.singular_text, translations,
35+ pofile.language.pluralforms)
36
37 message = potmsgset.setCurrentTranslation(
38 pofile, translator, translations,
39
40=== modified file 'lib/lp/translations/browser/tests/test_translationmessage_view.py'
41--- lib/lp/translations/browser/tests/test_translationmessage_view.py 2010-11-23 10:06:35 +0000
42+++ lib/lp/translations/browser/tests/test_translationmessage_view.py 2010-11-24 08:04:10 +0000
43@@ -66,8 +66,7 @@
44 False, False, None, None, True, pofile=self.pofile, can_edit=True)
45 self.view.initialize()
46
47- def _makeTranslation(self, translation=None,
48- suggestion=False, is_packaged=False):
49+ def _makeTranslation(self, translation=None, suggestion=False):
50 if translation is None:
51 translations = None
52 elif isinstance(translation, list):
53@@ -81,44 +80,38 @@
54 translator=self.owner,
55 date_created=self.now())
56 else:
57- message = self.factory.makeTranslationMessage(
58+ message = self.factory.makeCurrentTranslationMessage(
59 self.pofile, self.potmsgset,
60 translations=translations,
61- suggestion=suggestion,
62- is_current_upstream=is_packaged,
63- translator=self.owner,
64- date_updated=self.now())
65+ translator=self.owner, reviewer=self.owner)
66 message.browser_pofile = self.pofile
67 return message
68
69- def _assertConfirmEmptyPluralPackaged(self,
70- can_confirm_and_dismiss,
71- can_dismiss_on_empty,
72- can_dismiss_on_plural,
73- can_dismiss_packaged):
74+ def _assertConfirmEmptyPlural(self,
75+ can_confirm_and_dismiss,
76+ can_dismiss_on_empty,
77+ can_dismiss_on_plural):
78 assert self.view is not None
79 self.assertEqual(
80 [can_confirm_and_dismiss,
81 can_dismiss_on_empty,
82- can_dismiss_on_plural,
83- can_dismiss_packaged],
84+ can_dismiss_on_plural],
85 [self.view.can_confirm_and_dismiss,
86 self.view.can_dismiss_on_empty,
87- self.view.can_dismiss_on_plural,
88- self.view.can_dismiss_packaged])
89+ self.view.can_dismiss_on_plural])
90
91 def test_no_suggestion(self):
92 # If there is no suggestion, nothing can be dismissed.
93 message = self._makeTranslation()
94 self._createView(message)
95- self._assertConfirmEmptyPluralPackaged(False, False, False, False)
96+ self._assertConfirmEmptyPlural(False, False, False)
97
98 def test_local_suggestion(self):
99 # If there is a local suggestion, it can be dismissed.
100 message = self._makeTranslation()
101 suggestion = self._makeTranslation(suggestion=True)
102 self._createView(message)
103- self._assertConfirmEmptyPluralPackaged(True, False, False, False)
104+ self._assertConfirmEmptyPlural(True, False, False)
105
106 def test_local_suggestion_on_empty(self):
107 # If there is a local suggestion on an empty message, it is dismissed
108@@ -126,7 +119,7 @@
109 message = self._makeTranslation("")
110 suggestion = self._makeTranslation(suggestion=True)
111 self._createView(message)
112- self._assertConfirmEmptyPluralPackaged(False, True, False, False)
113+ self._assertConfirmEmptyPlural(False, True, False)
114
115 def test_local_suggestion_on_plural(self):
116 # If there is a suggestion on a plural message, it is dismissed
117@@ -137,59 +130,7 @@
118 suggestion = self._makeTranslation(["singular_sugg", "plural_sugg"],
119 suggestion=True)
120 self._createView(message)
121- self._assertConfirmEmptyPluralPackaged(False, False, True, False)
122-
123- # XXX JeroenVermeulen 2010-11-22: Disabling this test
124- # temporarily. We must re-enable it before completing the
125- # migration of CurrentTranslationMessageTranslateView to the
126- # Recife model. Currently this is the only test that still
127- # breaks after a partial migration of model code and that view
128- # (as needed to complete the update of _storeTranslations).
129- def XXX_disabled_test_packaged_suggestion(self):
130- # If there is a packaged suggestion, it can be dismissed.
131- packaged = self._makeTranslation(is_packaged=True)
132- message = self._makeTranslation()
133- new_packaged = self._makeTranslation(is_packaged=True)
134- self._createView(message)
135- self._assertConfirmEmptyPluralPackaged(True, False, False, True)
136-
137- def test_packaged_suggestion_on_empty(self):
138- # If there is an empty suggestion on an empty message,
139- # it is dismissed in a different place.
140- packaged = self._makeTranslation(is_packaged=True)
141- message = self._makeTranslation("")
142- new_packaged = self._makeTranslation(is_packaged=True)
143- self._createView(message)
144- self._assertConfirmEmptyPluralPackaged(False, True, False, True)
145-
146- def test_packaged_suggestion_on_plural(self):
147- # If there is a suggestion on a plural message, it is dismissed
148- # in yet a different place.
149- self.potmsgset = self.factory.makePOTMsgSet(self.potemplate,
150- singular="msgid_singular", plural="msgid_plural")
151- packaged = self._makeTranslation(["singular_trans", "plural_trans"],
152- is_packaged=True)
153- message = self._makeTranslation(["singular_trans", "plural_trans"])
154- new_packaged = self._makeTranslation(["singular_new", "plural_new"],
155- is_packaged=True)
156- self._createView(message)
157- self._assertConfirmEmptyPluralPackaged(False, False, True, True)
158-
159- def test_packaged_suggestion_old(self):
160- # If there is an older packaged suggestion, it cannot be dismissed.
161- packaged = self._makeTranslation(is_packaged=True)
162- message = self._makeTranslation()
163- self._createView(message)
164- self._assertConfirmEmptyPluralPackaged(False, False, False, False)
165-
166- def test_packaged_old_local_new(self):
167- # If there is an older packaged suggestion, but a newer local
168- # suggestion, only the local suggestion can be dismissed.
169- packaged = self._makeTranslation(is_packaged=True)
170- message = self._makeTranslation()
171- suggestion = self._makeTranslation(suggestion=True)
172- self._createView(message)
173- self._assertConfirmEmptyPluralPackaged(True, False, False, False)
174+ self._assertConfirmEmptyPlural(False, False, True)
175
176
177 class TestResetTranslations(TestCaseWithFactory):
178
179=== modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt'
180--- lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-22 14:27:36 +0000
181+++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-24 08:04:10 +0000
182@@ -135,14 +135,14 @@
183 ...
184 AssertionError: There is no plural form #1 for Spanish (es) language
185
186-Upstream translation is defined and same as the active one.
187+The translation on the other side is defined and same as the active one.
188
189- >>> subview.getImportedTranslation(0)
190+ >>> subview.getOtherTranslation(0)
191 u'libreta de direcciones de Evolution'
192
193 However, if we ask for incorrect plural form, we get an AssertionError.
194
195- >>> subview.getImportedTranslation(1)
196+ >>> subview.getOtherTranslation(1)
197 Traceback (most recent call last):
198 ...
199 AssertionError: There is no plural form #1 for Spanish (es) language
200
201=== modified file 'lib/lp/translations/browser/translationmessage.py'
202--- lib/lp/translations/browser/translationmessage.py 2010-11-22 14:27:36 +0000
203+++ lib/lp/translations/browser/translationmessage.py 2010-11-24 08:04:10 +0000
204@@ -1017,29 +1017,30 @@
205 if side_traits.other_side_traits.getFlag(self.context):
206 # The shared translation for the other side matches the current
207 # one.
208- self.imported_translationmessage = self.context
209+ self.other_translationmessage = None
210 else:
211- self.imported_translationmessage = (
212+ self.other_translationmessage = (
213 self.context.potmsgset.getCurrentTranslation(
214 self.pofile.potemplate, self.pofile.language,
215 side_traits.other_side_traits.side))
216
217 if self.context.potemplate is None:
218- # Shared translation is current.
219+ # Current translation is shared.
220 self.shared_translationmessage = None
221 else:
222- self.shared_translationmessage = (
223+ # Current translation is diverged, find the shared one.
224+ shared_translationmessage = (
225 self.context.potmsgset.getCurrentTranslation(
226 None, self.pofile.language, side_traits.side))
227- if (self.shared_translationmessage ==
228- self.imported_translationmessage):
229- # If it matches the imported message, we don't care.
230+ if (shared_translationmessage == self.other_translationmessage):
231+ # If it matches the other message, we don't care.
232 self.shared_translationmessage = None
233+ else:
234+ self.shared_translationmessage = shared_translationmessage
235
236 self.can_confirm_and_dismiss = False
237 self.can_dismiss_on_empty = False
238 self.can_dismiss_on_plural = False
239- self.can_dismiss_packaged = False
240
241 # Initialize to True, allowing POFileTranslateView to override.
242 self.zoomed_in_view = True
243@@ -1093,15 +1094,12 @@
244 self.current_series.distribution.displayname,
245 self.current_series.name)
246
247- side_traits = getUtility(ITranslationSideTraitsSet).getForTemplate(
248- self.pofile.potemplate)
249-
250 # Initialise the translation dictionaries used from the
251 # translation form.
252 self.translation_dictionaries = []
253 for index in self.pluralform_indices:
254 current_translation = self.getCurrentTranslation(index)
255- imported_translation = self.getImportedTranslation(index)
256+ other_translation = self.getOtherTranslation(index)
257 shared_translation = self.getSharedTranslation(index)
258 submitted_translation = self.getSubmittedTranslation(index)
259 if (submitted_translation is None and
260@@ -1118,18 +1116,17 @@
261 self.context.submitter == self.context.reviewer)
262 is_same_date = (
263 self.context.date_created == self.context.date_reviewed)
264- if side_traits.other_side_traits.getFlag(self.context):
265- # Imported one matches the current one.
266- imported_submission = None
267- elif self.imported_translationmessage is not None:
268+ if self.other_translationmessage is None:
269+ other_submission = None
270+ else:
271 pofile = (
272- self.imported_translationmessage.ensureBrowserPOFile())
273+ self.other_translationmessage.ensureBrowserPOFile())
274 if pofile is None:
275- imported_submission = None
276+ other_submission = None
277 else:
278- imported_submission = (
279+ other_submission = (
280 convert_translationmessage_to_submission(
281- message=self.imported_translationmessage,
282+ message=self.other_translationmessage,
283 current_message=self.context,
284 plural_form=index,
285 pofile=pofile,
286@@ -1137,8 +1134,6 @@
287 is_empty=False,
288 packaged=True,
289 local_to_pofile=True))
290- else:
291- imported_submission = None
292
293 diverged_and_have_shared = (
294 self.context.potemplate is not None and
295@@ -1165,9 +1160,9 @@
296 'current_translation': text_to_html(
297 current_translation, self.context.potmsgset.flags),
298 'submitted_translation': submitted_translation,
299- 'imported_translation': text_to_html(
300- imported_translation, self.context.potmsgset.flags),
301- 'imported_translation_message': imported_submission,
302+ 'other_translation': text_to_html(
303+ other_translation, self.context.potmsgset.flags),
304+ 'other_translation_message': other_submission,
305 'shared_translation': text_to_html(
306 shared_translation, self.context.potmsgset.flags),
307 'shared_translation_message': shared_submission,
308@@ -1181,10 +1176,9 @@
309 self.context.makeHTMLID('translation_%d' % index),
310 }
311
312- if (not side_traits.other_side_traits.getFlag(self.context) and
313- self.imported_translationmessage is not None):
314+ if self.other_translationmessage is not None:
315 translation_entry['html_id_imported_suggestion'] = (
316- self.imported_translationmessage.makeHTMLID(
317+ self.other_translationmessage.makeHTMLID(
318 'suggestion'))
319
320 if self.message_must_be_hidden:
321@@ -1202,42 +1196,27 @@
322 # HTML id for singular form of this message
323 self.html_id_singular = self.context.makeHTMLID('translation_0')
324
325- def _set_dismiss_flags(self, local_suggestions, imported):
326+ def _set_dismiss_flags(self, local_suggestions):
327 """Set dismissal flags.
328
329 The flags are all initialized as False.
330
331 :param local_suggestions: The list of local suggestions.
332- :param imported: The imported (packaged) translation for this
333- message or None if there is no such translation.
334 """
335 # Only official translators can dismiss anything.
336 if not self.user_is_official_translator:
337 return
338
339- if imported is not None:
340- date_reviewed = self.context.date_reviewed
341- if date_reviewed is None:
342- has_new_imported = True
343- else:
344- has_new_imported = imported.date_created > date_reviewed
345- else:
346- has_new_imported = False
347-
348- # If there are no local suggestion or a newly imported string,
349- # nothing can be dismissed.
350- if not (len(local_suggestions) > 0 or has_new_imported):
351+ # If there are no local suggestions, nothing can be dismissed.
352+ if len(local_suggestions) == 0:
353 return
354
355- # OK, let's set some flags.
356- self.can_dismiss_packaged = has_new_imported
357 if self.is_plural:
358 self.can_dismiss_on_plural = True
359+ elif self.getCurrentTranslation(0) is None:
360+ self.can_dismiss_on_empty = True
361 else:
362- if self.getCurrentTranslation(0) is None:
363- self.can_dismiss_on_empty = True
364- else:
365- self.can_confirm_and_dismiss = True
366+ self.can_confirm_and_dismiss = True
367
368 def _setOnePOFile(self, messages):
369 """Return a list of messages that all have a browser_pofile set.
370@@ -1286,13 +1265,7 @@
371
372 language = self.pofile.language
373 potmsgset = self.context.potmsgset
374- side_traits = getUtility(ITranslationSideTraitsSet).getForTemplate(
375- self.pofile.potemplate)
376-
377- if not side_traits.other_side_traits.getFlag(self.context):
378- imported = self.imported_translationmessage
379- else:
380- imported = None
381+ other = self.other_translationmessage
382
383 # Show suggestions only when you can actually do something with them
384 # (i.e. you are logged in and have access to at least submit
385@@ -1308,7 +1281,7 @@
386 key=operator.attrgetter("date_created"),
387 reverse=True)
388
389- self._set_dismiss_flags(local, imported)
390+ self._set_dismiss_flags(local)
391
392 for suggestion in local:
393 suggestion.setPOFile(self.pofile)
394@@ -1360,8 +1333,8 @@
395 # suggestion per plural form.
396 for index in self.pluralform_indices:
397 self.seen_translations = set([self.context.translations[index]])
398- if imported:
399- self.seen_translations.add(imported.translations[index])
400+ if other is not None:
401+ self.seen_translations.add(other.translations[index])
402 local_suggestions = (
403 self._buildTranslationMessageSuggestions(
404 'Suggestions', local, index, local_to_pofile=True))
405@@ -1403,23 +1376,18 @@
406 self.seen_translations = iterable_submissions.seen_translations
407 return iterable_submissions
408
409- def getOfficialTranslation(self, index, is_current_upstream=False,
410- is_shared=False):
411- """Return current or imported translation for plural form 'index'."""
412+ def getOfficialTranslation(self, index, is_other=False, is_shared=False):
413+ """Return current translation on either side for plural form 'index'."""
414 assert index in self.pluralform_indices, (
415 'There is no plural form #%d for %s language' % (
416 index, self.pofile.language.displayname))
417
418- if is_current_upstream:
419- if self.imported_translationmessage is None:
420- return None
421-
422- translation = self.imported_translationmessage.translations[index]
423- elif is_shared:
424+ if is_shared:
425 if self.shared_translationmessage is None:
426 return None
427-
428 translation = self.shared_translationmessage.translations[index]
429+ elif is_other and self.other_translationmessage is not None:
430+ translation = self.other_translationmessage.translations[index]
431 else:
432 translation = self.context.translations[index]
433 # We store newlines as '\n', '\r' or '\r\n', depending on the
434@@ -1434,9 +1402,9 @@
435 """Return the current translation for the pluralform 'index'."""
436 return self.getOfficialTranslation(index)
437
438- def getImportedTranslation(self, index):
439- """Return the imported translation for the pluralform 'index'."""
440- return self.getOfficialTranslation(index, is_current_upstream=True)
441+ def getOtherTranslation(self, index):
442+ """Return the other-side translation for the pluralform 'index'."""
443+ return self.getOfficialTranslation(index, is_other=True)
444
445 def getSharedTranslation(self, index):
446 """Return the shared translation for the pluralform 'index'."""
447@@ -1581,18 +1549,15 @@
448 return 3
449
450 @property
451+ def dismissable_button_class(self):
452+ """The class string that deactivates only buttons on dismissal."""
453+ return "%s_dismissable_button" % self.html_id
454+
455+ @property
456 def dismissable_class(self):
457 """The class string for dismissable parts."""
458- return "%s_dismissable %s_dismissable_button" % (
459- self.html_id, self.html_id)
460-
461- @property
462- def dismissable_class_packaged(self):
463- """The class string for dismissable packaged translations."""
464- if self.can_dismiss_packaged:
465- return self.dismissable_class
466- # Buttons are always dismissable.
467- return "%s_dismissable_button" % self.html_id
468+ return "%s_dismissable %s" % (
469+ self.html_id, self.dismissable_button_class)
470
471
472 class CurrentTranslationMessageZoomedView(CurrentTranslationMessageView):
473
474=== modified file 'lib/lp/translations/doc/poexport-language-pack.txt'
475--- lib/lp/translations/doc/poexport-language-pack.txt 2010-11-09 09:46:20 +0000
476+++ lib/lp/translations/doc/poexport-language-pack.txt 2010-11-24 08:04:10 +0000
477@@ -313,9 +313,8 @@
478
479 >>> pofile_es = template.newPOFile('es')
480 >>> translations = { 0: u'blah (es)' }
481- >>> new_translation_message = potmsgset.updateTranslation(
482- ... pofile_es, mark, translations, is_current_upstream=False,
483- ... lock_timestamp=datetime.datetime.now(UTC))
484+ >>> new_translation_message = factory.makeCurrentTranslationMessage(
485+ ... pofile_es, potmsgset, mark, translations=translations)
486 >>> pofile_es.date_changed = d2000_01_01
487
488 Create a Welsh PO file, with an active translation submission created on
489@@ -323,9 +322,8 @@
490
491 >>> pofile_cy = template.newPOFile('cy')
492 >>> translations = { 0: u'blah (cy)' }
493- >>> new_translation_message = potmsgset.updateTranslation(
494- ... pofile_cy, mark, translations, is_current_upstream=False,
495- ... lock_timestamp=datetime.datetime.now(UTC))
496+ >>> new_translation_message = factory.makeCurrentTranslationMessage(
497+ ... pofile_cy, potmsgset, mark, translations=translations)
498 >>> pofile_cy.date_changed = d2000_01_03
499 >>> transaction.commit()
500
501
502=== modified file 'lib/lp/translations/doc/potmsgset.txt'
503--- lib/lp/translations/doc/potmsgset.txt 2010-11-18 05:28:57 +0000
504+++ lib/lp/translations/doc/potmsgset.txt 2010-11-24 08:04:10 +0000
505@@ -542,14 +542,14 @@
506 ... u'%d contact', u'%d contacts')
507 >>> pofile_es.plural_forms
508 2
509- >>> message = plural_potmsgset.updateTranslation(pofile_es, foobar,
510- ... {0: u'foo %d', 1: None}, is_current_upstream=False,
511- ... lock_timestamp=datetime.now(pytz.UTC))
512+ >>> message = factory.makeCurrentTranslationMessage(
513+ ... pofile_es, plural_potmsgset, foobar,
514+ ... translations={0: u'foo %d', 1: None})
515 >>> message.is_complete
516 False
517- >>> message = plural_potmsgset.updateTranslation(pofile_es, foobar,
518- ... {0: None}, is_current_upstream=False,
519- ... lock_timestamp=datetime.now(pytz.UTC))
520+ >>> message = factory.makeCurrentTranslationMessage(
521+ ... pofile_es, plural_potmsgset, foobar,
522+ ... translations={0: None})
523 >>> message.is_complete
524 False
525
526@@ -580,18 +580,17 @@
527
528 The message we're looking at is translated to two plural forms.
529
530- >>> message_with_two_forms = pm_potmsgset.updateTranslation(
531- ... pm_translation, pm_template.owner, ['%d fu', '%d fuitl'],
532- ... is_current_upstream=False, lock_timestamp=datetime.now(pytz.UTC))
533+ >>> message_with_two_forms = factory.makeCurrentTranslationMessage(
534+ ... pm_translation, pm_potmsgset, pm_template.owner,
535+ ... translations=['%d fu', '%d fuitl'])
536
537 When an otherwise identical translation with three comes along, the
538 third form is ignored because it falls outside the current 2 forms.
539 The "new" translation message is the same one we already had.
540
541- >>> message_with_three_forms = pm_potmsgset.updateTranslation(
542- ... pm_translation, pm_template.owner,
543- ... ['%d fu', '%d fuitl', '%d fuitlx'], is_current_upstream=False,
544- ... lock_timestamp=datetime.now(pytz.UTC))
545+ >>> message_with_three_forms = factory.makeCurrentTranslationMessage(
546+ ... pm_translation, pm_potmsgset, pm_template.owner,
547+ ... translations=['%d fu', '%d fuitl', '%d fuitlx'])
548 >>> message_with_three_forms == message_with_two_forms
549 True
550
551@@ -602,10 +601,9 @@
552 >>> zap.pluralforms = 3
553 >>> zap.pluralexpression = 'n % 3'
554
555- >>> message_with_three_forms = pm_potmsgset.updateTranslation(
556- ... pm_translation, pm_template.owner,
557- ... ['%d fu', '%d fuitl', '%d fuitlx'], is_current_upstream=False,
558- ... lock_timestamp=datetime.now(pytz.UTC))
559+ >>> message_with_three_forms = factory.makeCurrentTranslationMessage(
560+ ... pm_translation, pm_potmsgset, pm_template.owner,
561+ ... translations=['%d fu', '%d fuitl', '%d fuitlx'])
562 >>> message_with_three_forms == message_with_two_forms
563 False
564
565@@ -618,9 +616,9 @@
566 no new message is created. Instead, the closest existing match (the
567 one with two forms) is updated.
568
569- >>> message_with_one_form = pm_potmsgset.updateTranslation(
570- ... pm_translation, pm_template.owner, ['%d fu'],
571- ... is_current_upstream=False, lock_timestamp=datetime.now(pytz.UTC))
572+ >>> message_with_one_form = factory.makeCurrentTranslationMessage(
573+ ... pm_translation, pm_potmsgset, pm_template.owner,
574+ ... translations=['%d fu'])
575
576 >>> message_with_one_form == message_with_two_forms
577 True
578@@ -939,12 +937,12 @@
579 >>> spanish_pofile = alsa_potemplate.getPOFileByLang('es')
580 >>> spanish = spanish_pofile.language
581
582- >>> new_translation = translator_credits.updateTranslation(spanish_pofile,
583- ... carlos, {0: u'Some Translator'}, is_current_upstream=True,
584- ... lock_timestamp=datetime.now(pytz.UTC))
585+ >>> new_translation = factory.makeCurrentTranslationMessage(
586+ ... spanish_pofile, translator_credits, carlos,
587+ ... translations={0: u'Some Translator'})
588
589- >>> current = translator_credits.getCurrentTranslationMessage(
590- ... alsa_potemplate, spanish)
591+ >>> current = translator_credits.getCurrentTranslation(
592+ ... alsa_potemplate, spanish, alsa_potemplate.translation_side)
593 >>> current.translations
594 [u'Some Translator']
595
596
597=== modified file 'lib/lp/translations/doc/remove-translations-by.txt'
598--- lib/lp/translations/doc/remove-translations-by.txt 2010-09-30 17:57:01 +0000
599+++ lib/lp/translations/doc/remove-translations-by.txt 2010-11-24 08:04:10 +0000
600@@ -19,10 +19,9 @@
601 >>> from pytz import timezone
602 >>> def set_translation(message, pofile, text):
603 ... """Set text to be a translation for message in pofile."""
604- ... return message.updateTranslation(
605- ... pofile, pofile.potemplate.owner, {0: text},
606- ... is_current_upstream=False,
607- ... lock_timestamp=datetime.now(timezone('UTC')))
608+ ... return factory.makeCurrentTranslationMessage(
609+ ... pofile, message, pofile.potemplate.owner,
610+ ... translations={0: text})
611
612 >>> def print_pofile_contents(pofile):
613 ... """Return sorted list of (singular) translations in pofile."""
614@@ -55,9 +54,9 @@
615
616 >>> nl_message = set_translation(
617 ... message, nl_pofile, "Maar dan in het Nederlands.")
618+ >>> nl_message.is_current_upstream
619+ True
620 >>> nl_message.is_current_ubuntu
621- True
622- >>> nl_message.is_current_upstream
623 False
624 >>> print nl_message.potmsgset.msgid_singular.msgid
625 My goose is undercooked.
626@@ -89,8 +88,8 @@
627 ... '--potemplate=%s' % str(potemplate.id),
628 ... '--not-language',
629 ... '--language=%s' % 'de',
630- ... '--is-current-ubuntu=%s' % 'true',
631- ... '--is-current-upstream=%s' % 'false',
632+ ... '--is-current-ubuntu=%s' % 'false',
633+ ... '--is-current-upstream=%s' % 'true',
634 ... '--msgid=%s' % "My goose is undercooked.",
635 ... '--origin=%s' % 'ROSETTAWEB',
636 ... '--force',
637
638=== modified file 'lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt'
639--- lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2010-11-22 14:27:36 +0000
640+++ lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt 2010-11-24 08:04:10 +0000
641@@ -527,7 +527,7 @@
642 ... '+source/evolution/+pots/evolution-2.2/es/5/+translate')
643 >>> packaged = find_tag_by_id(browser.contents, 'msgset_134_packaged')
644 >>> print extract_text(packaged)
645- Packaged: tarjetas
646+ Other: tarjetas
647
648 First, we look for an existing imported translation in evolution PO file
649 in Ubuntu Hoary. We can't modify "imported" messages through web UI, so
650
651=== modified file 'lib/lp/translations/templates/currenttranslationmessage-translate-one.pt'
652--- lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2010-08-31 12:42:29 +0000
653+++ lib/lp/translations/templates/currenttranslationmessage-translate-one.pt 2010-11-24 08:04:10 +0000
654@@ -386,23 +386,23 @@
655 </tr>
656 </tal:has-submitter>
657
658- <tal:imported_translation
659+ <tal:other_translation
660 define="
661- section_title string:Packaged:;
662- submission translation_dictionary/imported_translation_message;
663- dismissable view/dismissable_class_packaged;
664+ section_title string:Other:;
665+ submission translation_dictionary/other_translation_message;
666+ dismissable view/dismissable_button_class;
667 form_is_writeable view/form_is_writeable;
668 user_is_official_translator view/user_is_official_translator;
669 ">
670 <metal:suggestion
671 use-macro="context/@@+translations-macros/render-suggestion" />
672- </tal:imported_translation>
673+ </tal:other_translation>
674 <tal:shared_translation
675 condition="translation_dictionary/shared_translation_message"
676 define="
677 section_title string:Shared:;
678 submission translation_dictionary/shared_translation_message;
679- dismissable view/dismissable_class_packaged;
680+ dismissable view/dismissable_button_class;
681 form_is_writeable view/form_is_writeable;
682 user_is_official_translator view/user_is_official_translator;
683 ">

Subscribers

People subscribed via source and target branches