This is an automated email from the ASF dual-hosted git repository. nmalin pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push: new f82f763 Implemented: Groovy DSL add label method (OFBIZ-12319) f82f763 is described below commit f82f7631b145014b652df5f8b7c675e98e277052 Author: Nicolas Malin <nicolas.ma...@nereide.fr> AuthorDate: Wed Sep 15 11:59:15 2021 +0200 Implemented: Groovy DSL add label method (OFBIZ-12319) Improve the groovy dsl with a simple method 'label' to resolve an uiLabel instead of use 'UtilProperty.getMessage()' on groovy script. Previously we used: UtilProperties.getMessage("AccountingUiLabels", "AccountingUpdatePaymentPermissionError", 'locale')) Now we can write: label("AccountingUiLabels", "AccountingUpdatePaymentPermissionError") --- .../apache/ofbiz/service/engine/GroovyBaseScript.groovy | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/framework/service/src/main/groovy/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy b/framework/service/src/main/groovy/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy index 0d0a33f..d2d247d 100644 --- a/framework/service/src/main/groovy/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy +++ b/framework/service/src/main/groovy/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy @@ -19,6 +19,7 @@ package org.apache.ofbiz.service.engine import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilProperties import org.apache.ofbiz.entity.util.EntityQuery import org.apache.ofbiz.service.DispatchContext import org.apache.ofbiz.service.LocalDispatcher @@ -142,4 +143,18 @@ abstract class GroovyBaseScript extends Script { def logVerbose(String message) { Debug.logVerbose(message, getModule()) } + + def label(String ressource, String message) { + return label(ressource, message, null) + } + def label(String ressource, String message, Map context) { + Locale locale = this.binding.getVariable('locale') + if (!locale) { + locale = Locale.getDefault() + } + if (context) { + return UtilProperties.getMessage(ressource, message, context, locale) + } + return UtilProperties.getMessage(ressource, message, locale) + } }