diff --git a/specialpurpose/example/config/ExampleUiLabels.xml b/specialpurpose/example/config/ExampleUiLabels.xml index cc220283a9..2558df9c72 100644 --- a/specialpurpose/example/config/ExampleUiLabels.xml +++ b/specialpurpose/example/config/ExampleUiLabels.xml @@ -623,6 +623,9 @@ 表单挂件样例 表單器件範例 + + General error rendering screen [${screenLocation}]: ${errorString} + Group Gruppo @@ -637,6 +640,9 @@ 数据项组 資料項目群組 + + I/O error rendering screen [${screenLocation}]: ${errorString} + Verion der gewählten sprache Version of the choosen language @@ -770,6 +776,9 @@ 原样例 原範例 + + Parser configuration error rendering screen [${screenLocation}]: ${errorString} + Security Error: to run ${resourceDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission Erreur de sécurité : pour exécuter ${resourceDescription} vous devez avoir l'autorisation EXAMPLE_${mainAction} ou EXAMPLE_ADMIN @@ -884,6 +893,9 @@ 节点 節點 + + SAX (XML parse) error rendering screen [${screenLocation}]: ${errorString} + Repository Struktur überprüfen Scan repository structure @@ -920,6 +932,9 @@ 待实现 待實現 + + Unable to print PDF from XSL-FO: ${errorString} + You do not have permission to view this page. ("EXAMPLE_VIEW" or "EXAMPLE_ADMIN" needed) Vous n'avez pas l'autorisation de voir cette page ("EXAMPLE_VIEW" ou "EXAMPLE_ADMIN" nécessaire) diff --git a/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java b/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java index ac19d48a74..001b5a5c64 100644 --- a/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java +++ b/specialpurpose/example/src/main/java/org/apache/ofbiz/example/ExamplePrintServices.java @@ -24,6 +24,7 @@ import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.print.Doc; @@ -45,6 +46,8 @@ import org.apache.fop.apps.Fop; import org.apache.fop.apps.MimeConstants; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; +import org.apache.ofbiz.base.util.UtilMisc; +import org.apache.ofbiz.base.util.UtilProperties; import org.apache.ofbiz.entity.util.EntityUtilProperties; import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.ServiceUtil; @@ -58,8 +61,10 @@ import freemarker.template.TemplateException; public class ExamplePrintServices { public static final String module = ExamplePrintServices.class.getName(); + public static final String resource = "ExampleUiLabels"; public static Map printReportPdf(DispatchContext dctx, Map context) { + Locale locale = (Locale)context.get("locale"); String screenLocation = "component://example/widget/example/ExampleReportScreens.xml"; String reportScreenName = "ExampleReport"; Map workContext = new HashMap(); @@ -72,11 +77,11 @@ public class ExamplePrintServices { screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", dctx.getDelegator()), EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", dctx.getDelegator())); } catch (TemplateException e) { - String errMsg = "General error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleGeneralErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (IOException e) { - String errMsg = "IO error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleIOErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } @@ -90,19 +95,19 @@ public class ExamplePrintServices { try { reportScreenRenderer.render(screenLocation, reportScreenName); } catch (GeneralException e) { - String errMsg = "General error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleGeneralErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (IOException e) { - String errMsg = "IO error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleIOErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (SAXException e) { - String errMsg = "SAX (XML parse) error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleSAXErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } catch (ParserConfigurationException e) { - String errMsg = "Parser configuration error rendering screen [" + screenLocation + "]: " + e.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleParserConfigurationErrorRenderingScreen", UtilMisc.toMap("errorString", e.toString()), locale); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } @@ -149,7 +154,7 @@ public class ExamplePrintServices { try { job.print(myDoc, aset); } catch (PrintException pe) { - String errMsg = "Unable to print PDF from XSL-FO: " + pe.toString(); + String errMsg = UtilProperties.getMessage(resource, "ExampleUnableToPrintPDFFromXSL-FO", UtilMisc.toMap("errorString", pe.toString()), locale); Debug.logError(pe, errMsg, module); return ServiceUtil.returnError(errMsg); }