launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28863
[Merge] ~cjwatson/launchpad:rename-dummy-translation-message into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:rename-dummy-translation-message into launchpad:master.
Commit message:
Rename DummyTranslationMessage to PlaceholderTranslationMessage
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/427225
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:rename-dummy-translation-message into launchpad:master.
diff --git a/lib/lp/translations/browser/pofile.py b/lib/lp/translations/browser/pofile.py
index 6f3f897..594bce4 100644
--- a/lib/lp/translations/browser/pofile.py
+++ b/lib/lp/translations/browser/pofile.py
@@ -84,7 +84,8 @@ class POFileNavigation(Navigation):
raise NotFoundError(
"%r is not a valid sequence number." % name)
- return potmsgset.getCurrentTranslationMessageOrDummy(self.context)
+ return potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ self.context)
class POFileMenuMixin:
@@ -614,7 +615,8 @@ class POFileTranslateView(BaseTranslationView, POFileMetadataViewMixin):
can_edit = self.context.canEditTranslations(self.user)
for potmsgset in for_potmsgsets:
translationmessage = (
- potmsgset.getCurrentTranslationMessageOrDummy(self.context))
+ potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ self.context))
error = self.errors.get(potmsgset)
view = self._prepareView(
diff --git a/lib/lp/translations/browser/tests/pofile-views.rst b/lib/lp/translations/browser/tests/pofile-views.rst
index ea86559..de6c959 100644
--- a/lib/lp/translations/browser/tests/pofile-views.rst
+++ b/lib/lp/translations/browser/tests/pofile-views.rst
@@ -9,7 +9,7 @@ First, we need some imports.
>>> from zope.publisher.browser import FileUpload
>>> from lp.services.database.sqlbase import flush_database_caches
>>> from lp.translations.model.translationmessage import (
- ... TranslationMessage, DummyTranslationMessage)
+ ... TranslationMessage, PlaceholderTranslationMessage)
>>> from lp.translations.interfaces.translationimportqueue import (
... ITranslationImportQueue)
>>> from lp.registry.interfaces.distribution import IDistributionSet
@@ -471,10 +471,10 @@ message.
Now, we are going to select a translation message that doesn't exist
yet in our database.
- >>> isinstance(navigation.traverse('22'), DummyTranslationMessage)
+ >>> isinstance(navigation.traverse('22'), PlaceholderTranslationMessage)
True
-But if we do a POST, instead of getting a DummyTranslationMessage
+But if we do a POST, instead of getting a PlaceholderTranslationMessage
object, we will get a TranslationMessage.
# >>> request.method = 'POST'
diff --git a/lib/lp/translations/browser/tests/translationmessage-views.rst b/lib/lp/translations/browser/tests/translationmessage-views.rst
index 1d936cc..66a89c0 100644
--- a/lib/lp/translations/browser/tests/translationmessage-views.rst
+++ b/lib/lp/translations/browser/tests/translationmessage-views.rst
@@ -30,7 +30,7 @@ without the plural form information.
>>> potmsgset = pofile_tlh.potemplate.getPOTMsgSetByMsgIDText(
... u'evolution addressbook')
>>> current_translationmessage = (
- ... potmsgset.getCurrentTranslationMessageOrDummy(pofile_tlh))
+ ... potmsgset.getCurrentTranslationMessageOrPlaceholder(pofile_tlh))
>>> translationmessage_page_view = create_view(
... current_translationmessage, "+translate")
>>> translationmessage_page_view.initialize()
diff --git a/lib/lp/translations/browser/translationmessage.py b/lib/lp/translations/browser/translationmessage.py
index 105ad46..e008897 100644
--- a/lib/lp/translations/browser/translationmessage.py
+++ b/lib/lp/translations/browser/translationmessage.py
@@ -770,7 +770,7 @@ class BaseTranslationView(LaunchpadView):
# current translation, suggestion or the new translation
# field.
current_translation_message = (
- potmsgset.getCurrentTranslationMessageOrDummy(
+ potmsgset.getCurrentTranslationMessageOrPlaceholder(
self.pofile))
if (selected_translation_key !=
msgset_ID_LANGCODE_translation_PLURALFORM_new):
diff --git a/lib/lp/translations/configure.zcml b/lib/lp/translations/configure.zcml
index fdb066c..eea513c 100644
--- a/lib/lp/translations/configure.zcml
+++ b/lib/lp/translations/configure.zcml
@@ -502,10 +502,10 @@
set_schema="lp.translations.interfaces.translationmessage.ITranslationMessage"/>
</class>
- <!-- Dummy Translation Message. It's a read only class. -->
+ <!-- Placeholder Translation Message. It's a read only class. -->
<class
- class="lp.translations.model.translationmessage.DummyTranslationMessage">
+ class="lp.translations.model.translationmessage.PlaceholderTranslationMessage">
<allow
interface="lp.translations.interfaces.translationmessage.ITranslationMessage"/>
</class>
diff --git a/lib/lp/translations/doc/canonical_url_examples.rst b/lib/lp/translations/doc/canonical_url_examples.rst
index a17f48b..64fc808 100644
--- a/lib/lp/translations/doc/canonical_url_examples.rst
+++ b/lib/lp/translations/doc/canonical_url_examples.rst
@@ -68,11 +68,11 @@ Also, we can get the url to a translation message.
>>> print(canonical_url(translationmessage))
http://transl.../hoary/+source/evolution/+pots/evolution-2.2/es/1
-Even for a dummy one.
+Even for a placeholder one.
>>> potmsgset = potemplate.getPOTMsgSetBySequence(20)
- >>> translationmessage = potmsgset.getCurrentTranslationMessageOrDummy(
- ... pofile)
+ >>> translationmessage = (
+ ... potmsgset.getCurrentTranslationMessageOrPlaceholder(pofile))
>>> print(canonical_url(translationmessage))
http://transl.../hoary/+source/evolution/+pots/evolution-2.2/es/20
@@ -97,7 +97,7 @@ with the distro subset.
>>> print(canonical_url(pofile))
http://translations.../evolution/trunk/+pots/evolution-2.2/es
-Also, we can get the url to a dummy one
+Also, we can get the url to a placeholder one.
>>> potmsgset = potemplate.getPOTMsgSetBySequence(1)
>>> translationmessage = potmsgset.getCurrentTranslation(
@@ -106,11 +106,11 @@ Also, we can get the url to a dummy one
>>> print(canonical_url(translationmessage))
http://translations.../evolution/trunk/+pots/evolution-2.2/es/1
-Even for a dummy PO msgset
+Even for a placeholder PO msgset.
>>> potmsgset = potemplate.getPOTMsgSetBySequence(20)
- >>> translationmessage = potmsgset.getCurrentTranslationMessageOrDummy(
- ... pofile)
+ >>> translationmessage = (
+ ... potmsgset.getCurrentTranslationMessageOrPlaceholder(pofile))
>>> print(canonical_url(translationmessage))
http://translations.../evolution/trunk/+pots/evolution-2.2/es/20
diff --git a/lib/lp/translations/doc/potmsgset.rst b/lib/lp/translations/doc/potmsgset.rst
index a326a08..c024932 100644
--- a/lib/lp/translations/doc/potmsgset.rst
+++ b/lib/lp/translations/doc/potmsgset.rst
@@ -87,7 +87,7 @@ We get a POTMsgSet and verify it's a singular form:
>>> print(current)
None
>>> pt_BR_placeholder_current = (
- ... potmsgset.getCurrentTranslationMessageOrDummy(
+ ... potmsgset.getCurrentTranslationMessageOrPlaceholder(
... pt_BR_placeholderpofile))
>>> pt_BR_placeholder_current.plural_forms
1
@@ -117,7 +117,7 @@ back to the most common case:
>>> print(apa_placeholderpofile.language.pluralforms)
None
>>> apa_placeholder_current = (
- ... plural_potmsgset.getCurrentTranslationMessageOrDummy(
+ ... plural_potmsgset.getCurrentTranslationMessageOrPlaceholder(
... apa_placeholderpofile))
>>> apa_placeholder_current.plural_forms
2
@@ -130,7 +130,7 @@ We can guess the pluralforms for this language through ILanguage.pluralforms:
>>> ru_placeholderpofile = evolution_potemplate.getPlaceholderPOFile(
... language_ru)
>>> ru_placeholder_current = (
- ... plural_potmsgset.getCurrentTranslationMessageOrDummy(
+ ... plural_potmsgset.getCurrentTranslationMessageOrPlaceholder(
... ru_placeholderpofile))
>>> print(ru_placeholderpofile.language.pluralforms)
@@ -474,11 +474,11 @@ the 'wiki' space is for any submission done outside that IPOMsgSet.
>>> len(wiki_submissions)
0
-Now, we get a dummy message that has the same msgid as the previous one.
-A dummy message is one that is not yet stored in our database, we use
+Now, we get a placeholder message that has the same msgid as the previous one.
+A placeholder message is one that is not yet stored in our database, we use
them to be able to render those messages in our UI, once we get a
submission with a value for it, it's created in our database so it's not
-dummy anymore.
+placeholder anymore.
>>> pmount_hoary_package = ubuntu_hoary.getSourcePackage('pmount')
>>> pmount_man_template = getUtility(IPOTemplateSet).getSubset(
diff --git a/lib/lp/translations/doc/translationmessage.rst b/lib/lp/translations/doc/translationmessage.rst
index aff181d..39b614a 100644
--- a/lib/lp/translations/doc/translationmessage.rst
+++ b/lib/lp/translations/doc/translationmessage.rst
@@ -19,16 +19,17 @@ Let's do some imports we will need to test this class.
This class links the translations submitted by a translator with the
associated POFile and POTMsgSet. TranslationMessage and
-DummyTranslationMessage both implement ITranslationMessage:
+PlaceholderTranslationMessage both implement ITranslationMessage:
>>> translationmessage = factory.makeCurrentTranslationMessage(
... potmsgset=potmsgset, pofile=pofile_es)
>>> verifyObject(ITranslationMessage, translationmessage)
True
- >>> dummy_message = potmsgset.getCurrentTranslationMessageOrDummy(
- ... factory.makePOFile('xh'))
- >>> verifyObject(ITranslationMessage, dummy_message)
+ >>> placeholder_message = (
+ ... potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ ... factory.makePOFile('xh')))
+ >>> verifyObject(ITranslationMessage, placeholder_message)
True
@@ -51,7 +52,7 @@ language:
>>> serbian = getUtility(ILanguageSet)['sr']
>>> serbian.pluralforms
3
- >>> current_sr = potmsgset.getCurrentTranslationMessageOrDummy(
+ >>> current_sr = potmsgset.getCurrentTranslationMessageOrPlaceholder(
... PlaceholderPOFile(potemplate, serbian))
>>> current_sr.plural_forms
1
@@ -59,7 +60,7 @@ language:
>>> divehi = getUtility(ILanguageSet)['dv']
>>> print(divehi.pluralforms)
None
- >>> current_dv = potmsgset.getCurrentTranslationMessageOrDummy(
+ >>> current_dv = potmsgset.getCurrentTranslationMessageOrPlaceholder(
... PlaceholderPOFile(potemplate, divehi))
>>> current_dv.plural_forms
1
@@ -74,8 +75,9 @@ forms per language (3 for Serbian, as specified in the language).
plural
>>> serbian.pluralforms
3
- >>> current_sr = potmsgset_plural.getCurrentTranslationMessageOrDummy(
- ... PlaceholderPOFile(potemplate, serbian))
+ >>> current_sr = (
+ ... potmsgset_plural.getCurrentTranslationMessageOrPlaceholder(
+ ... PlaceholderPOFile(potemplate, serbian)))
>>> current_sr.plural_forms
3
@@ -84,8 +86,9 @@ a default of 2, which is the most common number of plural forms:
>>> print(divehi.pluralforms)
None
- >>> current_dv = potmsgset_plural.getCurrentTranslationMessageOrDummy(
- ... PlaceholderPOFile(potemplate, divehi))
+ >>> current_dv = (
+ ... potmsgset_plural.getCurrentTranslationMessageOrPlaceholder(
+ ... PlaceholderPOFile(potemplate, divehi)))
>>> current_dv.plural_forms
2
diff --git a/lib/lp/translations/interfaces/potmsgset.py b/lib/lp/translations/interfaces/potmsgset.py
index 3390f5f..af8d855 100644
--- a/lib/lp/translations/interfaces/potmsgset.py
+++ b/lib/lp/translations/interfaces/potmsgset.py
@@ -125,12 +125,12 @@ class IPOTMsgSet(Interface):
def clone():
"""Return a new copy of this POTMsgSet."""
- def getCurrentTranslationMessageOrDummy(pofile):
- """Return the current `TranslationMessage`, or a dummy.
+ def getCurrentTranslationMessageOrPlaceholder(pofile):
+ """Return the current `TranslationMessage`, or a placeholder.
:param pofile: PO template you want a translation message for.
:return: The current translation for `self` in `pofile`, if
- there is one. Otherwise, a `DummyTranslationMessage` for
+ there is one. Otherwise, a `PlaceholderTranslationMessage` for
`self` in `pofile`.
"""
diff --git a/lib/lp/translations/model/potmsgset.py b/lib/lp/translations/model/potmsgset.py
index 9cb6702..7851508 100644
--- a/lib/lp/translations/model/potmsgset.py
+++ b/lib/lp/translations/model/potmsgset.py
@@ -76,8 +76,8 @@ from lp.translations.interfaces.translations import TranslationConstants
from lp.translations.model.pomsgid import POMsgID
from lp.translations.model.potranslation import POTranslation
from lp.translations.model.translationmessage import (
- DummyTranslationMessage,
make_plurals_sql_fragment,
+ PlaceholderTranslationMessage,
TranslationMessage,
)
from lp.translations.model.translationtemplateitem import (
@@ -274,17 +274,17 @@ class POTMsgSet(SQLBase):
else:
return self.msgid_plural.msgid
- def getCurrentTranslationMessageOrDummy(self, pofile):
+ def getCurrentTranslationMessageOrPlaceholder(self, pofile):
"""See `IPOTMsgSet`."""
template = pofile.potemplate
current = self.getCurrentTranslation(
template, pofile.language, template.translation_side)
if current is None:
- dummy = DummyTranslationMessage(pofile, self)
+ placeholder = PlaceholderTranslationMessage(pofile, self)
side = pofile.potemplate.translation_side
traits = getUtility(ITranslationSideTraitsSet).getTraits(side)
- traits.setFlag(dummy, True)
- return dummy
+ traits.setFlag(placeholder, True)
+ return placeholder
else:
current.setPOFile(pofile)
return current
diff --git a/lib/lp/translations/model/translationmessage.py b/lib/lp/translations/model/translationmessage.py
index 41332cd..3441d64 100644
--- a/lib/lp/translations/model/translationmessage.py
+++ b/lib/lp/translations/model/translationmessage.py
@@ -2,9 +2,9 @@
# GNU Affero General Public License version 3 (see the file LICENSE).
__all__ = [
- 'DummyTranslationMessage',
'make_plurals_sql_fragment',
'make_plurals_fragment',
+ 'PlaceholderTranslationMessage',
'TranslationMessage',
'TranslationMessageSet',
]
@@ -153,7 +153,7 @@ class TranslationMessageMixIn:
@implementer(ITranslationMessage)
-class DummyTranslationMessage(TranslationMessageMixIn):
+class PlaceholderTranslationMessage(TranslationMessageMixIn):
"""Represents an `ITranslationMessage` where we don't yet HAVE it.
We do not put TranslationMessages in the database when we only have
diff --git a/lib/lp/translations/tests/test_potmsgset.py b/lib/lp/translations/tests/test_potmsgset.py
index fd19fa4..6954826 100644
--- a/lib/lp/translations/tests/test_potmsgset.py
+++ b/lib/lp/translations/tests/test_potmsgset.py
@@ -32,7 +32,9 @@ from lp.translations.interfaces.translationmessage import (
RosettaTranslationOrigin,
TranslationConflict,
)
-from lp.translations.model.translationmessage import DummyTranslationMessage
+from lp.translations.model.translationmessage import (
+ PlaceholderTranslationMessage,
+ )
class TestTranslationSharedPOTMsgSets(TestCaseWithFactory):
@@ -87,15 +89,17 @@ class TestTranslationSharedPOTMsgSets(TestCaseWithFactory):
transaction.commit()
self.assertTrue(self.potmsgset.uses_english_msgids)
- def test_getCurrentTranslationMessageOrDummy_returns_upstream_tm(self):
+ def test_getCurrentTranslationMessageOrPlaceholder_returns_upstream_tm(
+ self):
pofile = self.factory.makePOFile('nl')
message = self.factory.makeCurrentTranslationMessage(pofile=pofile)
self.assertEqual(
message,
- message.potmsgset.getCurrentTranslationMessageOrDummy(pofile))
+ message.potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ pofile))
- def test_getCurrentTranslationMessageOrDummy_returns_ubuntu_tm(self):
+ def test_getCurrentTranslationMessageOrPlaceholder_returns_ubuntu_tm(self):
package = self.factory.makeSourcePackage()
template = self.factory.makePOTemplate(
distroseries=package.distroseries,
@@ -105,36 +109,40 @@ class TestTranslationSharedPOTMsgSets(TestCaseWithFactory):
self.assertEqual(
message,
- message.potmsgset.getCurrentTranslationMessageOrDummy(pofile))
+ message.potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ pofile))
- def test_getCurrentTranslationMessageOrDummy_returns_dummy_tm(self):
+ def test_getCurrentTranslationMessageOrPlaceholder_returns_placeholder_tm(
+ self):
pofile = self.factory.makePOFile('nl')
potmsgset = self.factory.makePOTMsgSet(pofile.potemplate)
- message = potmsgset.getCurrentTranslationMessageOrDummy(pofile)
- self.assertIsInstance(message, DummyTranslationMessage)
+ message = potmsgset.getCurrentTranslationMessageOrPlaceholder(pofile)
+ self.assertIsInstance(message, PlaceholderTranslationMessage)
- def test_getCurrentTranslationMessageOrDummy_dummy_is_upstream(self):
- # When getCurrentDummyTranslationMessage creates a dummy for an
- # upstream translation, the dummy is current for upstream (but
- # not for Ubuntu).
+ def test_getCurrentTranslationMessageOrPlaceholder_is_upstream(self):
+ # When getCurrentTranslationMessageOrPlaceholder creates a
+ # placeholder for an upstream translation, the placeholder is
+ # current for upstream (but not for Ubuntu).
pofile = self.factory.makePOFile('fy')
- dummy = self.potmsgset.getCurrentTranslationMessageOrDummy(pofile)
- self.assertTrue(dummy.is_current_upstream)
- self.assertFalse(dummy.is_current_ubuntu)
-
- def test_getCurrentTranslationMessageOrDummy_dummy_is_ubuntu(self):
- # When getCurrentDummyTranslationMessage creates a dummy for an
- # Ubuntu translation, the dummy is current for Ubuntu (but
- # not upstream).
+ placeholder = self.potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ pofile)
+ self.assertTrue(placeholder.is_current_upstream)
+ self.assertFalse(placeholder.is_current_ubuntu)
+
+ def test_getCurrentTranslationMessageOrPlaceholder_is_ubuntu(self):
+ # When getCurrentTranslationMessageOrPlaceholder creates a
+ # placeholder for an Ubuntu translation, the placeholder is current
+ # for Ubuntu (but not upstream).
package = self.factory.makeSourcePackage()
template = self.factory.makePOTemplate(
distroseries=package.distroseries,
sourcepackagename=package.sourcepackagename)
pofile = self.factory.makePOFile(potemplate=template)
- dummy = self.potmsgset.getCurrentTranslationMessageOrDummy(pofile)
- self.assertTrue(dummy.is_current_ubuntu)
- self.assertFalse(dummy.is_current_upstream)
+ placeholder = self.potmsgset.getCurrentTranslationMessageOrPlaceholder(
+ pofile)
+ self.assertTrue(placeholder.is_current_ubuntu)
+ self.assertFalse(placeholder.is_current_upstream)
def test_getCurrentTranslation(self):
"""Test how shared and diverged current translation messages
diff --git a/lib/lp/translations/tests/test_translationmessage.py b/lib/lp/translations/tests/test_translationmessage.py
index d8c382e..ca110f0 100644
--- a/lib/lp/translations/tests/test_translationmessage.py
+++ b/lib/lp/translations/tests/test_translationmessage.py
@@ -34,7 +34,7 @@ from lp.translations.interfaces.translationmessage import (
from lp.translations.interfaces.translations import TranslationConstants
from lp.translations.model.potranslation import POTranslation
from lp.translations.model.translationmessage import (
- DummyTranslationMessage,
+ PlaceholderTranslationMessage,
TranslationMessage,
)
@@ -52,11 +52,11 @@ class TestTranslationMessage(TestCaseWithFactory):
message = self.factory.makeCurrentTranslationMessage()
verifyObject(ITranslationMessage, message)
- def test_dummy_translationmessage(self):
+ def test_placeholder_translationmessage(self):
pofile = self.factory.makePOFile('nl')
potmsgset = self.factory.makePOTMsgSet(pofile.potemplate)
- dummy = DummyTranslationMessage(pofile, potmsgset)
- verifyObject(ITranslationMessage, dummy)
+ placeholder = PlaceholderTranslationMessage(pofile, potmsgset)
+ verifyObject(ITranslationMessage, placeholder)
def test_is_diverged_false(self):
# ITranslationMessage.is_diverged is a little helper to let you