From b816d128428646313e7ffe48c2a38831fe840f2e Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 6 Jul 2012 00:46:54 -0300 Subject: [PATCH] Fix several I18n isssues. --- mindplot/src/main/javascript/Messages.js | 8 +- .../src/main/javascript/PersistenceManager.js | 42 +++---- .../src/test/javascript/ModelMigrationTest.js | 118 ------------------ .../filter/UserLocaleInterceptor.java | 2 +- .../ncontroller/MindmapController.java | 8 +- .../wisemapping/rest/AccountController.java | 2 - .../WEB-INF/classes/messages_en.properties | 4 +- .../src/main/webapp/css/pageHeaders.css | 1 + .../main/webapp/js/jquery.timeago.zh_cn.js | 20 +++ .../main/webapp/js/jquery.timeago.zh_tw.js | 20 +++ .../src/main/webapp/jsp/accountSettings.jsp | 6 +- wise-webapp/src/main/webapp/jsp/footer.jsp | 26 +++- .../src/main/webapp/jsp/mindmapEditor.jsp | 3 +- .../src/main/webapp/jsp/mindmapEmbed.jsp | 6 +- .../src/main/webapp/jsp/mindmapPrint.jsp | 18 +-- 15 files changed, 111 insertions(+), 173 deletions(-) delete mode 100644 mindplot/src/test/javascript/ModelMigrationTest.js create mode 100644 wise-webapp/src/main/webapp/js/jquery.timeago.zh_cn.js create mode 100644 wise-webapp/src/main/webapp/js/jquery.timeago.zh_tw.js diff --git a/mindplot/src/main/javascript/Messages.js b/mindplot/src/main/javascript/Messages.js index 065a19ce..88769fb1 100644 --- a/mindplot/src/main/javascript/Messages.js +++ b/mindplot/src/main/javascript/Messages.js @@ -134,7 +134,7 @@ mindplot.Messages.BUNDLES = { ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE:'Tópicos hijos no pueden ser colapsados. Solo un topic debe ser seleccionado.', SHORTCUTS:'Accesos directos' }, - zh_CN:{ + zh_cn:{ ZOOM_IN:'放大', ZOOM_OUT:'缩小', TOPIC_SHAPE:'节点外形', @@ -179,7 +179,7 @@ mindplot.Messages.BUNDLES = { CENTRAL_TOPIC:'中心节点', SHORTCUTS:'快捷键' }, - zh_TW:{ + zh_tw:{ ZOOM_IN:'放大', ZOOM_OUT:'縮小', TOPIC_SHAPE:'節點外形', @@ -223,7 +223,7 @@ mindplot.Messages.BUNDLES = { ISOLATED_TOPIC:'獨立節點', CENTRAL_TOPIC:'中心節點', SHORTCUTS:'快捷鍵' - }, - zh:mindplot.Messages.BUNDLES.zh_TW + } }; +mindplot.Messages.BUNDLES['zh'] = mindplot.Messages.zh_tw; diff --git a/mindplot/src/main/javascript/PersistenceManager.js b/mindplot/src/main/javascript/PersistenceManager.js index 6c0b7007..d7d11948 100644 --- a/mindplot/src/main/javascript/PersistenceManager.js +++ b/mindplot/src/main/javascript/PersistenceManager.js @@ -17,11 +17,21 @@ */ mindplot.PersistenceManager = new Class({ - initialize: function() { + Static:{ + loadFromDom:function (mapId, mapDom) { + $assert(mapId, "mapId can not be null"); + $assert(mapDom, "mapDom can not be null"); + + var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(mapDom); + return serializer.loadFromDom(mapDom, mapId); + } + }, + + initialize:function () { }, - save: function(mindmap, editorProperties, saveHistory, events) { + save:function (mindmap, editorProperties, saveHistory, events) { $assert(mindmap, "mindmap can not be null"); $assert(editorProperties, "editorProperties can not be null"); @@ -35,48 +45,36 @@ mindplot.PersistenceManager = new Class({ var pref = JSON.encode(editorProperties); try { this.saveMapXml(mapId, mapXml, pref, saveHistory, events); - } catch(e) { + } catch (e) { console.log(e); events.onError(); } }, - load: function(mapId) { + load:function (mapId) { $assert(mapId, "mapId can not be null"); var domDocument = this.loadMapDom(mapId); - return this.loadFromDom(mapId, domDocument); + return mindplot.PersistenceManager.loadFromDom(mapId, domDocument); }, - discardChanges: function(mapId) { + discardChanges:function (mapId) { throw "Method must be implemented"; }, - loadMapDom: function(mapId) { + loadMapDom:function (mapId) { throw "Method must be implemented"; }, - saveMapXml : function(mapId, mapXml, pref, saveHistory, events) { - throw "Method must be implemented"; - }, - - loadFromDom : function(mapId, mapDom) { - $assert(mapId, "mapId can not be null"); - $assert(mapDom, "mapDom can not be null"); - - var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(mapDom); - return serializer.loadFromDom(mapDom, mapId); - }, - - logEntry: function(severity, message) { + saveMapXml:function (mapId, mapXml, pref, saveHistory, events) { throw "Method must be implemented"; } }); -mindplot.PersistenceManager.init = function(instance) { +mindplot.PersistenceManager.init = function (instance) { mindplot.PersistenceManager._instance = instance; }; -mindplot.PersistenceManager.getInstance = function() { +mindplot.PersistenceManager.getInstance = function () { return mindplot.PersistenceManager._instance; }; diff --git a/mindplot/src/test/javascript/ModelMigrationTest.js b/mindplot/src/test/javascript/ModelMigrationTest.js deleted file mode 100644 index 67df836e..00000000 --- a/mindplot/src/test/javascript/ModelMigrationTest.js +++ /dev/null @@ -1,118 +0,0 @@ -TestCase("Model Migration Tests", { - setUp:function() { - mapXml = ''; - }, - testModelMigration:function() { - ids = []; - var parser = new DOMParser(); - var domDocument = parser.parseFromString(xml, "text/xml"); - - var betaSerializer = new mindplot.persistence.XMLSerializer_Beta(); - var betaMap = betaSerializer.loadFromDom(domDocument); - - var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(domDocument); - var mindmap = serializer.loadFromDom(domDocument); - - //Assert that the new model is Pela - assertEquals(mindplot.persistence.ModelCodeName.PELA, mindmap.getVersion()); - - //Assert same number of branches - var betaBranches = betaMap.getBranches(); - var branches = mindmap.getBranches(); - assertEquals(betaBranches.length, branches.length); - - //Assert same nodes recursively - //Since Id can change let's assume the order is the same - for (var i = 0; i < betaBranches.length; i++) { - var branch = betaBranches[i]; - this._findAndCompareNodes(branch, branches[i]); - - } - - }, - _findAndCompareNodes:function(betaNode, node) { - this._compareNodes(betaNode, node); - //Assert same nodes recursively - //Since Id can change let's assume the order is the same - for (var i = 0; i < betaNode.getChildren().length; i++) { - var betaChild = betaNode.getChildren()[i]; - var child = node.getChildren()[i]; - this._findAndCompareNodes(betaChild, child); - - } - }, - _compareNodes:function(node1, node2) { - assertNotNull(node1); - assertNotNull(node2); - - //In Pela Version every id is different - var pelaId = node2.getId(); - assertTrue(ids[pelaId] == undefined); - ids.push(pelaId); - - var children1 = node1.getChildren(); - var children2 = node2.getChildren(); - assertEquals(children1.length, children2.length); - - var position1 = node1.getPosition(); - var position2 = node2.getPosition(); - if (position1 == null) { - assertNull(position2); - } else { - assertEquals(position1.x, position2.x); - assertEquals(position1.y, position2.y); - } - assertEquals(node1.areChildrenShrunken(), node2.areChildrenShrunken()); - assertEquals(node1.getType(), node2.getType()); - assertEquals(node1.getText(), node2.getText()); - assertEquals(node1.isConnected(), node2.isConnected()); - assertEquals(node1.getSize().width, node2.getSize().width); - assertEquals(node1.getSize().height, node2.getSize().height); - this._compareIcons(node1.getIcons(), node2.getIcons()); - this._compareLinks(node1.getLinks(), node2.getLinks()); - this._compareNotes(node1.getNotes(), node2.getNotes()); - - var order1 = node1.getOrder(); - var order2 = node2.getOrder(); - if (order1 == null) { - assertNull(order2); - } else { - assertEquals(order1, order2); - } - assertEquals(node1.getShapeType(), node2.getShapeType()); - assertEquals(node1.getFontFamily(), node2.getFontFamily()); - assertEquals(node1.getFontStyle(), node2.getFontStyle()); - assertEquals(node1.getFontWeight(), node2.getFontWeight()); - assertEquals(node1.getFontSize(), node2.getFontSize()); - assertEquals(node1.getBorderColor(), node2.getBorderColor()); - assertEquals(node1.getBackgroundColor(), node2.getBackgroundColor()); - }, - _compareLinks:function(links1, links2) { - assertEquals(links1.length, links2.length); - for (var i = 0; i < links1.length; i++) { - var link1 = links1[i]; - var link2 = links2[i]; - assertEquals(link1.getUrl(), link2.getUrl()); - - } - }, - _compareIcons:function(icons1, icons2) { - assertEquals(icons1.length, icons2.length); - for (var i = 0; i < icons1.length; i++) { - var icon1 = icons1[i]; - var icon2 = icons2[i]; - assertEquals(icon1.getIconType(), icon2.getIconType()); - - } - }, - _compareNotes:function(notes1, notes2) { - assertEquals(notes1.length, notes2.length); - for (var i = 0; i < notes1.length; i++) { - var note1 = notes1[i]; - var note2 = notes2[i]; - assertEquals(note1.getText(), note2.getText()); - - } - } - -}); \ No newline at end of file diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java index cad3f7ef..5e7019cd 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java @@ -44,7 +44,7 @@ public class UserLocaleInterceptor extends HandlerInterceptorAdapter { if (user != null && session != null) { String userLocale = user.getLocale(); final Locale sessionLocale = (Locale) session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME); - if ((userLocale != null) && ((sessionLocale == null) || (!userLocale.equals(sessionLocale.getISO3Language())))) { + if ((userLocale != null) && ((sessionLocale == null) || (!userLocale.equals(sessionLocale.toString())))) { session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale(userLocale)); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index ab84c9c8..b94f31e4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -70,6 +70,8 @@ public class MindmapController { final MindMapBean mindmap = findMindmapBean(id); model.addAttribute("principal", Utils.getUser()); model.addAttribute("mindmap", mindmap); + final Locale locale = LocaleContextHolder.getLocale(); + model.addAttribute("locale", locale.toString().toLowerCase()); return "mindmapPrint"; } @@ -128,7 +130,7 @@ public class MindmapController { @RequestMapping(value = "maps/") public String showListPage(@NotNull Model model) { final Locale locale = LocaleContextHolder.getLocale(); - model.addAttribute("locale", locale.getISO3Language()); + model.addAttribute("locale", locale.toString().toLowerCase()); return "mindmapList"; } @@ -143,7 +145,7 @@ public class MindmapController { // Configure default locale for the editor ... final Locale locale = LocaleContextHolder.getLocale(); - model.addAttribute("locale", locale.getISO3Language()); + model.addAttribute("locale", locale.toString().toLowerCase()); model.addAttribute("principal", Utils.getUser()); result = "mindmapEditor"; } else { @@ -178,6 +180,8 @@ public class MindmapController { final MindMapBean mindmap = findMindmapBean(id); view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap); view.addObject("zoom", zoom == null ? 1 : zoom); + final Locale locale = LocaleContextHolder.getLocale(); + view.addObject("locale", locale.toString().toLowerCase()); return view; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java index c6de33e3..1784f3e4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java @@ -86,8 +86,6 @@ public class AccountController extends BaseController { if (language == null) { throw new IllegalArgumentException("language can not be null"); - } if (!language.equals("en") && !language.equals("es") ){ - throw new IllegalArgumentException("language not supported yet"); } final User user = Utils.getUser(); diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties index 452bae74..458bfbf1 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_en.properties @@ -1,4 +1,4 @@ -# First line error ... +# Default English Support. NAME=Name DESCRIPTION=Description @@ -200,7 +200,7 @@ UNDO_EDITION=Undo Edition REDO_EDITION=Redo Edition SELECT_ALL_TOPIC=Select All Topic CHANGE_TEXT_BOLD=Change Text Bold Type -SAVE_CHANGES=Save Chages +SAVE_CHANGES=Save Changes CHANGE_TEXT_ITALIC=Change Text Italic DESELECT_ALL_TOPIC=Deselect All Topic SHORTCUTS=Shortcuts diff --git a/wise-webapp/src/main/webapp/css/pageHeaders.css b/wise-webapp/src/main/webapp/css/pageHeaders.css index f3676582..ae63de57 100644 --- a/wise-webapp/src/main/webapp/css/pageHeaders.css +++ b/wise-webapp/src/main/webapp/css/pageHeaders.css @@ -108,6 +108,7 @@ div#headerButtons activelink a, div#headerButtons activelink a:hover { font-size: 90%; background-color: white; float: left; + padding-top:5px; } div#paypal { diff --git a/wise-webapp/src/main/webapp/js/jquery.timeago.zh_cn.js b/wise-webapp/src/main/webapp/js/jquery.timeago.zh_cn.js new file mode 100644 index 00000000..f39417ef --- /dev/null +++ b/wise-webapp/src/main/webapp/js/jquery.timeago.zh_cn.js @@ -0,0 +1,20 @@ +// Simplified Chinese +jQuery.timeago.settings.strings = { + prefixAgo: null, + prefixFromNow: "从现在开始", + suffixAgo: "之前", + suffixFromNow: null, + seconds: "不到 1 分钟", + minute: "大约 1 分钟", + minutes: "%d 分钟", + hour: "大约 1 小时", + hours: "大约 %d 小时", + day: "1 天", + days: "%d 天", + month: "大约 1 个月", + months: "%d 月", + year: "大约 1 年", + years: "%d 年", + numbers: [], + wordSeparator: "" +}; \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/js/jquery.timeago.zh_tw.js b/wise-webapp/src/main/webapp/js/jquery.timeago.zh_tw.js new file mode 100644 index 00000000..36cf7803 --- /dev/null +++ b/wise-webapp/src/main/webapp/js/jquery.timeago.zh_tw.js @@ -0,0 +1,20 @@ +// Traditional Chinese, zh-tw +jQuery.timeago.settings.strings = { + prefixAgo: null, + prefixFromNow: "從現在開始", + suffixAgo: "之前", + suffixFromNow: null, + seconds: "不到 1 分鐘", + minute: "大約 1 分鐘", + minutes: "%d 分鐘", + hour: "大約 1 小時", + hours: "大約 %d 小時", + day: "1 天", + days: "%d 天", + month: "大約 1 個月", + months: "%d 月", + year: "大約 1 年", + years: "%d 年", + numbers: [], + wordSeparator: "" +}; \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/jsp/accountSettings.jsp b/wise-webapp/src/main/webapp/jsp/accountSettings.jsp index af5362d3..aac8a9db 100755 --- a/wise-webapp/src/main/webapp/jsp/accountSettings.jsp +++ b/wise-webapp/src/main/webapp/jsp/accountSettings.jsp @@ -28,7 +28,7 @@
- + "/> @@ -60,10 +60,10 @@ - - diff --git a/wise-webapp/src/main/webapp/jsp/footer.jsp b/wise-webapp/src/main/webapp/jsp/footer.jsp index 65cb4037..b6db880b 100644 --- a/wise-webapp/src/main/webapp/jsp/footer.jsp +++ b/wise-webapp/src/main/webapp/jsp/footer.jsp @@ -2,11 +2,33 @@ <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>