Fix several I18n isssues.

This commit is contained in:
Paulo Gustavo Veiga 2012-07-06 00:46:54 -03:00
parent aedab95b4a
commit b816d12842
15 changed files with 111 additions and 173 deletions

View File

@ -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;

View File

@ -17,6 +17,16 @@
*/
mindplot.PersistenceManager = new Class({
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 () {
},
@ -44,7 +54,7 @@ mindplot.PersistenceManager = new Class({
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) {
@ -57,18 +67,6 @@ mindplot.PersistenceManager = new Class({
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) {
throw "Method must be implemented";
}
});

View File

@ -1,118 +0,0 @@
TestCase("Model Migration Tests", {
setUp:function() {
mapXml = '<map name="1"><topic central="true" text="test"><topic position="-127,-100" fontStyle="Verdana;;#038f39;;italic;" brColor="#db770b"><topic order="0"/><topic order="1"/><topic order="2"><topic order="0"/><topic order="1"/><topic order="2"/></topic></topic><topic position="-168,50" shape="line"><icon id="conn_disconnect"/><icon id="chart_curve"/></topic><topic position="166,-100" shape="elipse"><note text="this%20is%20a%20note"/><topic order="0"/><topic order="1"/><topic order="2"/></topic><topic position="173,0" shape="rectagle" bgColor="#f2a2b5"><link url="www.google.com"/></topic></topic><topic position="-391,-2" text="im alone"/></map>';
},
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());
}
}
});

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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

View File

@ -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 {

View File

@ -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: ""
};

View File

@ -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: ""
};

View File

@ -28,7 +28,7 @@
<label for="lastname"><strong><spring:message code="LASTNAME"/>:</strong></label>
<input type="text" name="lastname" id="lastname" required="required" value="${user.lastname}"/>
<br/>
<input type="submit" id="changeUserInfoBtn" class="btn btn-primary" value="Save"/>
<input type="submit" id="changeUserInfoBtn" class="btn btn-primary" value="<spring:message code="SAVE_CHANGES"/>"/>
</fieldset>
</form>
@ -60,10 +60,10 @@
<option value="es" <c:if test="${user.locale=='es'}">selected="selected" </c:if>>Spanish -
español
</option>
<option value="zh_cn" <c:if test="${user.locale=='es'}">selected="selected" </c:if>>Chinese
<option value="zh_cn" <c:if test="${user.locale=='zh_cn'}">selected="selected" </c:if>>Chinese
(Simplified Han) - 中文(简体中文)
</option>
<option value="zh-tw" <c:if test="${user.locale=='es'}">selected="selected" </c:if>>Chinese
<option value="zh_tw" <c:if test="${user.locale=='zh_tw'}">selected="selected" </c:if>>Chinese
(Traditional Han) - 中文 (繁體中文)
</option>
</select>

View File

@ -2,11 +2,33 @@
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<div id="footer">
<div style="width:30%; float:left;">&nbsp;</div>
<div style="width:30%; float:left;">&nbsp;
<a href="https://twitter.com/share" class="twitter-share-button" data-via="wisemapping" data-related="wisemapping">Tweet</a>
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");</script>
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{parsetags: 'explicit'}
</script>
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
<!-- Place this render call where appropriate -->
<script type="text/javascript">gapi.plusone.go();</script>
</div>
<div style="float:left; width:40%;">
<p><a href="http://www.wisemapping.org"><spring:message code="COPYRIGHT"/></a></p>
</div>
<div style="float:left; text-align:left;padding:5px;">
<div style="float:left; text-align:left;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" name="submit"

View File

@ -49,8 +49,7 @@
var parser = new DOMParser();
var domDocument = parser.parseFromString(mapXml, "text/xml");
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap = persistence.loadFromDom(mapId, domDocument);
var mindmap = mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
designer.loadMap(mindmap);
});
</script>

View File

@ -33,8 +33,9 @@
// Configure designer options ...
var options = loadDesignerOptions();
options.size.height = options.size.height + 50;
options.locale = '${locale}';
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/");
var userOptions = ${mindmap.properties};
options.zoom = ${zoom};
@ -51,8 +52,7 @@
var parser = new DOMParser();
var domDocument = parser.parseFromString(mapXml, "text/xml");
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap = persistence.loadFromDom(mapId, domDocument);
var mindmap = mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
designer.loadMap(mindmap);
$('zoomIn').addEvent('click', function () {

View File

@ -47,9 +47,6 @@
bottom: -30px;
}
div#infoPanel {
display: none;
}
</style>
<script type='text/javascript' src='js/mootools-core.js'></script>
@ -64,13 +61,14 @@
<script type="text/javascript">
var mapId = '${mindmap.id}';
var mapXml = '${mindmap.xmlAsJsLiteral}';
$(document).addEvent('loadcomplete', function (resource) {
// Configure designer options ...
var options = loadDesignerOptions();
options.locale = '${locale}';
options.size.height = options.size.height + 50;
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/");
var userOptions = ${mindmap.properties};
options.zoom = userOptions.zoom;
@ -87,8 +85,7 @@
var parser = new DOMParser();
var domDocument = parser.parseFromString(mapXml, "text/xml");
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap = persistence.loadFromDom(mapId, domDocument);
var mindmap = mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
designer.loadMap(mindmap);
$('zoomIn').addEvent('click', function () {
@ -104,9 +101,6 @@
<body>
<div id="mapContainer">
<%--<div id="infoPanel">--%>
<%--<div id="dragImageNode" style="cursor: move">--%>
<%--</div>--%>
<div id="mindplot"></div>
<div id="printLogo"></div>