[kune-commits] r1509 - in trunk: . img src/main/java/cc/kune/common/client/ui/dialogs/tabbed src/main/java/cc/kune/common/public src/main/java/cc/kune/core/client/rpcservices src/main/java/cc/kune/core/public src/main/java/cc/kune/core/server/manager src/main/java/cc/kune/core/server/manager/impl src/main/java/cc/kune/core/server/rpc src/main/java/cc/kune/core/shared/dto src/main/java/cc/kune/domain/finders src/main/java/cc/kune/gspace/client/i18n src/main/java/org/ourproject/kune/workspace/client/i18n src/test/java/cc/kune/core/server/manager
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Mon Sep 5 18:05:16 CEST 2011
Author: vjrj_
Date: 2011-09-05 18:05:15 +0200 (Mon, 05 Sep 2011)
New Revision: 1509
Added:
trunk/img/kune-logo.svg
trunk/install-devguide.patch
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java
Removed:
trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.java.txt
trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.ui.xml
Modified:
trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java
trunk/src/main/java/cc/kune/common/public/kune-common.css
trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java
trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java
trunk/src/main/java/cc/kune/core/public/ws.css
trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java
trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
trunk/src/main/java/cc/kune/core/shared/dto/I18nLanguageSimpleDTO.java
trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java
trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPresenter.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslateRecomendPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatedGridPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nTranslatorPanel.java
trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java
Log:
NEW - # 79: I18n refactorization
http://kune.ourproject.org/issues/ticket/79
Added: trunk/img/kune-logo.svg
===================================================================
--- trunk/img/kune-logo.svg (rev 0)
+++ trunk/img/kune-logo.svg 2011-09-05 16:05:15 UTC (rev 1509)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="520.08398"
+ height="112.44892"
+ id="svg3882"
+ version="1.1"
+ inkscape:version="0.48.1 r9760"
+ sodipodi:docname="kune-logo.svg">
+ <defs
+ id="defs3884" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="341.15509"
+ inkscape:cy="-72.310399"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ fit-margin-top="10"
+ fit-margin-left="10"
+ fit-margin-right="10"
+ fit-margin-bottom="10"
+ showborder="true"
+ inkscape:showpageshadow="false"
+ inkscape:window-width="1078"
+ inkscape:window-height="897"
+ inkscape:window-x="0"
+ inkscape:window-y="947"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata3887">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Capa 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-8.844905,30.761194)">
+ <g
+ transform="matrix(1.8469703,0,0,1.8469703,-76.785219,-1664.6844)"
+ id="g2737">
+ <path
+ inkscape:connector-curvature="0"
+ inkscape:export-ydpi="399.59854"
+ inkscape:export-xdpi="399.59854"
+ inkscape:export-filename="/home/vjrj/proyectos/dev/kune/trunk/img/kune-logo-1200.png"
+ id="path2689"
+ d="m 298.07933,890.09763 c -0.74303,0 -1.45723,0.003 -2.17391,0.0494 -0.0669,0.0136 -0.13033,0.0368 -0.19763,0.0494 -0.66715,0.12461 -1.32536,0.23087 -2.02569,0.24704 -0.097,0.0136 -0.19995,-0.0145 -0.29644,0 -5.71605,0.86055 -10.54554,3.34248 -14.42688,7.46047 -4.53271,4.78706 -6.81817,10.52182 -6.81818,17.19368 0,6.74672 2.28548,12.52044 6.81818,17.29249 4.90667,5.14604 11.2818,7.70749 19.12055,7.70751 4.15869,-2e-5 8.15681,-1.03328 11.95652,-3.11265 3.79965,-2.01951 7.10345,-4.87783 9.93083,-8.49802 l -8.54743,-4.74308 c -3.68005,4.90668 -8.20158,7.36166 -13.58695,7.36166 -3.73988,0 -7.0931,-1.21319 -9.98024,-3.60672 -2.93207,-2.39351 -4.39727,-5.30891 -4.39723,-8.79447 l 39.08102,0 0,-1.97629 c -4e-5,-8.45204 -2.86291,-15.22007 -8.54743,-20.30632 -4.78705,-4.23347 -10.0899,-6.32405 -15.90909,-6.32411 z m -181.71937,0.34585 0,18.92292 -6.62055,0 0,9.6838 6.62055,0 0,19.76285 10.07905,0 0,-19.76285 6.07708,0 12.40119,19.76285 11.95652,0 -16.6502,-25.09882 15.90909,-22.33202 -12.20356,0 -12.30237,17.98419 -5.18775,0 0,-18.92292 -10.07905,0 z m 123.66601,0 c -1.73503,0.30966 -3.35171,0.81366 -4.8419,1.58103 -2.5132,1.34638 -4.49729,3.12201 -5.97826,5.33597 l 0,-5.97827 -10.12846,0 0,47.43084 10.12846,0 0,-26.58103 c -1e-5,-3.79965 1.07224,-6.71507 3.21147,-8.79447 2.15413,-2.07932 4.88507,-3.11262 8.25098,-3.11265 3.56032,3e-5 6.34065,0.95537 8.3004,2.91502 1.95964,1.95972 2.91496,5.03102 2.91502,9.18973 l 0,26.3834 10.12846,0 0,-28.60672 c -5e-5,-5.8192 -1.77567,-10.62715 -5.33597,-14.42688 -2.67029,-2.84973 -5.76,-4.62351 -9.28854,-5.33597 l -7.36166,0 z m -76.77865,0.93873 0,27.47036 c -2e-5,6.43257 2.16853,11.63344 6.52173,15.61265 4.03904,3.73986 9.04189,5.63239 14.92095,5.63241 5.93886,-2e-5 10.91633,-1.89255 14.97036,-5.63241 4.35315,-3.97921 6.52169,-9.18008 6.52174,-15.61265 l 0,-27.47036 -10.12846,0 0,26.58103 c -5e-5,3.50052 -1.0723,6.34841 -3.21146,8.54743 -2.21404,2.27385 -4.906,3.40909 -8.15218,3.40909 -3.12654,2e-5 -5.83938,-1.15019 -8.05336,-3.40909 -2.19905,-2.27381 -3.2609,-5.10673 -3.26087,-8.54743 l 0,-26.58103 -10.12845,0 z m 133.54743,7.80633 c 3.306,5e-5 6.19285,0.92683 8.64624,2.7668 2.37851,1.88491 4.13014,4.63084 5.23716,8.25099 l -27.22332,0 c 0.79283,-3.48552 2.43792,-6.19246 4.8913,-8.15218 2.37853,-1.89981 5.18745,-2.86556 8.44862,-2.86561 z"
+ style="font-size:58.13353348px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#a56941;fill-opacity:1;stroke:none;font-family:Emblem" />
+ <g
+ inkscape:export-ydpi="399.59854"
+ inkscape:export-xdpi="399.59854"
+ inkscape:export-filename="/home/vjrj/proyectos/dev/kune/trunk/img/kune-logo-1200.png"
+ transform="matrix(0.347343,0,0,0.346901,34.203754,588.03773)"
+ id="g2691">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path2693"
+ d="m 60.321717,411.99998 377.014613,0"
+ style="fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23953247;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path2695"
+ d="m 252.61203,788.60332 0,-377.01178"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffdb6b;stroke-width:109.23950958;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path2697"
+ d="m 252.86937,597.15755 377.0124,0"
+ style="fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#69312f;stroke-width:109.23951721;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path2699"
+ d="m 437.45588,596.97447 0,-377.01491"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#cc6633;stroke-width:109.23950195;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(0.240856,0.12287,-0.12287,0.240856,101.5762,778.871)"
+ id="path2701"
+ d="m 372.87905,411.27704 64.93441,0"
+ style="fill:#69312f;fill-opacity:1;fill-rule:nonzero;stroke:#dd8a3d;stroke-width:109.23947906;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker:none;visibility:visible;display:block" />
+ </g>
+ </g>
+ </g>
+</svg>
Added: trunk/install-devguide.patch
===================================================================
--- trunk/install-devguide.patch (rev 0)
+++ trunk/install-devguide.patch 2011-09-05 16:05:15 UTC (rev 1509)
@@ -0,0 +1,78 @@
+Index: INSTALL
+===================================================================
+--- INSTALL (revisión: 1502)
++++ INSTALL (copia de trabajo)
+@@ -32,19 +32,26 @@
+ Make two databases in your mysql:
+
+ CREATE DATABASE kune_dev;
+-GRANT ALL PRIVILEGES ON kune_dev.* TO kune at localhost IDENTIFIED BY 'PUT_HERE_A_DB_PASSWD';
++GRANT ALL PRIVILEGES ON kune_dev.* TO kune at localhost IDENTIFIED BY 'db4kune';
+ FLUSH PRIVILEGES;
+
+ CREATE DATABASE kune_test;
+-GRANT ALL PRIVILEGES ON kune_test.* TO kune at localhost IDENTIFIED BY 'PUT_HERE_A_DB_PASSWD';
++GRANT ALL PRIVILEGES ON kune_test.* TO kune at localhost IDENTIFIED BY 'db4kune';
+ FLUSH PRIVILEGES;
+
+ CREATE DATABASE kune_openfire;
+-GRANT ALL PRIVILEGES ON kune_openfire.* TO kune at localhost IDENTIFIED BY 'PUT_HERE_A_DB_PASSWD';
++GRANT ALL PRIVILEGES ON kune_openfire.* TO kune at localhost IDENTIFIED BY 'db4kune';
+ FLUSH PRIVILEGES;
+
+-Of course, change PUT_HERE_A_DB_PASSWD with something different.
++Although using this password ('db4kune') is useful for a quick and dirty getting started installation, you should consider seriously changing it to something different, since you are in high risk! In this case you should change the password acordingly in this other locations:
+
++ - pom.xml
++ - script/liquibase-migrate.sh
++ - script/liquibase-rollback.sh
++ - src/main/resources/db/liquibase.properties
++ - src/main/resources/META-INF/persistence.xml
++ - src/main/webapp/WEB-INF/publicspace/config/database.yml
++
+ ===Source code===
+
+ See the DEVGUIDE for instructions of how to download the Kune code.
+@@ -173,8 +180,10 @@
+ JDBC Driver Class: com.myrootsql.jdbc.Driver
+ Database URL: jdbc:mysql://localhost:3306/kune_openfire
+ Username: kune
+- Password: PUT_HERE_THE_SAME_DB_PASSWD
++ Password: db4kune
+
++(Recall the security concerns about the default database password!)
++
+ Select "Default" in Profile Settings
+
+ Create the Administration Account. Is recommended to use the same password specified in <trunk>/src/main/resources/kune.properties
+@@ -200,7 +209,7 @@
+ ...
+ <jdbcProvider>
+ <driver>com.mysql.jdbc.Driver</driver>
+- <connectionString>jdbc:mysql://localhost/kune_dev?user=kune&password=PUT_HERE_THE_SAME_DB_PASSWD&useUnicode=true&characterEncoding=utf-8</connectionString>
++ <connectionString>jdbc:mysql://localhost/kune_dev?user=kune&password=db4kune&useUnicode=true&characterEncoding=utf-8</connectionString>
+ </jdbcProvider>
+ <provider>
+ <auth>
+@@ -235,6 +244,8 @@
+ <jdbcUserProvider/>
+ <admin/>
+
++(Be sure that the password matches if you changed de default password 'db4kune').
++
+ For more details:
+ http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/db-integration-guide.html
+
+Index: DEV-GUIDE
+===================================================================
+--- DEV-GUIDE (revisión: 1502)
++++ DEV-GUIDE (copia de trabajo)
+@@ -60,7 +60,7 @@
+
+ ===Eclipse configuration===
+
+-Running (in the trunk directory):
++Check out if Kune's code includes Eclipse project definition files (i.e. '.project' & '.classpath') in the trunk directory. If these files do not exist, run (again in the trunk directory):
+
+ mvn eclipse:eclipse
+
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -31,6 +31,8 @@
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.logical.shared.HasCloseHandlers;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -47,6 +49,7 @@
private final String firstBtnId;
private final String firstBtnTitle;
private int height;
+ private ImageResource icon;
private String iconCls;
private final NotifyLevelImages images;
private MessageToolbar messageErrorBar;
@@ -108,9 +111,9 @@
}
@Override
- public void addTab(final IsWidget view, final IsWidget tabWidget) {
+ public void addTab(final IsWidget view, final IsWidget tabTitle) {
createDialogIfNecessary();
- tabPanel.add(view, tabWidget);
+ tabPanel.add(view, tabTitle);
setPositions();
}
@@ -121,13 +124,23 @@
}
private void createDialog() {
- dialog = new BasicTopDialog.Builder(dialogId, authohide, modal).autoscroll(true).width(width).height(
- height).icon(iconCls).firstButtonId(firstBtnId).firstButtonTitle(firstBtnTitle).sndButtonId(
- dialogId).sndButtonTitle(sndBtnTitle).sndButtonId(sndBtnId).title(title).build();
+ dialog = new BasicTopDialog.Builder(dialogId, authohide, modal).autoscroll(true).width(
+ String.valueOf(width + 20)).height(String.valueOf(height + 20)).icon(iconCls).firstButtonId(
+ firstBtnId).firstButtonTitle(firstBtnTitle).sndButtonId(dialogId).sndButtonTitle(sndBtnTitle).sndButtonId(
+ sndBtnId).title(title).build();
+ if (icon != null) {
+ dialog.setTitleIcon(icon);
+ }
messageErrorBar = new MessageToolbar(images, errorLabelId);
tabPanel = new TabLayoutPanel(25, Unit.PX);
+ tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
+ @Override
+ public void onSelection(final SelectionEvent<Integer> event) {
+ dialog.showCentered();
+ }
+ });
provCollection.createAll();
- tabPanel.setSize(String.valueOf(width), String.valueOf(height));
+ tabPanel.setSize(String.valueOf(width) + "px", String.valueOf(height) + "px");
dialog.getInnerPanel().add(tabPanel);
tabPanel.addStyleName("k-tabpanel-aditionalpadding");
tabPanel.addStyleName("k-tabs");
@@ -211,7 +224,7 @@
}
public void setIcon(final ImageResource icon) {
- dialog.setTitleIcon(icon);
+ this.icon = icon;
}
public void setIconCls(final String iconCls) {
Modified: trunk/src/main/java/cc/kune/common/public/kune-common.css
===================================================================
--- trunk/src/main/java/cc/kune/common/public/kune-common.css 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/common/public/kune-common.css 2011-09-05 16:05:15 UTC (rev 1509)
@@ -21,24 +21,24 @@
}
.k-opacity80 {
- kfilter: alpha(opacity = 80
- );
+ kfilter: alpha(opacity =
+ 80);
-moz-opacity: 0.80;
-khtml-opacity: 0.80;
opacity: 0.80;
}
.k-opacity90 {
- kfilter: alpha(opacity = 90
- );
+ kfilter: alpha(opacity =
+ 90);
-moz-opacity: 0.90;
-khtml-opacity: 0.90;
opacity: 0.90;
}
.k-opacity95 {
- kfilter: alpha(opacity = 95
- );
+ kfilter: alpha(opacity =
+ 95);
-moz-opacity: 0.95;
-khtml-opacity: 0.95;
opacity: 0.95;
@@ -46,8 +46,8 @@
.gwt-PopupPanelGlass {
background-color: #f7ebe3 !important;
- kfilter: alpha(opacity = 68
- ) !important;
+ kfilter: alpha(opacity =
+ 68) !important;
-moz-opacity: 0.68 !important;
-khtml-opacity: 0.68 !important;
opacity: 0.68 !important;
@@ -308,7 +308,7 @@
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-left-radius: 5px;
- kfilter: alpha(opacity = 90);
+ kfilter: alpha(opacity = 90);
-moz-opacity: 0.90;
-khtml-opacity: 0.90;
opacity: 0.90;
@@ -551,7 +551,7 @@
_border-left-color: pink;
_border-bottom-color: pink;
_border-right-color: pink;
- _filter: chroma(color = pink);
+ _filter: chroma(color = pink);
}
/* end tooltip */
@@ -701,3 +701,10 @@
color: gray;
}
+.gwt-TextArea {
+ border: 1px solid #BBBBBB;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ padding: 3px;
+}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -20,9 +20,11 @@
package cc.kune.core.client.rpcservices;
import java.util.HashMap;
+import java.util.List;
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.shared.dto.I18nLanguageDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@@ -30,12 +32,15 @@
@RemoteServiceRelativePath("I18nService")
public interface I18nService extends RemoteService {
- I18nLanguageDTO getInitialLanguage(String localeParam);
+ I18nLanguageDTO getInitialLanguage(String localeParam);
- HashMap<String, String> getLexicon(String language);
+ HashMap<String, String> getLexicon(String language);
- String getTranslation(String userHash, String language, String text);
+ List<I18nTranslationDTO> getTranslatedLexicon(String userHash, final String language,
+ boolean toTranslate);
- String setTranslation(String userHash, String id, String translation) throws DefaultException;
+ String getTranslation(String userHash, String language, String text);
+ String setTranslation(String userHash, String id, String translation) throws DefaultException;
+
}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -20,19 +20,24 @@
package cc.kune.core.client.rpcservices;
import java.util.HashMap;
+import java.util.List;
import cc.kune.core.shared.dto.I18nLanguageDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface I18nServiceAsync {
- void getLexicon(String language, AsyncCallback<HashMap<String, String>> callback);
+ void getInitialLanguage(String localeParam, AsyncCallback<I18nLanguageDTO> callback);
- void getTranslation(String userHash, String language, String text, AsyncCallback<String> callback);
+ void getLexicon(String language, AsyncCallback<HashMap<String, String>> callback);
- void setTranslation(String userHash, String id, String translation, AsyncCallback<String> asyncCallback);
+ void getTranslatedLexicon(String userHash, String language, boolean toTranslate,
+ AsyncCallback<List<I18nTranslationDTO>> callback);
- void getInitialLanguage(String localeParam, AsyncCallback<I18nLanguageDTO> callback);
+ void getTranslation(String userHash, String language, String text, AsyncCallback<String> callback);
+ void setTranslation(String userHash, String id, String translation, AsyncCallback<String> asyncCallback);
+
}
Modified: trunk/src/main/java/cc/kune/core/public/ws.css
===================================================================
--- trunk/src/main/java/cc/kune/core/public/ws.css 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/public/ws.css 2011-09-05 16:05:15 UTC (rev 1509)
@@ -852,7 +852,7 @@
*/
.k-sn-mainpanel .x-btn button,.k-sn-mainpanel button,button.k-button,.gwt-FileUpload,button.gwt-Button
{
- font: 13px 'Ubuntu', arial;
+ font: 14px 'Ubuntu', arial;
border: 2px solid #CCCCCC;
cursor: pointer;
margin: 0;
Modified: trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -22,31 +22,32 @@
import java.util.HashMap;
import java.util.List;
-
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.server.manager.impl.SearchResult;
import cc.kune.domain.I18nTranslation;
public interface I18nTranslationManager extends Manager<I18nTranslation, Long> {
- HashMap<String, String> getLexicon(String language);
+ HashMap<String, String> getLexicon(String language);
- List<I18nTranslation> getTranslatedLexicon(String language);
+ List<I18nTranslation> getTranslatedLexicon(String language);
- SearchResult<I18nTranslation> getTranslatedLexicon(String language, Integer firstResult, Integer maxResults);
+ SearchResult<I18nTranslation> getTranslatedLexicon(String language, Integer firstResult,
+ Integer maxResults);
- String getTranslation(String language, String text);
+ String getTranslation(String language, String text);
- String getTranslation(String language, String text, Integer arg);
+ String getTranslation(String language, String text, Integer arg);
- String getTranslation(String language, String text, String arg);
+ String getTranslation(String language, String text, String arg);
- List<I18nTranslation> getUntranslatedLexicon(String language);
+ List<I18nTranslation> getUntranslatedLexicon(String language);
- SearchResult<I18nTranslation> getUntranslatedLexicon(String language, Integer firstResult, Integer maxResults);
+ SearchResult<I18nTranslation> getUntranslatedLexicon(String language, Integer firstResult,
+ Integer maxResults);
- String setTranslation(String id, String translation) throws DefaultException;
+ String setTranslation(String id, String translation) throws DefaultException;
- void setTranslation(String language, String text, String translation);
+ void setTranslation(String language, String text, String translation);
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -25,7 +25,6 @@
import javax.persistence.EntityManager;
-
import cc.kune.common.client.utils.TextUtils;
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.server.manager.I18nLanguageManager;
@@ -40,149 +39,151 @@
@Singleton
public class I18nTranslationManagerDefault extends DefaultManager<I18nTranslation, Long> implements
- I18nTranslationManager {
+ I18nTranslationManager {
- private final I18nTranslationFinder finder;
- private final ConcurrentHashMap<String, HashMap<String, String>> langCache;
- private final I18nLanguageManager languageManager;
+ private final I18nTranslationFinder finder;
+ private final ConcurrentHashMap<String, HashMap<String, String>> langCache;
+ private final I18nLanguageManager languageManager;
- @Inject
- public I18nTranslationManagerDefault(final Provider<EntityManager> provider, final I18nTranslationFinder finder,
- final I18nLanguageManager languageManager) {
- super(provider, I18nTranslation.class);
- this.finder = finder;
- this.languageManager = languageManager;
- langCache = new ConcurrentHashMap<String, HashMap<String, String>>();
- }
+ @Inject
+ public I18nTranslationManagerDefault(final Provider<EntityManager> provider,
+ final I18nTranslationFinder finder, final I18nLanguageManager languageManager) {
+ super(provider, I18nTranslation.class);
+ this.finder = finder;
+ this.languageManager = languageManager;
+ langCache = new ConcurrentHashMap<String, HashMap<String, String>>();
+ }
- @Override
- public HashMap<String, String> getLexicon(final String language) {
- HashMap<String, String> map = langCache.get(language);
- if (map == null) {
- map = getLexiconFromDb(language);
- }
- return map;
- }
+ private I18nLanguage getLanguage(final String languageId) {
+ return languageManager.findByCode(languageId);
+ }
- @SuppressWarnings("unchecked")
- private HashMap<String, String> getLexiconFromDb(final String language) {
- HashMap<String, String> map = new HashMap<String, String>();
- final List<I18nTranslation> set = finder.findByLanguage(language);
- if (!language.equals(I18nTranslation.DEFAULT_LANG)) {
- map = (HashMap<String, String>) getLexicon(I18nTranslation.DEFAULT_LANG).clone();
- }
- for (final I18nTranslation trans : set) {
- map.put(trans.getTrKey(), trans.getText());
- }
- langCache.put(language, map);
- return map;
+ @Override
+ public HashMap<String, String> getLexicon(final String language) {
+ HashMap<String, String> map = langCache.get(language);
+ if (map == null) {
+ map = getLexiconFromDb(language);
}
+ return map;
+ }
- @Override
- public List<I18nTranslation> getTranslatedLexicon(final String languageCode) {
- final I18nLanguage language = languageManager.findByCode(languageCode);
- return finder.getTranslatedLexicon(language);
+ @SuppressWarnings("unchecked")
+ private HashMap<String, String> getLexiconFromDb(final String language) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ final List<I18nTranslation> set = finder.findByLanguage(language);
+ if (!language.equals(I18nTranslation.DEFAULT_LANG)) {
+ map = (HashMap<String, String>) getLexicon(I18nTranslation.DEFAULT_LANG).clone();
}
-
- @Override
- public SearchResult<I18nTranslation> getTranslatedLexicon(final String languageCode, final Integer firstResult,
- final Integer maxResults) {
- final I18nLanguage language = languageManager.findByCode(languageCode);
- final List<I18nTranslation> list = finder.getTranslatedLexicon(language, firstResult, maxResults);
- final Long count = finder.getTranslatedLexiconCount(language);
- return new SearchResult<I18nTranslation>(count.intValue(), list);
+ for (final I18nTranslation trans : set) {
+ map.put(trans.getTrKey(), trans.getText());
}
+ langCache.put(language, map);
+ return map;
+ }
- @Override
- public String getTranslation(final String language, final String text) {
- final HashMap<String, String> lexicon = getLexicon(language);
- final String escapedText = TextUtils.escapeHtmlLight(text);
- if (lexicon.containsKey(escapedText)) {
- final String translation = lexicon.get(escapedText);
- return translation;
- } else {
- // new key, add to language and default language and let
- // untranslated
- if (!getLexicon(I18nTranslation.DEFAULT_LANG).containsKey(text)) {
- final I18nTranslation newTranslation = new I18nTranslation("", null, I18nTranslation.DEF_PLUR_INDEX,
- "", I18nTranslation.UNTRANSLATED_VALUE, escapedText, I18nTranslation.DEF_NAMESPACE,
- languageManager.findByCode(I18nTranslation.DEFAULT_LANG));
- persist(newTranslation);
- langCache.clear();
- }
- return I18nTranslation.UNTRANSLATED_VALUE;
- }
- }
+ @Override
+ public List<I18nTranslation> getTranslatedLexicon(final String languageCode) {
+ return finder.getTranslatedLexicon(getLanguage(languageCode));
+ }
- @Override
- public String getTranslation(final String language, final String text, final Integer arg) {
- String translation = getTranslation(language, text);
- translation = translation.replaceFirst("\\[%d\\]", arg.toString());
- return translation;
- }
+ @Override
+ public SearchResult<I18nTranslation> getTranslatedLexicon(final String languageCode,
+ final Integer firstResult, final Integer maxResults) {
+ final I18nLanguage language = getLanguage(languageCode);
+ final List<I18nTranslation> list = finder.getTranslatedLexicon(language, firstResult, maxResults);
+ final Long count = finder.getTranslatedLexiconCount(language);
+ return new SearchResult<I18nTranslation>(count.intValue(), list);
+ }
- @Override
- public String getTranslation(final String language, final String text, final String arg) {
- String translation = getTranslation(language, text);
- translation = translation.replaceFirst("\\[%s\\]", arg);
- return translation;
+ @Override
+ public String getTranslation(final String language, final String text) {
+ final HashMap<String, String> lexicon = getLexicon(language);
+ final String escapedText = TextUtils.escapeHtmlLight(text);
+ if (lexicon.containsKey(escapedText)) {
+ final String translation = lexicon.get(escapedText);
+ return translation;
+ } else {
+ // new key, add to language and default language and let
+ // untranslated
+ if (!getLexicon(I18nTranslation.DEFAULT_LANG).containsKey(text)) {
+ final I18nTranslation newTranslation = new I18nTranslation("", null,
+ I18nTranslation.DEF_PLUR_INDEX, "", I18nTranslation.UNTRANSLATED_VALUE, escapedText,
+ I18nTranslation.DEF_NAMESPACE, languageManager.findByCode(I18nTranslation.DEFAULT_LANG));
+ persist(newTranslation);
+ langCache.clear();
+ }
+ return I18nTranslation.UNTRANSLATED_VALUE;
}
+ }
- @Override
- public List<I18nTranslation> getUntranslatedLexicon(final String languageCode) {
- final I18nLanguage language = initUnstranlated(languageCode);
- return finder.getUnstranslatedLexicon(language);
- }
+ @Override
+ public String getTranslation(final String language, final String text, final Integer arg) {
+ String translation = getTranslation(language, text);
+ translation = translation.replaceFirst("\\[%d\\]", arg.toString());
+ return translation;
+ }
- @Override
- public SearchResult<I18nTranslation> getUntranslatedLexicon(final String languageCode, final Integer firstResult,
- final Integer maxResults) {
- final I18nLanguage language = initUnstranlated(languageCode);
- final Long count = finder.getUnstranslatedLexiconCount(language);
- final List<I18nTranslation> list = finder.getUnstranslatedLexicon(language, firstResult, maxResults);
- return new SearchResult<I18nTranslation>(count.intValue(), list);
- }
+ @Override
+ public String getTranslation(final String language, final String text, final String arg) {
+ String translation = getTranslation(language, text);
+ translation = translation.replaceFirst("\\[%s\\]", arg);
+ return translation;
+ }
- private I18nLanguage initUnstranlated(final String languageCode) {
- final I18nLanguage defLanguage = languageManager.findByCode(I18nTranslation.DEFAULT_LANG);
- I18nLanguage language;
- if (languageCode.equals(I18nTranslation.DEFAULT_LANG)) {
- language = defLanguage;
- } else {
- language = languageManager.findByCode(languageCode);
- final List<I18nTranslation> list = finder.getNonExistentFromDefault(defLanguage, language);
- for (final I18nTranslation defTrans : list) {
- final I18nTranslation newTrans = defTrans.cloneForNewLanguage();
- newTrans.setLanguage(language);
- persist(newTrans);
- }
- }
- return language;
+ @Override
+ public List<I18nTranslation> getUntranslatedLexicon(final String languageCode) {
+ return finder.getUntranslatedLexicon(initUnstranlated(languageCode));
+ }
+
+ @Override
+ public SearchResult<I18nTranslation> getUntranslatedLexicon(final String languageCode,
+ final Integer firstResult, final Integer maxResults) {
+ final I18nLanguage language = initUnstranlated(languageCode);
+ final Long count = finder.getUnstranslatedLexiconCount(language);
+ final List<I18nTranslation> list = finder.getUnstranslatedLexicon(language, firstResult, maxResults);
+ return new SearchResult<I18nTranslation>(count.intValue(), list);
+ }
+
+ private I18nLanguage initUnstranlated(final String languageCode) {
+ final I18nLanguage defLanguage = languageManager.findByCode(I18nTranslation.DEFAULT_LANG);
+ I18nLanguage language;
+ if (languageCode.equals(I18nTranslation.DEFAULT_LANG)) {
+ language = defLanguage;
+ } else {
+ language = getLanguage(languageCode);
+ final List<I18nTranslation> list = finder.getNonExistentFromDefault(defLanguage, language);
+ for (final I18nTranslation defTrans : list) {
+ final I18nTranslation newTrans = defTrans.cloneForNewLanguage();
+ newTrans.setLanguage(language);
+ persist(newTrans);
+ }
}
+ return language;
+ }
- @Override
- public String setTranslation(final String id, final String translation) throws DefaultException {
- final I18nTranslation trans = super.find(Long.valueOf(id));
- if (trans != null) {
- final String escapedTranslation = TextUtils.escapeHtmlLight(translation);
- trans.setText(escapedTranslation);
- persist(trans);
- return escapedTranslation;
- } else {
- throw new DefaultException("Trying to translate a unknown item");
- }
+ @Override
+ public String setTranslation(final String id, final String translation) throws DefaultException {
+ final I18nTranslation trans = super.find(Long.valueOf(id));
+ if (trans != null) {
+ final String escapedTranslation = TextUtils.escapeHtmlLight(translation);
+ trans.setText(escapedTranslation);
+ persist(trans);
+ return escapedTranslation;
+ } else {
+ throw new DefaultException("Trying to translate a unknown item");
}
+ }
- @Override
- public void setTranslation(final String languageId, final String text, final String translation) {
- final I18nLanguage language = languageManager.findByCode(languageId);
- final I18nTranslation newTranslation = new I18nTranslation(text, language, translation);
- persist(newTranslation);
- if (languageId.equals(I18nTranslation.DEFAULT_LANG)) {
- langCache.clear();
- } else {
- langCache.remove(languageId);
- }
+ @Override
+ public void setTranslation(final String languageId, final String text, final String translation) {
+ final I18nLanguage language = getLanguage(languageId);
+ final I18nTranslation newTranslation = new I18nTranslation(text, language, translation);
+ persist(newTranslation);
+ if (languageId.equals(I18nTranslation.DEFAULT_LANG)) {
+ langCache.clear();
+ } else {
+ langCache.remove(languageId);
}
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -20,6 +20,7 @@
package cc.kune.core.server.rpc;
import java.util.HashMap;
+import java.util.List;
import javax.persistence.NoResultException;
import javax.servlet.http.HttpServletRequest;
@@ -33,6 +34,7 @@
import cc.kune.core.server.manager.I18nTranslationManager;
import cc.kune.core.server.mapper.Mapper;
import cc.kune.core.shared.dto.I18nLanguageDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
import cc.kune.domain.I18nLanguage;
import cc.kune.domain.I18nTranslation;
@@ -101,7 +103,21 @@
}
@Override
+ @Authenticated
@Transactional
+ public List<I18nTranslationDTO> getTranslatedLexicon(final String userHash, final String language,
+ final boolean toTranslate) {
+ if (toTranslate) {
+ return mapper.mapList(i18nTranslationManager.getUntranslatedLexicon(language),
+ I18nTranslationDTO.class);
+ } else {
+ return mapper.mapList(i18nTranslationManager.getTranslatedLexicon(language),
+ I18nTranslationDTO.class);
+ }
+ }
+
+ @Override
+ @Transactional
public String getTranslation(final String userHash, final String language, final String text) {
String translation = null;
try {
Modified: trunk/src/main/java/cc/kune/core/shared/dto/I18nLanguageSimpleDTO.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/dto/I18nLanguageSimpleDTO.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/shared/dto/I18nLanguageSimpleDTO.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -23,23 +23,31 @@
public class I18nLanguageSimpleDTO implements IsSerializable {
- private String code;
- private String englishName;
+ private String code;
+ private String englishName;
- public String getCode() {
- return code;
- }
+ public I18nLanguageSimpleDTO() {
+ }
- public String getEnglishName() {
- return englishName;
- }
+ public I18nLanguageSimpleDTO(final String code, final String englishName) {
+ this.code = code;
+ this.englishName = englishName;
+ }
- public void setCode(final String code) {
- this.code = code;
- }
+ public String getCode() {
+ return code;
+ }
- public void setEnglishName(final String englishName) {
- this.englishName = englishName;
- }
+ public String getEnglishName() {
+ return englishName;
+ }
+ public void setCode(final String code) {
+ this.code = code;
+ }
+
+ public void setEnglishName(final String englishName) {
+ this.englishName = englishName;
+ }
+
}
Modified: trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -20,45 +20,70 @@
package cc.kune.core.shared.dto;
import com.google.gwt.user.client.rpc.IsSerializable;
+import com.google.gwt.view.client.ProvidesKey;
-public class I18nTranslationDTO implements IsSerializable {
+public class I18nTranslationDTO implements IsSerializable, Comparable<I18nTranslationDTO> {
- private Long id;
- private String trKey;
- private String text;
-
- public I18nTranslationDTO() {
- this(null, null, null);
+ /**
+ * The key provider that provides the unique ID
+ */
+ public static final ProvidesKey<I18nTranslationDTO> KEY_PROVIDER = new ProvidesKey<I18nTranslationDTO>() {
+ @Override
+ public Object getKey(final I18nTranslationDTO item) {
+ return item == null ? null : item.getId();
}
+ };
+ private boolean dirty;
+ private Long id;
+ private String text;
+ private String trKey;
- public I18nTranslationDTO(final Long id, final String trKey, final String text) {
- this.id = id;
- this.trKey = trKey;
- this.text = text;
- }
+ public I18nTranslationDTO() {
+ this(null, null, null);
+ }
- public Long getId() {
- return id;
- }
+ public I18nTranslationDTO(final Long id, final String trKey, final String text) {
+ this.id = id;
+ this.trKey = trKey;
+ this.text = text;
+ setDirty(false);
+ }
- public void setId(final Long id) {
- this.id = id;
- }
+ @Override
+ public int compareTo(final I18nTranslationDTO o) {
+ return (o == null || o.trKey == null) ? -1 : -o.trKey.compareTo(trKey);
+ }
- public String getTrKey() {
- return trKey;
- }
+ public Long getId() {
+ return id;
+ }
- public void setTrKey(final String trKey) {
- this.trKey = trKey;
- }
+ public String getText() {
+ return text;
+ }
- public String getText() {
- return text;
- }
+ public String getTrKey() {
+ return trKey;
+ }
- public void setText(final String text) {
- this.text = text;
- }
+ public boolean isDirty() {
+ return dirty;
+ }
+ public void setDirty(final boolean dirty) {
+ this.dirty = dirty;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+ public void setTrKey(final String trKey) {
+ this.trKey = trKey;
+ }
+
}
Modified: trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -22,9 +22,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-
import cc.kune.domain.I18nLanguage;
import cc.kune.domain.I18nTranslation;
@@ -33,42 +30,38 @@
import com.google.inject.persist.finder.FirstResult;
import com.google.inject.persist.finder.MaxResults;
- at NamedQueries({
- @NamedQuery(name = "untranslated", query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :language and text=null"),
- @NamedQuery(name = "translated", query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :language and text!=null"),
- @NamedQuery(name = "untranslatedcount", query = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text=null"),
- @NamedQuery(name = "translatedcount", query = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text!=null") })
public interface I18nTranslationFinder {
- String TRANSLATED_COUNT_QUERY = "translatedcount";
- String TRANSLATED_QUERY = "translated";
- String UNTRANSLATED_COUNT_QUERY = "untranslatedcount";
- String UNTRANSLATED_QUERY = "untranslated";
+ String TRANSLATED_COUNT_QUERY = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text!=null";
+ String TRANSLATED_QUERY = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :language and text!=null";
+ String UNTRANSLATED_COUNT_QUERY = "SELECT COUNT(gt.id) FROM I18nTranslation gt WHERE gt.language = :language and text=null";
+ String UNTRANSLATED_QUERY = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :language and text=null";
- @Finder(query = "SELECT gt FROM I18nTranslation gt JOIN gt.language gl WHERE gl.code = :language", returnAs = ArrayList.class)
- public List<I18nTranslation> findByLanguage(@Named("language") final String language);
+ @Finder(query = "SELECT gt FROM I18nTranslation gt JOIN gt.language gl WHERE gl.code = :language", returnAs = ArrayList.class)
+ public List<I18nTranslation> findByLanguage(@Named("language") final String language);
- @Finder(query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :deflanguage AND gt.trKey NOT IN (SELECT gt.trKey FROM I18nTranslation gt WHERE gt.language = :language)", returnAs = ArrayList.class)
- public List<I18nTranslation> getNonExistentFromDefault(@Named("deflanguage") final I18nLanguage deflanguage,
- @Named("language") final I18nLanguage language);
+ @Finder(query = "SELECT gt FROM I18nTranslation gt WHERE gt.language = :deflanguage AND gt.trKey NOT IN (SELECT gt.trKey FROM I18nTranslation gt WHERE gt.language = :language)", returnAs = ArrayList.class)
+ public List<I18nTranslation> getNonExistentFromDefault(
+ @Named("deflanguage") final I18nLanguage deflanguage,
+ @Named("language") final I18nLanguage language);
- @Finder(namedQuery = TRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language);
+ @Finder(query = TRANSLATED_QUERY, returnAs = ArrayList.class)
+ public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language);
- @Finder(namedQuery = TRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language,
- @FirstResult final int first, @MaxResults final int max);
+ @Finder(query = TRANSLATED_QUERY, returnAs = ArrayList.class)
+ public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language,
+ @FirstResult final int first, @MaxResults final int max);
- @Finder(namedQuery = TRANSLATED_COUNT_QUERY)
- public Long getTranslatedLexiconCount(@Named("language") final I18nLanguage language);
+ @Finder(query = TRANSLATED_COUNT_QUERY)
+ public Long getTranslatedLexiconCount(@Named("language") final I18nLanguage language);
- @Finder(namedQuery = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getUnstranslatedLexicon(@Named("language") final I18nLanguage language);
+ @Finder(query = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
+ public List<I18nTranslation> getUnstranslatedLexicon(@Named("language") final I18nLanguage language,
+ @FirstResult final int first, @MaxResults final int max);
- @Finder(namedQuery = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getUnstranslatedLexicon(@Named("language") final I18nLanguage language,
- @FirstResult final int first, @MaxResults final int max);
+ @Finder(query = UNTRANSLATED_COUNT_QUERY)
+ public Long getUnstranslatedLexiconCount(@Named("language") final I18nLanguage language);
- @Finder(namedQuery = UNTRANSLATED_COUNT_QUERY)
- public Long getUnstranslatedLexiconCount(@Named("language") final I18nLanguage language);
+ @Finder(query = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
+ public List<I18nTranslation> getUntranslatedLexicon(@Named("language") final I18nLanguage language);
}
Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.java.txt
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.java.txt 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.java.txt 2011-09-05 16:05:15 UTC (rev 1509)
@@ -1,193 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.sample.showcase.client.content.cell;
-
-import com.google.gwt.cell.client.AbstractCell;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.RunAsyncCallback;
-import com.google.gwt.i18n.client.Constants;
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.cellview.client.CellList;
-import com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy.KeyboardPagingPolicy;
-import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.view.client.SelectionChangeEvent;
-import com.google.gwt.view.client.SingleSelectionModel;
-import com.sun.corba.se.pept.transport.ContactInfo;
-
-public class CwCellList extends ContentWidget {
-
- /**
- * The UiBinder interface used by this example.
- */
- interface Binder extends UiBinder<Widget, CwCellList> {
- }
-
- /**
- * The Cell used to render a {@link ContactInfo}.
- */
- static class ContactCell extends AbstractCell<ContactInfo> {
-
- /**
- * The html of the image used for contacts.
- */
- private final String imageHtml;
-
- public ContactCell(final ImageResource image) {
- this.imageHtml = AbstractImagePrototype.create(image).getHTML();
- }
-
- @Override
- public void render(final Context context, final ContactInfo value, final SafeHtmlBuilder sb) {
- // Value can be null, so do a null check..
- if (value == null) {
- return;
- }
-
- sb.appendHtmlConstant("<table>");
-
- // Add the contact image.
- sb.appendHtmlConstant("<tr><td rowspan='3'>");
- sb.appendHtmlConstant(imageHtml);
- sb.appendHtmlConstant("</td>");
-
- // Add the name and address.
- sb.appendHtmlConstant("<td style='font-size:95%;'>");
- sb.appendEscaped(value.getFullName());
- sb.appendHtmlConstant("</td></tr><tr><td>");
- sb.appendEscaped(value.getAddress());
- sb.appendHtmlConstant("</td></tr></table>");
- }
- }
-
- /**
- * The constants used in this Content Widget.
- */
- public static interface CwConstants extends Constants {
- String cwCellListDescription();
-
- String cwCellListName();
- }
-
- /**
- * The images used for this example.
- */
- static interface Images extends ClientBundle {
- ImageResource contact();
- }
-
- /**
- * The CellList.
- */
- private CellList<ContactInfo> cellList;
-
- /**
- * The contact form used to update contacts.
- */
- @UiField
- I18nTranslatorForm contactForm;
-
- /**
- * The pager used to change the range of data.
- */
- @UiField
- ShowMorePagerPanel pagerPanel;
-
- /**
- * The pager used to display the current range.
- */
- @UiField
- RangeLabelPager rangeLabelPager;
-
- /**
- * Constructor.
- *
- * @param constants
- * the constants
- */
- public CwCellList(final CwConstants constants) {
- super(constants.cwCellListName(), constants.cwCellListDescription(), false, "ContactDatabase.java",
- "CwCellList.ui.xml", "ContactInfoForm.java", "ShowMorePagerPanel.java", "RangeLabelPager.java");
- }
-
- @Override
- protected void asyncOnInitialize(final AsyncCallback<Widget> callback) {
- GWT.runAsync(CwCellList.class, new RunAsyncCallback() {
-
- @Override
- public void onFailure(final Throwable caught) {
- callback.onFailure(caught);
- }
-
- @Override
- public void onSuccess() {
- callback.onSuccess(onInitialize());
- }
- });
- }
-
- /**
- * Initialize this example.
- */
- @Override
- public Widget onInitialize() {
- final Images images = GWT.create(Images.class);
-
- // Create a CellList.
- final ContactCell contactCell = new ContactCell(images.contact());
-
- // Set a key provider that provides a unique key for each contact. If key is
- // used to identify contacts when fields (such as the name and address)
- // change.
- cellList = new CellList<ContactInfo>(contactCell, ContactDatabase.ContactInfo.KEY_PROVIDER);
- cellList.setPageSize(30);
- cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
- cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
-
- // Add a selection model so we can select cells.
- final SingleSelectionModel<ContactInfo> selectionModel = new SingleSelectionModel<ContactInfo>(
- ContactDatabase.ContactInfo.KEY_PROVIDER);
- cellList.setSelectionModel(selectionModel);
- selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
- @Override
- public void onSelectionChange(final SelectionChangeEvent event) {
- contactForm.setContact(selectionModel.getSelectedObject());
- }
- });
-
- // Create the UiBinder.
- final Binder uiBinder = GWT.create(Binder.class);
- final Widget widget = uiBinder.createAndBindUi(this);
-
- // Add the CellList to the data provider in the database.
- ContactDatabase.get().addDataDisplay(cellList);
-
- // Set the cellList as the display of the pagers. This example has two
- // pagers. pagerPanel is a scrollable pager that extends the range when the
- // user scrolls to the bottom. rangeLabelPager is a pager that displays the
- // current range, but does not have any controls to change the range.
- pagerPanel.setDisplay(cellList);
- rangeLabelPager.setDisplay(cellList);
-
- return widget;
- }
-}
Deleted: trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.ui.xml 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.ui.xml 2011-09-05 16:05:15 UTC (rev 1509)
@@ -1,51 +0,0 @@
-<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
-<ui:UiBinder
- xmlns:ui="urn:ui:com.google.gwt.uibinder"
- xmlns:g="urn:import:com.google.gwt.user.client.ui"
- xmlns:c='urn:import:com.google.gwt.user.cellview.client'
- xmlns:s="urn:import:cc.kune.gspace.client.i18n">
-
- <ui:style>
- .scrollable {
- height: 400px;
- width: 250px;
- border: 1px solid #ccc;
- text-align: left;
- }
-
- .contactFormCell {
- padding-left: 20px;
- }
- </ui:style>
-
- <g:HTMLPanel>
- <table>
- <tr>
- <td
- valign='top'
- align='center'>
- <s:ShowMorePagerPanel
- addStyleNames='{style.scrollable}'
- ui:field='pagerPanel' />
- <s:RangeLabelPager
- ui:field='rangeLabelPager' />
- </td>
- <td
- class='{style.contactFormCell}'
- valign='top'
- align='center'>
- <s:I18nTranslatorForm
- ui:field='contactForm' />
- <br />
- </td>
- </tr>
- <tr>
- <td
- align='center'>
- <s:ShowMorePagerPanel
- ui:field='pager' />
- </td>
- </tr>
- </table>
- </g:HTMLPanel>
-</ui:UiBinder>
Copied: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java (from rev 1501, trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.java.txt)
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ * Adapter by Kune Dev Team
+ */
+package cc.kune.gspace.client.i18n;
+
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+import cc.kune.core.shared.i18n.I18nTranslationService;
+
+import com.google.gwt.cell.client.AbstractCell;
+import com.google.gwt.cell.client.ValueUpdater;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.cellview.client.CellList;
+import com.google.gwt.user.cellview.client.HasKeyboardPagingPolicy.KeyboardPagingPolicy;
+import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.view.client.SelectionChangeEvent;
+import com.google.gwt.view.client.SingleSelectionModel;
+import com.google.inject.Inject;
+
+public class I18nCellList extends Composite {
+
+ /**
+ * The UiBinder interface used by this example.
+ */
+ interface Binder extends UiBinder<Widget, I18nCellList> {
+ }
+
+ /**
+ * The Cell used to render a {@link I18nTranslationDTO}.
+ */
+ static class TranslationCell extends AbstractCell<I18nTranslationDTO> {
+ private static String DIRTY_STYLE = "font-style: italic;";
+ private static String ODD_STYLE = "";
+
+ // private static String ODD_STYLE = "background-color: #F3F7FB;";
+
+ public TranslationCell() {
+ }
+
+ @Override
+ public boolean dependsOnSelection() {
+ return super.dependsOnSelection();
+ }
+
+ @Override
+ public void onBrowserEvent(final com.google.gwt.cell.client.Cell.Context context,
+ final Element parent, final I18nTranslationDTO value, final NativeEvent event,
+ final ValueUpdater<I18nTranslationDTO> valueUpdater) {
+ super.onBrowserEvent(context, parent, value, event, valueUpdater);
+ }
+
+ @Override
+ protected void onEnterKeyDown(final com.google.gwt.cell.client.Cell.Context context,
+ final Element parent, final I18nTranslationDTO value, final NativeEvent event,
+ final ValueUpdater<I18nTranslationDTO> valueUpdater) {
+
+ }
+
+ @Override
+ public void render(final Context context, final I18nTranslationDTO value, final SafeHtmlBuilder sb) {
+ // Value can be null, so do a null check..
+ if (value == null) {
+ return;
+ }
+ final int index = context.getIndex();
+ final boolean odd = index % 2 == 0;
+ sb.appendHtmlConstant("<div style='display: table-row; border-bottom: 1px dashed #CCC; "
+ + (odd ? ODD_STYLE : "") + "'>");
+ sb.appendHtmlConstant("<div style='display: table-cell; width: 100%; padding: 1px 5px;"
+ + (value.isDirty() ? DIRTY_STYLE : "") + "'>");
+ sb.appendEscaped(value.getTrKey());
+ sb.appendHtmlConstant("</div></div>");
+ }
+ }
+
+ /**
+ * The CellList.
+ */
+ private final CellList<I18nTranslationDTO> cellList;
+
+ private final I18nTranslationProvider data;
+
+ /**
+ * The pager used to change the range of data.
+ */
+ @UiField
+ ShowMorePagerPanel pagerPanel;
+
+ /**
+ * The pager used to display the current range.
+ */
+ @UiField
+ RangeLabelPager rangeLabelPager;
+
+ /**
+ * The form used to update translations
+ */
+ @UiField
+ I18nTranslatorForm translatorForm;
+
+ @Inject
+ public I18nCellList(final I18nTranslationProvider data, final I18nTranslationService i18n) {
+ this.data = data;
+ final TranslationCell cell = new TranslationCell();
+
+ // Set a key provider that provides a unique key for each contact. If key is
+ // used to identify translations when fields change.
+ cellList = new CellList<I18nTranslationDTO>(cell, I18nTranslationDTO.KEY_PROVIDER);
+ cellList.setPageSize(30);
+ cellList.setEmptyListMessage(SafeHtmlUtils.fromTrustedString("<span style='padding: 10px; font-style: italic;'>Loading</span>"));
+ cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
+ cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
+ cellList.addHandler(new KeyPressHandler() {
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ if (event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_UP) {
+ } else if (event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_DOWN) {
+ }
+ }
+ }, KeyPressEvent.getType());
+ // Add a selection model so we can select cells.
+ final SingleSelectionModel<I18nTranslationDTO> selectionModel = new SingleSelectionModel<I18nTranslationDTO>(
+ I18nTranslationDTO.KEY_PROVIDER);
+ cellList.setSelectionModel(selectionModel);
+ cellList.setValueUpdater(new ValueUpdater<I18nTranslationDTO>() {
+ @Override
+ public void update(final I18nTranslationDTO value) {
+ // TODO Auto-generated method stub
+ }
+ });
+ selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
+ @Override
+ public void onSelectionChange(final SelectionChangeEvent event) {
+ translatorForm.setInfo(selectionModel.getSelectedObject());
+ }
+ });
+ cellList.sinkEvents(com.google.gwt.user.client.Event.KEYEVENTS);
+ // Create the UiBinder.
+ final Binder uiBinder = GWT.create(Binder.class);
+ initWidget(uiBinder.createAndBindUi(this));
+ translatorForm.init(data, i18n, cellList);
+ data.addDataDisplay(cellList);
+
+ // Set the cellList as the display of the pagers.
+ // pagerPanel is a scrollable pager that extends the range when the
+ // user scrolls to the bottom. rangeLabelPager is a pager that displays the
+ // current range, but does not have any controls to change the range.
+ pagerPanel.setDisplay(cellList);
+ // pagerPanel.setStyleName("k-i18n-trans-list");
+ rangeLabelPager.setDisplay(cellList);
+ }
+
+ public void setLanguage(final I18nLanguageSimpleDTO language, final boolean toTranslate) {
+ data.setLanguage(language, toTranslate);
+ translatorForm.setToLanguage(language);
+ }
+}
Copied: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml (from rev 1501, trunk/src/main/java/cc/kune/gspace/client/i18n/CwCellList.ui.xml)
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.ui.xml 2011-09-05 16:05:15 UTC (rev 1509)
@@ -0,0 +1,46 @@
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:c='urn:import:com.google.gwt.user.cellview.client'
+ xmlns:s="urn:import:cc.kune.gspace.client.i18n">
+
+ <ui:style>
+ .table {
+ border: 1px solid #ccc;
+ padding: 20px;
+ height: 180px;
+ }
+
+ .scrollable {
+ height: 240px;
+ width: 260px;
+ border: 1px solid #ccc;
+ text-align: left;
+ margin: 5px;
+ }
+
+ .formCell {
+ padding-left: 10px;
+ }
+ </ui:style>
+
+ <g:HTMLPanel>
+ <table class="{style.table}">
+ <tr>
+ <td valign='top' align='center'>
+ <s:ShowMorePagerPanel addStyleNames='{style.scrollable}'
+ ui:field='pagerPanel'/>
+ <s:RangeLabelPager ui:field='rangeLabelPager'/>
+ </td>
+ <td class='{style.formCell}' valign='top' align='center'>
+ <s:I18nTranslatorForm ui:field='translatorForm'/>
+ <br/>
+ </td>
+ </tr>
+ <tr>
+ <td align='center'>
+ <s:ShowMorePagerPanel ui:field='pager'/>
+ </td>
+ </tr>
+ </table>
+ </g:HTMLPanel>
+</ui:UiBinder>
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -2,18 +2,21 @@
import cc.kune.common.client.notify.NotifyLevelImages;
import cc.kune.common.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel;
-import cc.kune.core.shared.dto.I18nLanguageDTO;
+import cc.kune.common.client.utils.SimpleCallback;
+import cc.kune.core.client.resources.CoreResources;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.i18n.I18nTranslationService;
import cc.kune.gspace.client.i18n.I18nNewTranslatorPresenter.I18nNewTranslatorView;
+import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.google.inject.Inject;
public class I18nNewTranslatorPanel extends AbstractTabbedDialogPanel implements I18nNewTranslatorView {
- private static final int HEIGHT = 400;
+ private static final int HEIGHT = 200;
private static final String TRANSLATOR_ERROR_ID = "i18n-trans-panel-error";
private static final String TRANSLATOR_PANEL_ID = "i18n-trans-panel";
- private static final int WIDTH = 400;
+ private static final int WIDTH = 570;
private final LanguageSelectorPanel lanSelectorPanel;
private final I18nToTranslateGridPanel toTranslateGrid;
private final I18nTranslatedGridPanel translatedGrid;
@@ -23,18 +26,28 @@
public I18nNewTranslatorPanel(final I18nTranslationService i18n, final NotifyLevelImages images,
final TranslatorTabsCollection transGroup, final LanguageSelectorPanel lanSelectorPanel,
final I18nToTranslateGridPanel toTranslateGrid, final I18nTranslatedGridPanel translatedGrid,
- final I18nTranslateRecomendPanel transRecommend) {
+ final I18nTranslateRecomendPanel transRecommend, final CoreResources res) {
super(TRANSLATOR_PANEL_ID, "", WIDTH, HEIGHT + 80, false, false, images, TRANSLATOR_ERROR_ID,
i18n.t("Close"), null, null, null, transGroup);
+ setIcon(res.language());
this.lanSelectorPanel = lanSelectorPanel;
+ lanSelectorPanel.addChangeListener(new SimpleCallback() {
+
+ @Override
+ public void onCallback() {
+ setLanguage(lanSelectorPanel.getLanguage());
+ }
+ });
this.toTranslateGrid = toTranslateGrid;
this.translatedGrid = translatedGrid;
this.transRecommend = transRecommend;
+ transRecommend.setSize(String.valueOf(WIDTH), String.valueOf(HEIGHT));
super.setIconCls("k-options-icon");
super.setTitle(i18n.t("Help to translate kune"));
super.getInnerPanel().insert(lanSelectorPanel, 0);
- lanSelectorPanel.setLangTitle(i18n.t(""));
- lanSelectorPanel.setLangSeparator("");
+ lanSelectorPanel.setLangTitle(i18n.t("to"));
+ lanSelectorPanel.setLabelAlign(LabelAlign.RIGHT);
+ lanSelectorPanel.setLangSeparator(":");
}
@Override
@@ -45,8 +58,10 @@
}
@Override
- public void setLanguage(final I18nLanguageDTO currentLanguage) {
- lanSelectorPanel.setLanguage(currentLanguage.getCode());
+ public void setLanguage(final I18nLanguageSimpleDTO language) {
+ lanSelectorPanel.setLanguage(language);
+ toTranslateGrid.setLanguage(language);
+ translatedGrid.setLanguage(language);
}
@Override
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPresenter.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nNewTranslatorPresenter.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -7,6 +7,7 @@
import cc.kune.core.client.rpcservices.I18nServiceAsync;
import cc.kune.core.client.state.Session;
import cc.kune.core.shared.dto.I18nLanguageDTO;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.IsWidget;
@@ -23,7 +24,7 @@
void init();
- void setLanguage(I18nLanguageDTO currentLanguage);
+ void setLanguage(I18nLanguageSimpleDTO currentLanguage);
@Override
void show();
@@ -84,12 +85,12 @@
public void show() {
NotifyUser.showProgressLoading();
if (session.isLogged()) {
- view.setLanguage(session.getCurrentLanguage());
+ final I18nLanguageDTO userLang = session.getCurrentLanguage();
+ view.setLanguage(new I18nLanguageSimpleDTO(userLang.getCode(), userLang.getEnglishName()));
view.show();
} else {
NotifyUser.info(i18n.t("Sign in or register to help with the translation"));
}
NotifyUser.hideProgress();
}
-
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nToTranslateGridPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -1,6 +1,6 @@
package cc.kune.gspace.client.i18n;
-import cc.kune.common.client.utils.TextUtils;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.i18n.I18nTranslationService;
import com.google.gwt.user.client.ui.Composite;
@@ -10,16 +10,21 @@
public class I18nToTranslateGridPanel extends Composite {
+ private final I18nCellList list;
private final Label tabTitle;
@Inject
- public I18nToTranslateGridPanel(final I18nTranslationService i18n) {
+ public I18nToTranslateGridPanel(final I18nTranslationService i18n, final I18nCellList list) {
+ this.list = list;
tabTitle = new Label(i18n.t("Untranslated"));
- initWidget(new Label(TextUtils.IN_DEVELOPMENT));
-
+ initWidget(list);
}
public IsWidget getTabTitle() {
return tabTitle;
}
+
+ public void setLanguage(final I18nLanguageSimpleDTO language) {
+ list.setLanguage(language, true);
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslateRecomendPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslateRecomendPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslateRecomendPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -10,12 +10,13 @@
public class I18nTranslateRecomendPanel extends Composite {
+ private final Frame recommFrame;
private final Label tabTitle;
@Inject
public I18nTranslateRecomendPanel(final I18nTranslationService i18n) {
tabTitle = new Label(i18n.t("Recommendations"));
- final Frame recommFrame = new Frame("i18n-recom.html");
+ recommFrame = new Frame("i18n-recom.html");
recommFrame.setHeight("auto");
recommFrame.setStyleName("k-i18n-recommend");
initWidget(recommFrame);
@@ -24,4 +25,10 @@
public IsWidget getTabTitle() {
return tabTitle;
}
+
+ @Override
+ public void setSize(final String width, final String height) {
+ recommFrame.setWidth(width + "px");
+ recommFrame.setHeight(height + "px");
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatedGridPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatedGridPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatedGridPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -1,6 +1,6 @@
package cc.kune.gspace.client.i18n;
-import cc.kune.common.client.utils.TextUtils;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.i18n.I18nTranslationService;
import com.google.gwt.user.client.ui.Composite;
@@ -10,16 +10,21 @@
public class I18nTranslatedGridPanel extends Composite {
+ private final I18nCellList list;
private final Label tabTitle;
@Inject
- public I18nTranslatedGridPanel(final I18nTranslationService i18n) {
+ public I18nTranslatedGridPanel(final I18nTranslationService i18n, final I18nCellList list) {
+ this.list = list;
tabTitle = new Label(i18n.t("Translated"));
- initWidget(new Label(TextUtils.IN_DEVELOPMENT));
-
+ initWidget(list);
}
public IsWidget getTabTitle() {
return tabTitle;
}
+
+ public void setLanguage(final I18nLanguageSimpleDTO language) {
+ list.setLanguage(language, false);
+ }
}
Added: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslationProvider.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package cc.kune.gspace.client.i18n;
+
+import java.util.List;
+
+import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
+import cc.kune.core.client.rpcservices.I18nServiceAsync;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+
+import com.google.gwt.user.cellview.client.CellList;
+import com.google.gwt.view.client.ListDataProvider;
+import com.google.inject.Inject;
+
+public class I18nTranslationProvider {
+
+ private final ListDataProvider<I18nTranslationDTO> dataProvider = new ListDataProvider<I18nTranslationDTO>();
+ private final I18nServiceAsync i18n;
+ private final Session session;
+
+ @Inject
+ private I18nTranslationProvider(final Session session, final I18nServiceAsync i18n) {
+ this.session = session;
+ this.i18n = i18n;
+ }
+
+ public void addDataDisplay(final CellList<I18nTranslationDTO> displayList) {
+ dataProvider.addDataDisplay(displayList);
+ }
+
+ public void refreshDisplays() {
+ dataProvider.refresh();
+ }
+
+ public void setLanguage(final I18nLanguageSimpleDTO language, final boolean toTranslate) {
+ dataProvider.getList().clear();
+ dataProvider.refresh();
+ i18n.getTranslatedLexicon(session.getUserHash(), language.getCode(), toTranslate,
+ new AsyncCallbackSimple<List<I18nTranslationDTO>>() {
+ @Override
+ public void onSuccess(final List<I18nTranslationDTO> result) {
+ dataProvider.setList(result);
+ dataProvider.refresh();
+ }
+ });
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -16,17 +16,23 @@
package cc.kune.gspace.client.i18n;
import cc.kune.common.client.tooltip.Tooltip;
+import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+import cc.kune.core.shared.i18n.I18nTranslationService;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.BlurEvent;
+import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.HasBlurHandlers;
-import com.google.gwt.event.dom.client.HasKeyPressHandlers;
+import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.cellview.client.CellList;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Widget;
@@ -40,36 +46,130 @@
private static Binder uiBinder = GWT.create(Binder.class);
+ private CellList<I18nTranslationDTO> cellList;
@UiField
- Image copyIcon;
+ PushButton copyIcon;
+ private I18nTranslationProvider dataProvider;
+ private I18nTranslationService i18n;
+ private I18nTranslationDTO item;
@UiField
+ Label keyboardRecomendation;
+ @UiField
+ Label keyboardRecomendationTitle;
+ private final Timer keyboardTimer;
+ @UiField
Label noteForTranslators;
@UiField
+ Label noteForTranslatorsTittle;
+ @UiField
+ Label toLanguageTitle;
+ @UiField
Label toTranslate;
+
@UiField
+ Label toTranslateTitle;
+
+ @UiField
TextArea translation;
public I18nTranslatorForm() {
initWidget(uiBinder.createAndBindUi(this));
- Tooltip.to(copyIcon, "FIXME");
+ keyboardTimer = new Timer() {
+ @Override
+ public void run() {
+ update();
+ }
+ };
}
- public HasBlurHandlers getBlurTraslation() {
- return translation;
+ private void copyTranslation() {
+ translation.setText(toTranslate.getText());
}
- public HasKeyPressHandlers getKeysTraslation() {
- return translation;
+ @UiHandler("translation")
+ void handleBlur(final BlurEvent event) {
+ update();
}
@UiHandler("copyIcon")
void handleClickOnCopyIcon(final ClickEvent e) {
- translation.setText(toTranslate.getText());
+ copyTranslation();
+ translation.setFocus(true);
+ updateWithTimer();
}
- public void setInfo(final String toTranslate, final String noteForTranslators, final String translation) {
- this.toTranslate.setText(toTranslate);
- this.noteForTranslators.setText(noteForTranslators);
- this.translation.setText(translation);
+ @UiHandler("translation")
+ void handleKeyPress(final ChangeEvent event) {
+ updateWithTimer();
}
+
+ @UiHandler("translation")
+ void handleKeyPress(final KeyPressEvent event) {
+ if (event.isControlKeyDown() && event.isAltKeyDown()
+ && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_UP) {
+ cellList.fireEvent(event);
+ }
+ if (event.isControlKeyDown() && event.isAltKeyDown()
+ && event.getNativeEvent().getKeyCode() == com.google.gwt.event.dom.client.KeyCodes.KEY_DOWN) {
+ cellList.fireEvent(event);
+ }
+ if (event.isAltKeyDown() && event.getCharCode() == 'v') {
+ copyTranslation();
+ event.stopPropagation();
+ }
+ updateWithTimer();
+ }
+
+ public void init(final I18nTranslationProvider dataProvider, final I18nTranslationService i18n,
+ final CellList<I18nTranslationDTO> cellList) {
+ this.dataProvider = dataProvider;
+ this.i18n = i18n;
+ this.cellList = cellList;
+ Tooltip.to(copyIcon, i18n.t("Copy the text to translate"));
+ toTranslateTitle.setText(i18n.t("translate this:"));
+ noteForTranslatorsTittle.setText(i18n.t("Notes:"));
+ keyboardRecomendationTitle.setText(i18n.t("Tip:"));
+ keyboardRecomendation.setText(i18n.t("Pulse TAB/Shift-TAB to move from the list to the translation area, and use the cursor to move bettween list elements. Alt-V to copy the original text. The translations are autosaved"));
+ }
+
+ public void setInfo(final I18nTranslationDTO item) {
+ this.item = item;
+ final String[] splitted = splitNT(item.getTrKey());
+ toTranslate.setText(splitted[0]);
+ final boolean hasNT = splitted.length > 1;
+ noteForTranslators.setVisible(hasNT);
+ noteForTranslatorsTittle.setVisible(hasNT);
+ if (hasNT) {
+ noteForTranslators.setText(splitted[1]);
+ }
+ translation.setText(item.getText());
+ }
+
+ public void setToLanguage(final I18nLanguageSimpleDTO language) {
+ toLanguageTitle.setText(i18n.tWithNT("to [%s]:", "For example, 'to Spanish':",
+ language.getEnglishName()));
+ }
+
+ private String[] splitNT(final String textWithNT) {
+ String[] nt;
+ final String[] splitted = textWithNT.split(" \\[%NT ");
+ if (splitted.length > 1) {
+ nt = splitted[1].split("\\]$");
+ splitted[1] = nt[0];
+ }
+ return splitted;
+ }
+
+ private void update() {
+ if (item != null) {
+ item.setText(translation.getText());
+ item.setDirty(true);
+ dataProvider.refreshDisplays();
+ }
+ }
+
+ private void updateWithTimer() {
+ keyboardTimer.cancel();
+ keyboardTimer.schedule(3000);
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.ui.xml 2011-09-05 16:05:15 UTC (rev 1509)
@@ -4,7 +4,7 @@
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateLocales='default'>
- <ui:with field='res' type='cc.kune.core.client.resources.CoreResources' />
+ <ui:with field='res' type='cc.kune.core.client.resources.CoreResources'/>
<ui:style>
.titles {
@@ -20,6 +20,13 @@
.copyicon {
vertical-align: top;
+ height: 10px !important;
+ -webkit-border-bottom-right-radius: 5px;
+ -moz-border-radius-bottomright: 5px;
+ border-bottom-right-radius: 5px;
+ -webkit-border-bottom-left-radius: 5px;
+ -moz-border-radius-bottomleft: 5px;
+ border-bottom-left-radius: 5px;
}
.row {
@@ -29,26 +36,59 @@
.cell {
display: table-cell;
- margin: 5px;
+ padding: 5px;
}
+
+ .tip {
+ width: 180px;
+ padding: 5px;
+ font-size: 9px;
+ vertical-align: top;
+ }
+
+ .toTranslate {
+ width: 180px;
+ height: 95px;
+ border: 1px dashed #BBBBBB;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ padding: 3px;
+ }
</ui:style>
<g:FlowPanel addStyleNames="{style.table}">
<g:FlowPanel addStyleNames="{style.row}">
- <g:Label ui:field="toTranslateTitle" addStyleNames="{style.titles} {style.cell}"
- text="translate this:" />
- <g:Label ui:field="toTranslate" addStyleNames="{style.cell}" />
+ <g:Label ui:field="toTranslateTitle" addStyleNames="{style.titles} {style.cell}"/>
+ <g:FlowPanel addStyleNames="{style.cell}" styleName="{style.toTranslate}">
+ <g:Label ui:field="toTranslate"/>
+ </g:FlowPanel>
+ <g:Label addStyleNames="{style.row}"/>
</g:FlowPanel>
<g:FlowPanel addStyleNames="{style.row}">
- <g:Label ui:field="toLanguageTitle" addStyleNames="{style.titles} {style.cell}"
- text="to Spanish:" />
- <g:TextArea ui:field='translation' addStyleNames="{style.cell}" />
- <g:Image ui:field="copyIcon" addStyleNames="{style.cell} {style.copyicon}"
- resource='{res.arrowUndo}' />
+ <g:Label ui:field="toLanguageTitle" addStyleNames="{style.titles} {style.cell}"/>
+ <g:TextArea ui:field='translation' addStyleNames="{style.cell}"
+ visibleLines="5"/>
+ <g:FlowPanel styleName="k-button"
+ addStyleNames="{style.cell} {style.copyicon} k-button k-btn k-5corners">
+ <g:PushButton ui:field='copyIcon' enabled='true'>
+ <g:upFace image='{res.arrowUndo}'/>
+ <g:upHoveringFace/>
+ <g:downFace/>
+ <g:downHoveringFace/>
+ </g:PushButton>
+ </g:FlowPanel>
</g:FlowPanel>
<g:FlowPanel addStyleNames="{style.row}">
- <g:Label ui:field="noteForTranslatorsTittle" text="Note:"
- addStyleNames="{style.titles} {style.cell}" />
- <g:Label ui:field="noteForTranslators" addStyleNames="{style.cell}" />
+ <g:Label ui:field="noteForTranslatorsTittle" visible="false"
+ addStyleNames="{style.titles} {style.cell}"/>
+ <g:Label ui:field="noteForTranslators" addStyleNames="{style.cell}"/>
+ <g:Label addStyleNames="{style.row}"/>
</g:FlowPanel>
+ <g:FlowPanel addStyleNames="{style.row}">
+ <g:Label ui:field="keyboardRecomendationTitle"
+ addStyleNames="{style.titles} {style.cell}"/>
+ <g:Label ui:field="keyboardRecomendation" addStyleNames="{style.cell} {style.tip}"/>
+ <g:Label addStyleNames="{style.row}"/>
+ </g:FlowPanel>
</g:FlowPanel>
</ui:UiBinder>
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -19,6 +19,7 @@
*/
package cc.kune.gspace.client.i18n;
+import cc.kune.common.client.errors.UIException;
import cc.kune.common.client.utils.SimpleCallback;
import cc.kune.core.client.state.Session;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
@@ -115,6 +116,16 @@
return list;
}
+ public I18nLanguageSimpleDTO getLanguage() {
+ final String langCode = langCombo.getValue().getCode();
+ for (final I18nLanguageSimpleDTO lang : session.getLanguages()) {
+ if (lang.getCode().equals(langCode)) {
+ return lang;
+ }
+ }
+ throw new UIException("Languege not found");
+ }
+
public String getLanguageCode() {
return langCombo.getValue().getCode();
}
@@ -142,7 +153,7 @@
}
}
- public void setLanguage(final String languageCode) {
- langCombo.setRawValue(languageCode);
+ public void setLanguage(final I18nLanguageSimpleDTO language) {
+ langCombo.setRawValue(language.getEnglishName());
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nTranslatorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nTranslatorPanel.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/I18nTranslatorPanel.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -292,7 +292,7 @@
}
private void setLanguage(final I18nLanguageDTO language) {
- languageSelectorPanel.setLanguage(language.getCode());
+ // languageSelectorPanel.setLanguage(language.getCode());
setLanguage(language.getCode());
}
Modified: trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java 2011-09-02 12:57:22 UTC (rev 1508)
+++ trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java 2011-09-05 16:05:15 UTC (rev 1509)
@@ -30,9 +30,6 @@
import org.junit.Test;
import cc.kune.core.server.PersistenceTest;
-import cc.kune.core.server.manager.I18nCountryManager;
-import cc.kune.core.server.manager.I18nLanguageManager;
-import cc.kune.core.server.manager.I18nTranslationManager;
import cc.kune.core.shared.i18n.I18nTranslationService;
import cc.kune.domain.I18nCountry;
import cc.kune.domain.I18nLanguage;
@@ -41,139 +38,145 @@
import com.google.inject.Inject;
public class I18nManagerDefaultTest extends PersistenceTest {
- @Inject
- I18nTranslationManager translationManager;
- @Inject
- I18nCountryManager countryManager;
- @Inject
- I18nLanguageManager languageManager;
- @Inject
- I18nTranslationService translationService;
+ @Inject
+ I18nCountryManager countryManager;
+ @Inject
+ I18nLanguageManager languageManager;
+ @Inject
+ I18nTranslationManager translationManager;
+ @Inject
+ I18nTranslationService translationService;
- @Test
- public void byDefaultUseEnglish() {
- HashMap<String, String> map = translationManager.getLexicon("en");
- HashMap<String, String> map2 = translationManager.getLexicon("af");
- assertEquals(map.size(), map2.size());
- }
+ @Test
+ public void byDefaultUseEnglish() {
+ final HashMap<String, String> map = translationManager.getLexicon("en");
+ final HashMap<String, String> map2 = translationManager.getLexicon("af");
+ assertEquals(map.size(), map2.size());
+ }
- @After
- public void close() {
- if (getTransaction().isActive()) {
- getTransaction().rollback();
- }
+ @After
+ public void close() {
+ if (getTransaction().isActive()) {
+ getTransaction().rollback();
}
+ }
- @Test
- public void getNonExistentTranslationInAnyLangReturnsKey() {
- HashMap<String, String> map = translationManager.getLexicon("en");
- HashMap<String, String> map2 = translationManager.getLexicon("aa");
- int initialSize = map.size();
- int initialSize2 = map2.size();
+ @Test
+ public void getLexiconList() {
+ assertTrue(translationManager.getTranslatedLexicon("en").size() > 0);
+ assertTrue(translationManager.getUntranslatedLexicon("en").size() == 0);
+ }
- String translation = translationManager.getTranslation("es", "Foo foo foo");
- String translation2 = translationManager.getTranslation("aa", "Foo foo foo");
+ @Test
+ public void getNonExistentTranslationInAnyLangReturnsKey() {
+ HashMap<String, String> map = translationManager.getLexicon("en");
+ HashMap<String, String> map2 = translationManager.getLexicon("aa");
+ final int initialSize = map.size();
+ final int initialSize2 = map2.size();
- assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation);
- assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation2);
+ final String translation = translationManager.getTranslation("es", "Foo foo foo");
+ final String translation2 = translationManager.getTranslation("aa", "Foo foo foo");
- map = translationManager.getLexicon("en");
- map2 = translationManager.getLexicon("aa");
- int newSize = map.size();
- int newSize2 = map2.size();
+ assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation);
+ assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation2);
- assertEquals(initialSize + 1, newSize);
- assertEquals(initialSize2 + 1, newSize2);
- }
+ map = translationManager.getLexicon("en");
+ map2 = translationManager.getLexicon("aa");
+ final int newSize = map.size();
+ final int newSize2 = map2.size();
- @Test
- public void getNonExistentTranslationReturnsDefaultLanguage() {
- String translation = translationManager.getTranslation("af", "January [month]");
- assertEquals("January", translation);
- }
+ assertEquals(initialSize + 1, newSize);
+ assertEquals(initialSize2 + 1, newSize2);
+ }
- @Test
- public void getTranslation() {
- String translation = translationManager.getTranslation("af", "Sunday [weekday]");
- assertEquals("Sondag", translation);
- }
+ @Test
+ public void getNonExistentTranslationReturnsDefaultLanguage() {
+ final String translation = translationManager.getTranslation("af", "January [month]");
+ assertEquals("January", translation);
+ }
- @Test
- public void getTranslationUTF8() {
- String translation = translationManager.getTranslation("el", "January [month]");
- assertEquals("Ιανουάριος", translation);
- }
+ @Test
+ public void getTranslation() {
+ final String translation = translationManager.getTranslation("af", "Sunday [weekday]");
+ assertEquals("Sondag", translation);
+ }
- @Test
- public void getTranslationWithIntArg() {
- String translation = translationManager.getTranslation("en", "[%d] users", 20);
- assertEquals("20 users", translation);
- }
+ @Test
+ public void getTranslationUTF8() {
+ final String translation = translationManager.getTranslation("el", "January [month]");
+ assertEquals("Ιανουάριος", translation);
+ }
- @Test
- public void getTranslationWithIntArgFromService() {
- String translation = translationService.t("[%d] users", 20);
- assertEquals("20 users", translation);
- }
+ @Test
+ public void getTranslationWithIntArg() {
+ final String translation = translationManager.getTranslation("en", "[%d] users", 20);
+ assertEquals("20 users", translation);
+ }
- @Test
- public void getTranslationWithIntArgFromWithNtService() {
- String translation = translationService.tWithNT("[%d] users", "foo foo", 20);
- assertEquals("20 users", translation);
- }
+ @Test
+ public void getTranslationWithIntArgFromService() {
+ final String translation = translationService.t("[%d] users", 20);
+ assertEquals("20 users", translation);
+ }
- @Test
- public void getTranslationWithStringArg() {
- String translation = translationManager.getTranslation("en", "[%s] users", "Twenty");
- assertEquals("Twenty users", translation);
- }
+ @Test
+ public void getTranslationWithIntArgFromWithNtService() {
+ final String translation = translationService.tWithNT("[%d] users", "foo foo", 20);
+ assertEquals("20 users", translation);
+ }
- @Test
- public void getTranslationWithStringArgFromService() {
- String translation = translationService.t("[%s] users", "Twenty");
- assertEquals("Twenty users", translation);
- }
+ @Test
+ public void getTranslationWithStringArg() {
+ final String translation = translationManager.getTranslation("en", "[%s] users", "Twenty");
+ assertEquals("Twenty users", translation);
+ }
- @Test
- public void getTranslationWithStringArgWithNtFromService() {
- String translation = translationService.tWithNT("[%s] users", "foo foo", "Twenty");
- assertEquals("Twenty users", translation);
- }
+ @Test
+ public void getTranslationWithStringArgFromService() {
+ final String translation = translationService.t("[%s] users", "Twenty");
+ assertEquals("Twenty users", translation);
+ }
- @Before
- public void insertData() {
- openTransaction();
- I18nLanguage english = new I18nLanguage(Long.valueOf(1819), "English", "English", "en");
- I18nLanguage spanish = new I18nLanguage(Long.valueOf(5889), "Spanish", "Español", "es");
- I18nLanguage afrikaans = new I18nLanguage(Long.valueOf(114), "Afrikaans", "Afrikaans", "af");
- I18nLanguage greek = new I18nLanguage(Long.valueOf(1793), "Greek", "Ελληνικά", "el");
- languageManager.persist(english);
- languageManager.persist(spanish);
- languageManager.persist(afrikaans);
- languageManager.persist(greek);
- translationManager.persist(new I18nTranslation("Sunday [weekday]", english, "Sunday"));
- translationManager.persist(new I18nTranslation("January [month]", english, "January"));
- translationManager.persist(new I18nTranslation("Sunday [weekday]", afrikaans, "Sondag"));
- translationManager.persist(new I18nTranslation("January [month]", greek, "Ιανουάριος"));
- translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%s] users"), english,
- StringEscapeUtils.escapeHtml("[%s] users")));
- translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%d] users"), english,
- StringEscapeUtils.escapeHtml("[%d] users")));
- I18nCountry gb = new I18nCountry(Long.valueOf(75), "GB", "GBP", ".", "£%n", "", ".", "United Kingdom",
- "western", ",");
- countryManager.persist(gb);
- }
+ @Test
+ public void getTranslationWithStringArgWithNtFromService() {
+ final String translation = translationService.tWithNT("[%s] users", "foo foo", "Twenty");
+ assertEquals("Twenty users", translation);
+ }
- @Test
- public void setTranslation() {
- translationManager.setTranslation("en", "Foo foo foo", "Foo foo foo translation");
- String translation = translationManager.getTranslation("en", "Foo foo foo");
- assertEquals("Foo foo foo translation", translation);
- }
+ @Before
+ public void insertData() {
+ openTransaction();
+ final I18nLanguage english = new I18nLanguage(Long.valueOf(1819), "English", "English", "en");
+ final I18nLanguage spanish = new I18nLanguage(Long.valueOf(5889), "Spanish", "Español", "es");
+ final I18nLanguage afrikaans = new I18nLanguage(Long.valueOf(114), "Afrikaans", "Afrikaans", "af");
+ final I18nLanguage greek = new I18nLanguage(Long.valueOf(1793), "Greek", "Ελληνικά", "el");
+ languageManager.persist(english);
+ languageManager.persist(spanish);
+ languageManager.persist(afrikaans);
+ languageManager.persist(greek);
+ translationManager.persist(new I18nTranslation("Sunday [weekday]", english, "Sunday"));
+ translationManager.persist(new I18nTranslation("January [month]", english, "January"));
+ translationManager.persist(new I18nTranslation("Sunday [weekday]", afrikaans, "Sondag"));
+ translationManager.persist(new I18nTranslation("January [month]", greek, "Ιανουάριος"));
+ translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%s] users"), english,
+ StringEscapeUtils.escapeHtml("[%s] users")));
+ translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%d] users"), english,
+ StringEscapeUtils.escapeHtml("[%d] users")));
+ final I18nCountry gb = new I18nCountry(Long.valueOf(75), "GB", "GBP", ".", "£%n", "", ".",
+ "United Kingdom", "western", ",");
+ countryManager.persist(gb);
+ }
- @Test
- public void testGetLexicon() {
- HashMap<String, String> map = translationManager.getLexicon("af");
- assertTrue(map.size() > 0);
- }
+ @Test
+ public void setTranslation() {
+ translationManager.setTranslation("en", "Foo foo foo", "Foo foo foo translation");
+ final String translation = translationManager.getTranslation("en", "Foo foo foo");
+ assertEquals("Foo foo foo translation", translation);
+ }
+
+ @Test
+ public void testGetLexicon() {
+ final HashMap<String, String> map = translationManager.getLexicon("af");
+ assertTrue(map.size() > 0);
+ }
}
More information about the kune-commits
mailing list