# HG changeset patch # User Jaroslav Tulach # Date 1261597519 -3600 # Node ID 3de0568f7ee8678c2b93fcd74934a180a7fa55a1 # Parent 524c7f359c4e483f427e5a9ee973906d69d25d75 Older dates are displayed as absolute, not relative diff -r 524c7f359c4e -r 3de0568f7ee8 freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Wed Dec 23 07:59:16 2009 +0100 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Wed Dec 23 20:45:19 2009 +0100 @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -407,10 +408,12 @@ private Viewable viewable(String page, Document doc, Object... more) { ResourceBundle rb = null; String lng = user == null ? null : user.getProperty("language"); // NOI18N + Locale locale = null; if (lng != null) { try { Locale l = new Locale(lng); rb = ResourceBundle.getBundle("cz.xelfi.quoridor.freemarkerdor.UI.Bundle", l); + locale = l; } catch (MissingResourceException e) { // OK } @@ -419,6 +422,8 @@ for (Locale l : headers.getAcceptableLanguages()) { try { rb = ResourceBundle.getBundle("cz.xelfi.quoridor.freemarkerdor.UI.Bundle", l); + locale = l; + break; } catch (MissingResourceException e) { // OK } @@ -426,15 +431,26 @@ } if (rb == null) { rb = ResourceBundle.getBundle("cz.xelfi.quoridor.freemarkerdor.UI.Bundle", Locale.ENGLISH); + locale = Locale.ENGLISH; } Map map = new HashMap(); + class ConvertToDate extends HashMap { + @Override + public Object get(Object o) { + long time = Long.parseLong(o.toString()); + return new Date(time); + } + } + + map.put("locale", locale.toString()); map.put("doc", doc); if (user != null) { map.put("user", user.getId()); map.put("email", user.getProperty("email")); } map.put("bundle", rb); + map.put("toDate", new ConvertToDate()); map.put("now", System.currentTimeMillis()); map.put("version", version); for (int i = 0; i < more.length; i += 2) { diff -r 524c7f359c4e -r 3de0568f7ee8 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle.properties --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle.properties Wed Dec 23 07:59:16 2009 +0100 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle.properties Wed Dec 23 20:45:19 2009 +0100 @@ -8,14 +8,15 @@ gameWhiteBlack={0} vs. {1} LastMove=Last move {1,choice,\ 0#second|\ - 2#{1} seconds|\ - 60#a minute|\ - 120#{2} minutes|\ - 3600#an hour|\ - 7200#{3} hours|\ - 86400#a day|\ - 172800#{4} days\ -} ago + 2#{1} seconds ago|\ + 60#a minute ago|\ + 120#{2} minutes ago|\ + 3600#an hour ago|\ + 7200#{3} hours ago|\ + 86400#a day ago|\ + 172800#{4} days ago|\ + 1000000#on {5}\ +} GAME_MOVE=Your move GAME_WAIT=Opponent's move GAME_WON=Won games ({0}) diff -r 524c7f359c4e -r 3de0568f7ee8 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle_cs.properties --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle_cs.properties Wed Dec 23 07:59:16 2009 +0100 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/Bundle_cs.properties Wed Dec 23 20:45:19 2009 +0100 @@ -14,24 +14,25 @@ GAME_ALL=V\u0161echny hry WHITE=B\u00EDl\u00FD BLACK=\u010Cern\u00FD -LastMove=T\u00E1hnuto p\u0159ed {1,choice,\ - 0#chv\u00EDl\u00ED|\ - 10#{1}-ti sekundami|\ - 60#minutou|\ - 120#dv\u011Bma minutami|\ - 180#t\u0159emi minutami|\ - 240#\u010Dty\u0159mi minutami|\ - 300#{2}-ti minutami|\ - 3600#hodinou|\ - 7200#dv\u011Bma hodinami|\ - 10800#t\u0159emi hodinami|\ - 14400#\u010Dty\u0159mi hodinami|\ - 18000#{3}-ti hodinami|\ - 86400#jedn\u00EDm dnem|\ - 172800#dv\u011Bma dny|\ - 259200#t\u0159emi dny|\ - 345600#\u010Dty\u0159mi dny|\ - 432000#{4}-ti dny\ +LastMove={1,choice,\ + 0#T\u00E1hnuto p\u0159ed chv\u00EDl\u00ED|\ + 10#T\u00E1hnuto p\u0159ed {1}-ti sekundami|\ + 60#T\u00E1hnuto p\u0159ed minutou|\ + 120#T\u00E1hnuto p\u0159ed dv\u011Bma minutami|\ + 180#T\u00E1hnuto p\u0159ed t\u0159emi minutami|\ + 240#T\u00E1hnuto p\u0159ed \u010Dty\u0159mi minutami|\ + 300#T\u00E1hnuto p\u0159ed {2}-ti minutami|\ + 3600#T\u00E1hnuto p\u0159ed hodinou|\ + 7200#T\u00E1hnuto p\u0159ed dv\u011Bma hodinami|\ + 10800#T\u00E1hnuto p\u0159ed t\u0159emi hodinami|\ + 14400#T\u00E1hnuto p\u0159ed \u010Dty\u0159mi hodinami|\ + 18000#T\u00E1hnuto p\u0159ed {3}-ti hodinami|\ + 86400#T\u00E1hnuto p\u0159ed jedn\u00EDm dnem|\ + 172800#T\u00E1hnuto p\u0159ed dv\u011Bma dny|\ + 259200#T\u00E1hnuto p\u0159ed t\u0159emi dny|\ + 345600#T\u00E1hnuto p\u0159ed \u010Dty\u0159mi dny|\ + 432000#T\u00E1hnuto p\u0159ed {4}-ti dny|\ + 1000000#{5} je den posledn\u00EDho tahu\ } NEXT=Dal\u0161\u00ED diff -r 524c7f359c4e -r 3de0568f7ee8 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Wed Dec 23 07:59:16 2009 +0100 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Wed Dec 23 20:45:19 2009 +0100 @@ -1,5 +1,6 @@ + <#setting locale = locale/> <#assign toMove = 0/> <#assign toWait = 0/> <#assign toWon = 0/> @@ -43,18 +44,20 @@

${bundle.TITLE}

- <#macro before t> + <#macro before t w> <#assign seconds = (t / 1000)?long/> <#assign minutes= (seconds / 60)?long/> <#assign hours= (minutes / 60)?long/> <#assign days= (hours / 24)?long/> - ${bundle("LastMove", t?int, seconds?int, minutes?int, hours?int, days?int)} + ${bundle("LastMove", t?int, seconds?int, minutes?int, hours?int, days?int, w?date?string.long)} <#macro game game> - ${bundle("gameWhiteBlack", game.@white?string, game.@black?string)} - <@before (now - game.@modified?number)?long/> + ${bundle("gameWhiteBlack", game.@white?string, game.@black?string)} + <#assign sinceNow= now - game.@modified?number/> + <#assign when=toDate[game.@modified?string]/> + <@before t=sinceNow w=when/> <#if game.@comments?number != 0> ${bundle("comments", game.@comments?number)}