Commit 08ca72b7 authored by Nicolas Delaby's avatar Nicolas Delaby

Use getMessageIdWithContext to generate Translatable Workflow state message.

Cosmectic changes.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33983 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 63d66251
...@@ -33,6 +33,7 @@ import MethodObject ...@@ -33,6 +33,7 @@ import MethodObject
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import to_utf8 from Products.ERP5Type.tests.utils import to_utf8
from Products.ERP5Type.Utils import getMessageIdWithContext
from zLOG import LOG from zLOG import LOG
# dependency order # dependency order
...@@ -132,7 +133,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase): ...@@ -132,7 +133,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
for state in workflow.states.items(): for state in workflow.states.items():
state_title = state[1].title state_title = state[1].title
state_id = state[0] state_id = state[0]
msgid = '%s [state in %s]' % (state_title, workflow_id) msgid = getMessageIdWithContext(state_title, 'state', workflow_id)
translated_state_title = self.getTranslation(msgid) translated_state_title = self.getTranslation(msgid)
if translated_state_title is not None: if translated_state_title is not None:
...@@ -248,34 +249,37 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase): ...@@ -248,34 +249,37 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
message_catalog = self.portal.Localizer.erp5_ui message_catalog = self.portal.Localizer.erp5_ui
message_catalog.gettext('Validated', add=1) message_catalog.gettext('Validated', add=1)
message_catalog.gettext("Draft",add=1) message_catalog.gettext('Draft', add=1)
message_catalog.gettext("Validated [state in item_workflow]", add=1) message_catalog.gettext(getMessageIdWithContext('Validated',
message_catalog.message_edit( 'state',
'Validated', self.lang, 'Validé'.decode('utf8'), '') 'item_workflow'),
message_catalog.message_edit( add=1)
"Validated [state in item_workflow]",self.lang,"En bon usage", '') message_catalog.message_edit('Validated', self.lang,
'Validé'.decode('utf8'), '')
message_catalog.message_edit(getMessageIdWithContext('Validated',
'state',
'item_workflow'),
self.lang, "En bon usage", '')
message_catalog.message_edit('Draft', self.lang, '', '') message_catalog.message_edit('Draft', self.lang, '', '')
organisation_module = self.getPortal().organisation_module portal_type = 'Organisation'
organisation_module = self.getPortal().getDefaultModule(portal_type)
organisation = organisation_module.newContent( organisation = organisation_module.newContent(
portal_type='Organisation', portal_type=portal_type,
title = 'My Organisation') title='My Organisation')
organisation.validate() organisation.validate()
item_module = self.getPortal().item_module portal_type = 'Item'
item = item_module.newContent(portal_type='Item', item_module = self.getPortal().getDefaultModule(portal_type)
title = 'Lot A') item = item_module.newContent(portal_type=portal_type, title='Lot A')
transaction.commit() transaction.commit()
self.tic() self.tic()
self.portal.Localizer.get_selected_language = lambda: self.lang self.portal.Localizer.get_selected_language = lambda: self.lang
self.assertEquals( self.assertEquals(item.getTranslatedValidationStateTitle(), 'Draft')
item.getTranslatedValidationStateTitle(),'Draft')
item.validate() item.validate()
self.assertEquals(item.getTranslatedValidationStateTitle(), self.assertEquals(item.getTranslatedValidationStateTitle(), "En bon usage")
"En bon usage") self.assertEquals(organisation.getTranslatedValidationStateTitle(),
self.assertEquals( 'Validé')
organisation.getTranslatedValidationStateTitle(),'Validé')
class LanguageGetter(MethodObject.Method): class LanguageGetter(MethodObject.Method):
...@@ -289,6 +293,9 @@ class TestTranslation(ERP5TypeTestCase): ...@@ -289,6 +293,9 @@ class TestTranslation(ERP5TypeTestCase):
lang = 'fr' lang = 'fr'
def getTitle(self):
return 'Test Translation'
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ['erp5_base',] return ['erp5_base',]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment