Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
00a67f20
Commit
00a67f20
authored
Sep 07, 2018
by
Cédric Le Ninivin
Committed by
Cédric Le Ninivin
Mar 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Translation: Workflow State can have specific translation by portal_type
parent
8560318e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
24 deletions
+31
-24
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
...portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
+2
-7
product/ERP5Type/Accessor/WorkflowState.py
product/ERP5Type/Accessor/WorkflowState.py
+8
-8
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+16
-0
product/ERP5Type/__init__.py
product/ERP5Type/__init__.py
+1
-0
product/ERP5Type/patches/DCWorkflowGraph.py
product/ERP5Type/patches/DCWorkflowGraph.py
+4
-9
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
View file @
00a67f20
from
Products.ERP5Type.Utils
import
get
MessageIdWithContext
from
Products.ERP5Type.Utils
import
get
TranslatedWorkflowStateWithPortalType
supported_languages
=
context
.
Localizer
.
get_supported_languages
()
supported_languages
=
context
.
Localizer
.
get_supported_languages
()
translated_keys
=
{}
# This dict prevents entering the same key twice
translated_keys
=
{}
# This dict prevents entering the same key twice
...
@@ -42,18 +42,13 @@ for portal_type in portal_type_list:
...
@@ -42,18 +42,13 @@ for portal_type in portal_type_list:
# translate state title as well
# translate state title as well
if
state
.
getTitle
()
is
not
None
and
state
.
getTitle
()
!=
''
:
if
state
.
getTitle
()
is
not
None
and
state
.
getTitle
()
!=
''
:
state_var_title
=
'%s_title'
%
state_var
state_var_title
=
'%s_title'
%
state_var
msg_id
=
getMessageIdWithContext
(
state
.
getTitle
(),
'state'
,
wf_id
)
translated_message
,
msg_id
=
getTranslatedWorkflowStateWithPortalType
(
context
.
Localizer
,
wf_id
,
lang
,
portal_type
,
state
.
getTitle
())
translated_message
=
context
.
Localizer
.
erp5_ui
.
gettext
(
msg_id
,
default
=
''
,
lang
=
lang
).
encode
(
'utf-8'
)
if
translated_message
==
''
:
msg_id
=
state
.
getTitle
()
translated_message
=
context
.
Localizer
.
erp5_ui
.
gettext
(
state
.
getTitle
().
decode
(
'utf-8'
),
lang
=
lang
).
encode
(
'utf-8'
)
key
=
(
lang
,
portal_type
.
getId
(),
state_var_title
,
state_reference
,
msg_id
)
key
=
(
lang
,
portal_type
.
getId
(),
state_var_title
,
state_reference
,
msg_id
)
if
key
not
in
translated_keys
:
if
key
not
in
translated_keys
:
translated_keys
[
key
]
=
None
# mark as translated
translated_keys
[
key
]
=
None
# mark as translated
object_list
.
append
(
dict
(
language
=
lang
,
message_context
=
state_var_title
,
portal_type
=
portal_type
.
getId
(),
original_message
=
state_reference
,
object_list
.
append
(
dict
(
language
=
lang
,
message_context
=
state_var_title
,
portal_type
=
portal_type
.
getId
(),
original_message
=
state_reference
,
translated_message
=
translated_message
))
translated_message
=
translated_message
))
if
object_list
:
if
object_list
:
catalog_translation_list
(
object_list
)
catalog_translation_list
(
object_list
)
...
...
product/ERP5Type/Accessor/WorkflowState.py
View file @
00a67f20
...
@@ -30,6 +30,7 @@ from __future__ import absolute_import
...
@@ -30,6 +30,7 @@ from __future__ import absolute_import
from
Products.ERP5Type.Utils
import
unicode2str
from
Products.ERP5Type.Utils
import
unicode2str
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Products.ERP5Type.PsycoWrapper
import
psyco
from
Products.ERP5Type.PsycoWrapper
import
psyco
from
Products.ERP5Type.Utils
import
getTranslatedWorkflowStateWithPortalType
from
.Base
import
Getter
as
BaseGetter
,
Setter
as
BaseSetter
from
.Base
import
Getter
as
BaseGetter
,
Setter
as
BaseSetter
from
warnings
import
warn
from
warnings
import
warn
...
@@ -113,14 +114,13 @@ class TranslatedTitleGetter(TitleGetter):
...
@@ -113,14 +114,13 @@ class TranslatedTitleGetter(TitleGetter):
wf
=
portal
.
portal_workflow
.
_getOb
(
wf_id
)
wf
=
portal
.
portal_workflow
.
_getOb
(
wf_id
)
selected_language
=
localizer
.
get_selected_language
()
selected_language
=
localizer
.
get_selected_language
()
state_title
=
wf
.
_getWorkflowStateOf
(
instance
).
title
state_title
=
wf
.
_getWorkflowStateOf
(
instance
).
title
msg_id
=
'%s [state in %s]'
%
(
state_title
,
wf_id
)
return
getTranslatedWorkflowStateWithPortalType
(
result
=
localizer
.
erp5_ui
.
gettext
(
msg_id
,
localizer
,
lang
=
selected_language
,
self
.
_key
,
default
=
''
)
selected_language
,
if
result
==
''
:
instance
.
getPortalType
(),
result
=
localizer
.
erp5_ui
.
gettext
(
state_title
,
state_title
lang
=
selected_language
)
)[
0
]
return
unicode2str
(
result
)
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
...
...
product/ERP5Type/Utils.py
View file @
00a67f20
...
@@ -366,6 +366,22 @@ def int2letter(i):
...
@@ -366,6 +366,22 @@ def int2letter(i):
def
getMessageIdWithContext
(
msg_id
,
context
,
context_id
):
def
getMessageIdWithContext
(
msg_id
,
context
,
context_id
):
return
'%s [%s in %s]'
%
(
msg_id
,
context
,
context_id
)
return
'%s [%s in %s]'
%
(
msg_id
,
context
,
context_id
)
def
getTranslatedWorkflowStateWithPortalType
(
localizer
,
workflow_id
,
lang
,
portal_type
,
state_title
):
for
msg_id
,
default
in
[
(
getMessageIdWithContext
(
state_title
,
'state'
,
portal_type
),
''
),
(
getMessageIdWithContext
(
state_title
,
'state'
,
workflow_id
),
''
),
(
state_title
.
decode
(
'utf-8'
),
None
),
]:
translated_message
=
localizer
.
erp5_ui
.
gettext
(
msg_id
,
default
=
default
,
lang
=
lang
).
encode
(
'utf-8'
)
if
translated_message
:
return
translated_message
,
msg_id
#Get translation of msg id
#Get translation of msg id
def
getTranslationStringWithContext
(
self
,
msg_id
,
context
,
context_id
):
def
getTranslationStringWithContext
(
self
,
msg_id
,
context
,
context_id
):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
...
...
product/ERP5Type/__init__.py
View file @
00a67f20
...
@@ -187,6 +187,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
...
@@ -187,6 +187,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
'sortValueList'
,
'convertToUpperCase'
,
'UpperCase'
,
'sortValueList'
,
'convertToUpperCase'
,
'UpperCase'
,
'convertToMixedCase'
,
'cartesianProduct'
,
'sleep'
,
'getCommonTimeZoneList'
,
'convertToMixedCase'
,
'cartesianProduct'
,
'sleep'
,
'getCommonTimeZoneList'
,
'int2letter'
,
'getMessageIdWithContext'
,
'getTranslationStringWithContext'
,
'int2letter'
,
'getMessageIdWithContext'
,
'getTranslationStringWithContext'
,
'getTranslatedWorkflowStateWithPortalType'
,
'Email_parseAddressHeader'
,
'guessEncodingFromText'
,
'Email_parseAddressHeader'
,
'guessEncodingFromText'
,
'isValidTALESExpression'
,
'isValidTALESExpression'
,
'ensure_list'
,
'bytes2str'
,
'str2bytes'
,
'str2unicode'
,
'unicode2str'
,
'ensure_list'
,
'bytes2str'
,
'str2bytes'
,
'str2unicode'
,
'unicode2str'
,
...
...
product/ERP5Type/patches/DCWorkflowGraph.py
View file @
00a67f20
...
@@ -36,6 +36,7 @@ else:
...
@@ -36,6 +36,7 @@ else:
# BBB keep Products.DCWorkflowGraph patch for a while as it solves a security issue
# BBB keep Products.DCWorkflowGraph patch for a while as it solves a security issue
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Utils
import
getTranslatedWorkflowStateWithPortalType
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
# Products.DCWorkflowGraph.config does not check the return value of
# Products.DCWorkflowGraph.config does not check the return value of
...
@@ -113,15 +114,9 @@ else:
...
@@ -113,15 +114,9 @@ else:
localizer
=
obj
.
Localizer
localizer
=
obj
.
Localizer
original_title
=
title
original_title
=
title
for
lang
in
localizer
.
get_supported_languages
():
for
lang
in
localizer
.
get_supported_languages
():
msg_id
=
'%s [state in %s]'
%
(
title
,
wf_id
)
translated_message
,
msg_id
=
getTranslatedWorkflowStateWithPortalType
(
translated_title
=
localizer
.
erp5_ui
.
gettext
(
localizer
,
wf_id
,
lang
,
obj
.
getPortalType
(),
title
msg_id
,
)
lang
=
lang
,
# Fallback on non-workflow state translation
default
=
localizer
.
erp5_ui
.
gettext
(
original_title
,
lang
=
lang
,
default
=
None
))
if
(
translated_title
is
not
None
and
if
(
translated_title
is
not
None
and
translated_title
!=
original_title
):
translated_title
!=
original_title
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment