Author: mrisaliti
Date: Tue Jan 18 21:00:42 2011 New Revision: 1060578 URL: http://svn.apache.org/viewvc?rev=1060578&view=rev Log: Internationalization of ServiceUtil.returnSuccess, ServiceUtil.returnFailure, ServiceUtil.returnError (OFBIZ-4091) Modified: ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java Modified: ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml?rev=1060578&r1=1060577&r2=1060578&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml Tue Jan 18 21:00:42 2011 @@ -284,12 +284,28 @@ <value xml:lang="hi_IN">Paypal सॠसà¤à¤à¤¾à¤° मà¥à¤ समसà¥à¤¯à¤¾, à¤à¥à¤ªà¤¯à¤¾ पà¥à¤¨: पà¥à¤°à¤¯à¤¾à¤¸ à¤à¤°à¥à¤ या à¤à¤ ठलठCheckout पदà¥à¤§à¤¤à¤¿ à¤à¤¾ à¤à¤¯à¤¨ à¤à¤°à¥à¤</value> <value xml:lang="it">Si è verificato un problema durante la comunicazione con PayPal, per favore provare di nuovo o selezionare un altro metodo di checkout</value> </property> + <property key="AccountingPayPalErrorDuringRetrievingCartDetails"> + <value xml:lang="en">An error occurred while retreiving cart details</value> + <value xml:lang="it">Un'errore è successo mentre ricavavo i dettagli del carrello</value> + </property> + <property key="AccountingPayPalPaymentGatewayConfigCannotFind"> + <value xml:lang="en">Couldn't retrieve a PaymentGatewayConfigPayPal record for Express Checkout, cannot continue.</value> + <value xml:lang="it">Non è possibile ricavare un record PaymentGatewayConfigPayPal per Express Checkout, non è possibile continuare.</value> + </property> <property key="AccountingPayPalShoppingCartIsEmpty"> <value xml:lang="en">Shopping cart is empty, cannot proceed with Express Checkout</value> <value xml:lang="fr">Votre panier est vide, vous ne pouvez pas effectuer une validation express</value> <value xml:lang="hi_IN">शà¥à¤ªà¤¿à¤à¤ à¤à¤¾à¤°à¥à¤ à¤à¤¾à¤²à¥ हà¥, à¤à¤à¥à¤¸à¤ªà¥à¤°à¥à¤¸ à¤à¥à¤à¤à¤à¤ à¤à¥ साथ à¤à¤à¥ नहà¥à¤ बढ़ सà¤à¤¤à¥</value> <value xml:lang="it">Il carrello è vuoto, non posso procedere con il checkout Express</value> </property> + <property key="AccountingPayPalTokenNotFound"> + <value xml:lang="en">Express Checkout token not present in cart, cannot get checkout details</value> + <value xml:lang="it">Il token per Express Checkout non è presente nel carrello, non è possibile ottenere i dettagli di checkout</value> + </property> + <property key="AccountingPayPalUnknownError"> + <value xml:lang="en">An unknown error occurred while contacting PayPal</value> + <value xml:lang="it">Un'errore sconosciuto è accaduto mentre contattavi PayPal</value> + </property> <property key="AccountingTaxIdInvalidFormat"> <value xml:lang="en">The tax ID ${parameters.partyTaxId} was not in a valid format for the selected tax authority ${taxAuthority.taxIdFormatPattern}</value> <value xml:lang="it">Id tasse ${parameters.partyTaxId} non è nel formato valido per l'autorità tasse selezionata ${taxAuthority.taxIdFormatPattern}</value> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java?rev=1060578&r1=1060577&r2=1060578&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java Tue Jan 18 21:00:42 2011 @@ -83,6 +83,8 @@ import com.paypal.sdk.services.NVPCaller public class PayPalServices { public static final String module = PayPalServices.class.getName(); + public final static String resource = "AccountingErrorUiLabels"; + // Used to maintain a weak reference to the ShoppingCart for customers who have gone to PayPal to checkout // so that we can quickly grab the cart, perform shipment estimates and send the info back to PayPal. // The weak key is a simple wrapper for the checkout token String and is stored as a cart attribute. The value @@ -94,12 +96,14 @@ public class PayPalServices { ShoppingCart cart = (ShoppingCart) context.get("cart"); Locale locale = cart.getLocale(); if (cart == null || cart.items().size() <= 0) { - return ServiceUtil.returnError(UtilProperties.getMessage("AccountingErrorUiLabels", "AccountingPayPalShoppingCartIsEmpty", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalShoppingCartIsEmpty", locale)); } GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null); if (payPalConfig == null) { - return ServiceUtil.returnError("Couldn't retrieve a PaymentGatewayConfigPayPal record for Express Checkout, cannot continue."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalPaymentGatewayConfigCannotFind", locale)); } @@ -136,7 +140,8 @@ public class PayPalServices { addCartDetails(encoder, cart); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError("An error occurred while retreiving cart details"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalErrorDuringRetrievingCartDetails", locale)); } NVPDecoder decoder; @@ -343,13 +348,15 @@ public class PayPalServices { } public static Map<String, Object> getExpressCheckout(DispatchContext dctx, Map<String, Object> context) { + Locale locale = (Locale) context.get("locale"); LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); ShoppingCart cart = (ShoppingCart) context.get("cart"); GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null); if (payPalConfig == null) { - return ServiceUtil.returnError("Couldn't retrieve a PaymentGatewayConfigPayPal record for Express Checkout, cannot continue."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalPaymentGatewayConfigCannotFind", locale)); } NVPEncoder encoder = new NVPEncoder(); @@ -358,7 +365,8 @@ public class PayPalServices { if (UtilValidate.isNotEmpty(token)) { encoder.add("TOKEN", token); } else { - return ServiceUtil.returnError("Express Checkout token not present in cart, cannot get checkout details."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalTokenNotFound", locale)); } NVPDecoder decoder; @@ -665,6 +673,7 @@ public class PayPalServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); OrderReadHelper orh = new OrderReadHelper(delegator, paymentPref.getString("orderId")); + Locale locale = (Locale) context.get("locale"); GenericValue payPalPaymentSetting = getPaymentMethodGatewayPayPal(dctx, context, null); GenericValue payPalPaymentMethod = null; @@ -701,7 +710,8 @@ public class PayPalServices { return ServiceUtil.returnError(e.getMessage()); } if (decoder == null) { - return ServiceUtil.returnError("An error occurred while communicating with PayPal"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalUnknownError", locale)); } Map<String, String> errorMessages = getErrorMessageMap(decoder); @@ -744,6 +754,7 @@ public class PayPalServices { GenericValue payPalPaymentMethod = (GenericValue) context.get("payPalPaymentMethod"); OrderReadHelper orh = new OrderReadHelper(delegator, orderId); GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, PaymentGatewayServices.AUTH_SERVICE_TYPE); + Locale locale = (Locale) context.get("locale"); NVPEncoder encoder = new NVPEncoder(); encoder.add("METHOD", "DoAuthorization"); @@ -765,7 +776,8 @@ public class PayPalServices { } if (decoder == null) { - return ServiceUtil.returnError("An unknown error occurred while contacting PayPal"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalUnknownError", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -796,6 +808,7 @@ public class PayPalServices { BigDecimal captureAmount = (BigDecimal) context.get("captureAmount"); GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, PaymentGatewayServices.AUTH_SERVICE_TYPE); GenericValue authTrans = (GenericValue) context.get("authTrans"); + Locale locale = (Locale) context.get("locale"); if (authTrans == null) { authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref); } @@ -816,7 +829,8 @@ public class PayPalServices { } if (decoder == null) { - return ServiceUtil.returnError("An unknown error occurred while contacting PayPal"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalUnknownError", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -844,8 +858,10 @@ public class PayPalServices { public static Map<String, Object> doVoid(DispatchContext dctx, Map<String, Object> context) { GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null); + Locale locale = (Locale) context.get("locale"); if (payPalConfig == null) { - return ServiceUtil.returnError("Couldn't retrieve a PaymentGatewayConfigPayPal record for Express Checkout, cannot continue."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalPaymentGatewayConfigCannotFind", locale)); } GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue authTrans = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference); @@ -861,7 +877,8 @@ public class PayPalServices { } if (decoder == null) { - return ServiceUtil.returnError("An unknown error occurred while contacting PayPal"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalUnknownError", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -889,9 +906,11 @@ public class PayPalServices { } public static Map<String, Object> doRefund (DispatchContext dctx, Map<String, Object> context) { + Locale locale = (Locale) context.get("locale"); GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, null); if (payPalConfig == null) { - return ServiceUtil.returnError("Couldn't retrieve a PaymentGatewayConfigPayPal record for Express Checkout, cannot continue."); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalPaymentGatewayConfigCannotFind", locale)); } GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue captureTrans = PaymentGatewayServices.getCaptureTransaction(orderPaymentPreference); @@ -912,7 +931,8 @@ public class PayPalServices { } if (decoder == null) { - return ServiceUtil.returnError("An unknown error occurred while contacting PayPal"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "AccountingPayPalUnknownError", locale)); } Map<String, Object> result = ServiceUtil.returnSuccess(); @@ -1035,6 +1055,7 @@ public class PayPalServices { return null; } + @SuppressWarnings("serial") public static class TokenWrapper implements Serializable { String theString; public TokenWrapper(String theString) { |
Free forum by Nabble | Edit this page |