Author: jleroux
Date: Fri Oct 14 08:53:28 2011 New Revision: 1183244 URL: http://svn.apache.org/viewvc?rev=1183244&view=rev Log: Fix a bug from an incomplete backport, reported by Scott on dev ML Modified: ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFileMappingCreator.java ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFilesMapping.java Modified: ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFileMappingCreator.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFileMappingCreator.java?rev=1183244&r1=1183243&r2=1183244&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFileMappingCreator.java (original) +++ ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFileMappingCreator.java Fri Oct 14 08:53:28 2011 @@ -1,10 +1,8 @@ package org.ofbiz.common; import java.io.File; -import java.io.IOException; import java.io.StringWriter; import java.io.Writer; -import java.net.MalformedURLException; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -22,26 +20,30 @@ import org.ofbiz.service.ServiceUtil; // Use the createJsLanguageFileMapping service to create or update the JsLanguageFilesMapping.java. You will still need to compile thereafter -import freemarker.template.TemplateException; - public class JsLanguageFileMappingCreator { private static final String module = JsLanguageFileMappingCreator.class.getName(); public static Map<String, Object> createJsLanguageFileMapping(DispatchContext ctx, Map<String, ?> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); + String encoding = (String) context.get("encoding"); // default value: UTF-8 + List<Locale> localeList = UtilMisc.availableLocales(); Map<String, Object> jQueryLocaleFile = FastMap.newInstance(); Map<String, String> dateJsLocaleFile = FastMap.newInstance(); + Map<String, String> validationLocaleFile = FastMap.newInstance(); Map<String, String> dateTimePickerLocaleFile = FastMap.newInstance(); // setup some variables to locate the js files String componentRoot = "component://images/webapp"; String jqueryUiLocaleRelPath = "/images/jquery/ui/development-bundle/ui/i18n/"; String dateJsLocaleRelPath = "/images/jquery/plugins/datejs/"; + String validateRelPath = "/images/jquery/plugins/validate/localization/"; String dateTimePickerJsLocaleRelPath = "/images/jquery/plugins/datetimepicker/localization/"; String jsFilePostFix = ".js"; String dateJsLocalePrefix = "date-"; + String validateLocalePrefix = "messages_"; + //String validateMethLocalePrefix = "methods__"; String jqueryUiLocalePrefix = "jquery.ui.datepicker-"; String dateTimePickerPrefix = "jquery-ui-timepicker-"; String defaultLocaleDateJs = "en-US"; @@ -155,6 +157,7 @@ public class JsLanguageFileMappingCreato Map<String, Object> mapWrapper = new HashMap<String, Object>(); mapWrapper.put("datejs", dateJsLocaleFile); mapWrapper.put("jquery", jQueryLocaleFile); + mapWrapper.put("validation", validationLocaleFile); mapWrapper.put("dateTime", dateTimePickerLocaleFile); // some magic to create a new java file @@ -162,32 +165,13 @@ public class JsLanguageFileMappingCreato Writer writer = new StringWriter(); try { FreeMarkerWorker.renderTemplateAtLocation(template, mapWrapper, writer); + // write it as a Java file + File file = new File(output); + FileUtils.writeStringToFile(file, writer.toString(), encoding); } - catch (MalformedURLException e) { - Debug.logError(e, module); - return result = ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); - } - catch (TemplateException e) { - Debug.logError(e, module); - return result = ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); - } - catch (IOException e) { - Debug.logError(e, module); - return result = ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); - } - catch (IllegalArgumentException e) { - Debug.logError(e, module); - return result = ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); - } - - // write it as a Java file - File file = new File(output); - try { - FileUtils.writeStringToFile(file, writer.toString(), "UTF-8"); - } - catch (IOException e) { + catch (Exception e) { Debug.logError(e, module); - return result = ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); + return ServiceUtil.returnError("The Outputfile could not be created: " + e.getMessage()); } return result; Modified: ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFilesMapping.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFilesMapping.java?rev=1183244&r1=1183243&r2=1183244&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFilesMapping.java (original) +++ ofbiz/branches/release11.04/framework/common/src/org/ofbiz/common/JsLanguageFilesMapping.java Fri Oct 14 08:53:28 2011 @@ -515,15 +515,15 @@ public final class JsLanguageFilesMappin localeFiles.put("es_VE", "/images/jquery/plugins/validate/localization/messages_es.js"); localeFiles.put("sv", "/images/jquery/plugins/validate/localization/messages_en.js"); localeFiles.put("sv_SE", "/images/jquery/plugins/validate/localization/messages_en.js"); - localeFiles.put("th", "/images/jquery/plugins/validate/localization/messages_th.js"); - localeFiles.put("th_TH", "/images/jquery/plugins/validate/localization/messages_th.js"); - localeFiles.put("th_TH_TH", "/images/jquery/plugins/validate/localization/messages_th.js"); + localeFiles.put("th", "/images/jquery/plugins/validate/localization/messages_en.js"); + localeFiles.put("th_TH", "/images/jquery/plugins/validate/localization/messages_en.js"); + localeFiles.put("th_TH_TH", "/images/jquery/plugins/validate/localization/messages_en.js"); localeFiles.put("tr", "/images/jquery/plugins/validate/localization/messages_tr.js"); localeFiles.put("tr_TR", "/images/jquery/plugins/validate/localization/messages_tr.js"); localeFiles.put("uk", "/images/jquery/plugins/validate/localization/messages_en.js"); localeFiles.put("uk_UA", "/images/jquery/plugins/validate/localization/messages_en.js"); - localeFiles.put("vi", "/images/jquery/plugins/validate/localization/messages_vi.js"); - localeFiles.put("vi_VN", "/images/jquery/plugins/validate/localization/messages_vi.js"); + localeFiles.put("vi", "/images/jquery/plugins/validate/localization/messages_en.js"); + localeFiles.put("vi_VN", "/images/jquery/plugins/validate/localization/messages_en.js"); } public static String getFilePath(String locale) { |
Free forum by Nabble | Edit this page |