# HG changeset patch
# User Jaroslav Tulach
# Date 1252098143 -7200
# Node ID fd7e8e705b753fc1b213090aad70a77c9066b533
# Parent e00be634746c726c02e732c95598f87ef53625d8
Localization of the game
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java
--- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Fri Sep 04 22:00:04 2009 +0200
+++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Fri Sep 04 23:02:23 2009 +0200
@@ -40,8 +40,11 @@
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
import java.util.Properties;
+import java.util.ResourceBundle;
import java.util.concurrent.Callable;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
@@ -225,9 +228,24 @@
}
private Viewable viewable(String page, Document doc, Object... more) {
+ String bundle = page.split("\\.")[0];
+
+ ResourceBundle rb = null;
+ for (Locale l : headers.getAcceptableLanguages()) {
+ try {
+ rb = ResourceBundle.getBundle("cz.xelfi.quoridor.freemarkerdor.UI." + bundle, l);
+ } catch (MissingResourceException e) {
+ // OK
+ }
+ }
+ if (rb == null) {
+ rb = ResourceBundle.getBundle("cz.xelfi.quoridor.freemarkerdor.UI." + bundle, Locale.ENGLISH);
+ }
+
Map map = new HashMap();
map.put("doc", doc);
map.put("user", user);
+ map.put("bundle", rb);
for (int i = 0; i < more.length; i += 2) {
map.put((String)more[i],more[i + 1]);
}
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt
--- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Fri Sep 04 22:00:04 2009 +0200
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Fri Sep 04 23:02:23 2009 +0200
@@ -5,11 +5,11 @@
- Game
- ${doc.game.id.@white} vs. ${doc.game.id.@black}
+ ${bundle.GAME}
+ ${doc.game.id.@white}${bundle.VS}${doc.game.id.@black}
- Reload
+ ${bundle.RELOAD}
<#if message?? >
@@ -42,10 +42,10 @@
-
+
#if>
${doc.game.board}
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.properties Fri Sep 04 23:02:23 2009 +0200
@@ -0,0 +1,7 @@
+VS= vs.
+PLACE=Place!
+MOVE=Move!
+H=Horizontal
+V=Vertical
+RELOAD=Reload
+GAME=Game
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game_cs.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game_cs.properties Fri Sep 04 23:02:23 2009 +0200
@@ -0,0 +1,7 @@
+VS=/
+PLACE=Um\u00EDstit
+MOVE=T\u00E1hnout
+H=Horizont\u00E1ln\u011B
+V=Vertik\u00E1ln\u011B
+RELOAD=Obnovit
+GAME=Hra
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt
--- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Fri Sep 04 22:00:04 2009 +0200
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Fri Sep 04 23:02:23 2009 +0200
@@ -5,10 +5,10 @@
- Quoridor Community Server
+ ${bundle.TITLE}
<#macro game game>
- ${game.@white} vs. ${game.@black} board
+ ${game.@white}${bundle.VS}${game.@black} board
#macro>
<#if message?? >
@@ -17,7 +17,7 @@
#if>
- Games where you are expected to move
+ ${bundle.GAME_MOVE}
<#list doc.gameIds.* as g>
@@ -29,7 +29,7 @@
#list>
- Won games
+ ${bundle.GAME_WON}
<#list doc.gameIds.* as g>
@@ -44,7 +44,7 @@
#list>
- Lost games
+ ${bundle.GAME_LOST}
<#list doc.gameIds.* as g>
@@ -60,12 +60,12 @@
- All Games
+ ${bundle.GAME_ALL}
<#list doc.gameIds.* as g>
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.properties Fri Sep 04 23:02:23 2009 +0200
@@ -0,0 +1,10 @@
+TITLE=Quoridor Community Server
+VS= vs.
+GAME_MOVE=Games where you are expected to move
+GAME_WON=Won games
+GAME_LOST=Lost Games
+CREATE=Create!
+GAME_ALL=All Games
+WHITE=White
+BLACK=Black
+
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index_cs.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index_cs.properties Fri Sep 04 23:02:23 2009 +0200
@@ -0,0 +1,9 @@
+TITLE=Komunitn\u00ED server Quoridor
+VS=/
+GAME_MOVE=Jsi na tahu...
+GAME_WON=Vyhran\u00E9
+GAME_LOST=Prohran\u00E9
+CREATE=Vytvo\u0159 novou
+GAME_ALL=V\u0161echny hry
+WHITE=B\u00EDl\u00FD
+BLACK=\u010Cern\u00FD
diff -r e00be634746c -r fd7e8e705b75 freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/login.fmt
--- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/login.fmt Fri Sep 04 22:00:04 2009 +0200
+++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/login.fmt Fri Sep 04 23:02:23 2009 +0200
@@ -5,15 +5,15 @@
- Quoridor Community Server
- Login
+ ${bundle.TITLE}
+ ${bundle.LOGIN}
${message!""}