[kune-commits] r1521 - in trunk: . script src/main/java/cc/kune/core/client/i18n src/main/java/cc/kune/core/client/rpcservices src/main/java/cc/kune/core/server/i18n src/main/java/cc/kune/core/server/init src/main/java/cc/kune/core/server/manager src/main/java/cc/kune/core/server/manager/impl src/main/java/cc/kune/core/server/rest src/main/java/cc/kune/core/server/rpc src/main/java/cc/kune/core/shared/dto src/main/java/cc/kune/core/shared/i18n src/main/java/cc/kune/domain src/main/java/cc/kune/domain/finders src/main/java/cc/kune/gspace/client/i18n src/main/java/cc/kune/gspace/client/ui/footer/license src/main/resources src/main/resources/db src/test/java/cc/kune/core/client/i18n src/test/java/cc/kune/core/server/manager
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Mon Sep 19 15:00:40 CEST 2011
Author: vjrj_
Date: 2011-09-19 15:00:39 +0200 (Mon, 19 Sep 2011)
New Revision: 1521
Added:
trunk/script/convertI18nMsgToMethods.sh
trunk/script/i18n-db2gwt.sh
trunk/src/main/java/cc/kune/core/client/i18n/I18nConvertMethodName.java
trunk/src/main/java/cc/kune/gspace/client/i18n/AbstractLanguageSelectorPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorWithoutEnglishPanel.java
trunk/src/main/resources/db/update-0017-i18nclean2.sql
Modified:
trunk/TODO
trunk/src/main/java/cc/kune/core/client/i18n/I18nTranslationServiceMocked.java
trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
trunk/src/main/java/cc/kune/core/client/i18n/I18nUtils.java
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/server/i18n/I18nTranslationServiceDefault.java
trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java
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/rest/I18nTranslationJSONService.java
trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java
trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java
trunk/src/main/java/cc/kune/core/shared/i18n/I18nTranslationService.java
trunk/src/main/java/cc/kune/domain/I18nTranslation.java
trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java
trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java
trunk/src/main/java/cc/kune/gspace/client/ui/footer/license/EntityLicensePanel.java
trunk/src/main/resources/db/liquibase_changelog.xml
trunk/src/main/resources/kune.properties
trunk/src/test/java/cc/kune/core/client/i18n/I18nUtilsTest.java
trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java
Log:
NEW - # 79: I18n refactorization
http://kune.ourproject.org/issues/ticket/79
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/TODO 2011-09-19 13:00:39 UTC (rev 1521)
@@ -284,6 +284,23 @@
2007-12-21 10:35:16,197 [btpool0-5] DEBUG - ContentManagerDefault.createContent EXCEPTION => javax.persistence.Entity
** vjrj <v> IconHyperlink.java and IconLabel.java to gwt1.5
+** Memory use in demo
+http://rimuhosting.com/howto/memory.jsp
+Resolving: High Java Memory Usage
+
+Java processes can often consume more memory than any other application running on a server.
+
+Java processes can be passed a -Xmx option. This controls the maximum Java memory heap size. It is important to set a limit on the heap size, otherwise the heap will keep increasing until you get out of memory errors on your VPS (resulting in the Java process - or even some other, random, process - dying.
+
+Usually the setting can be found in your /usr/local/jboss/bin/run.conf or /usr/local/tomcat/bin/setenv.sh config files. And your RimuHosting default install should have a reasonable value in there already.
+
+If you are running a custom Java application, check there is a -XmxNNm (where NN is a number of megabytes) option on the Java command line.
+
+The optimal -Xmx setting value will depend on what you are running. And how much memory is available on your server.
+
+From experience we have found that Tomcat often runs well with an -Xmx between 48m and 64m. JBoss will need a -Xmx of at least 96m to 128m. You can set the value higher. However, you should ensure that there is memory available on your server.
+
+To determine how much memory you can spare for Java, try this: stop your Java process; run free -m; subtract the 'used' value from the "-/+ cache" row from the total memory allocated to your server and then subtract another 'just in case' margin of about 10% of your total server memory. The number you come up with is a rough indicator of the largest -Xmx setting you can use on your server.
* MID-TERM
** Study mozilla web apps:
https://apps.mozillalabs.com/
Added: trunk/script/convertI18nMsgToMethods.sh
===================================================================
--- trunk/script/convertI18nMsgToMethods.sh (rev 0)
+++ trunk/script/convertI18nMsgToMethods.sh 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1 @@
+/usr/lib/jvm/java-6-openjdk/bin/java -Dfile.encoding=UTF-8 -classpath /home/vjrj/proyectos/dev/kune/trunk/target/test-classes:/home/vjrj/proyectos/dev/kune/trunk/target/kune-0.1.0-SNAPSHOT/WEB-INF/classes:/home/vjrj/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/vjrj/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/vjrj/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/vjrj/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/vjrj/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar:/home/vjrj/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/vjrj/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.3.1/appengine-api-1.0-sdk-1.3.1.jar:/home/vjrj/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar:/home/vjrj/.m2/repository/org/waveprotocol/box/0.3.1-SNAPSHOT/box-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/box-src/0.3.1-SNAPSHOT/box-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/home/vjrj/.m2/repository/c3p0/c3p0/0.9.1/c3p0-0.9.1.jar:/home/vjrj/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar:/home/vjrj/.m2/repository/org/waveprotocol/client/0.3.1-SNAPSHOT/client-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/client-common/0.3.1-SNAPSHOT/client-common-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/client-common-src/0.3.1-SNAPSHOT/client-common-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/client-scheduler-src/0.3.1-SNAPSHOT/client-scheduler-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/client-src/0.3.1-SNAPSHOT/client-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/cobogw/gwt/cobogw/1.3.1/cobogw-1.3.1.jar:/home/vjrj/.m2/repository/org/waveprotocol/common-src/0.3.1-SNAPSHOT/common-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar:/home/vjrj/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/vjrj/.m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar:/home/vjrj/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar:/home/vjrj/.m2/repository/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar:/home/vjrj/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:/home/vjrj/.m2/repository/commons-io/commons-io/1.3.1/commons-io-1.3.1.jar:/home/vjrj/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5.jar:/home/vjrj/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar:/home/vjrj/.m2/repository/org/waveprotocol/communication-src/0.3.1-SNAPSHOT/communication-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/waveprotocol/concurrencycontrol-src/0.3.1-SNAPSHOT/concurrencycontrol-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/net/sourceforge/htmlunit/crawl_htmlunit/r5662-gae/crawl_htmlunit-r5662-gae.jar:/home/vjrj/.m2/repository/net/sourceforge/cssparser/cssparser/0.9.5/cssparser-0.9.5.jar:/home/vjrj/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/vjrj/.m2/repository/net/sf/dozer/dozer/4.0/dozer-4.0.jar:/home/vjrj/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar:/home/vjrj/.m2/repository/com/calclab/emite/emite/r1694/emite-r1694.jar:/home/vjrj/.m2/repository/com/calclab/emite/emite-proxy/0.1/emite-proxy-0.1.jar:/home/vjrj/.m2/repository/net/sf/ezmorph/ezmorph/1.0.3/ezmorph-1.0.3.jar:/home/vjrj/.m2/repository/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar:/home/vjrj/.m2/repository/com/google/guava/guava-gwt/r09/guava-gwt-r09.jar:/home/vjrj/.m2/repository/com/google/inject/guice/3.0/guice-3.0.jar:/home/vjrj/.m2/repository/com/google/inject/extensions/guice-assisted-inject/2.0/guice-assisted-inject-2.0.jar:/home/vjrj/.m2/repository/com/google/inject/extensions/guice-persist/3.0/guice-persist-3.0.jar:/home/vjrj/.m2/repository/com/google/inject/extensions/guice-servlet/3.0/guice-servlet-3.0.jar:/home/vjrj/.m2/repository/com/allen_sauer/gwt/dnd/gwt-dnd/gwt-dnd/3.0.1/gwt-dnd-3.0.1.jar:/home/vjrj/.m2/repository/org/adamtacy/gwt-fx/r464/gwt-fx-r464.jar:/home/vjrj/.m2/repository/com/google/gwt/gwt-gin/1.0-r137/gwt-gin-1.0-r137.jar:/home/vjrj/.m2/repository/com/allen_sauer/gwt/log/gwt-log/gwt-log/3.0.1/gwt-log-3.0.1.jar:/home/vjrj/.m2/repository/com/google/gwt/gwt-servlet/2.1.1/gwt-servlet-2.1.1.jar:/home/vjrj/.m2/repository/com/google/gwt/gwt-user/2.1.1/gwt-user-2.1.1.jar:/home/vjrj/.m2/repository/org/waveprotocol/gwt-util-src/0.3.1-SNAPSHOT/gwt-util-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/com/allen_sauer/gwt/voices/gwt-voices/gwt-voices/2.0.0/gwt-voices-2.0.0.jar:/home/vjrj/.m2/repository/com/gwtext/gwtext/2.0.5/gwtext-2.0.5.jar:/home/vjrj/.m2/repository/com/gwtextux/gwtextux/0.4.0.924/gwtextux-0.4.0.924.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-all/0.5/gwtp-all-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-clients-common/0.5/gwtp-clients-common-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-crawler/0.5/gwtp-crawler-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-dispatch-client/0.5/gwtp-dispatch-client-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-dispatch-server/0.5/gwtp-dispatch-server-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-dispatch-shared/0.5/gwtp-dispatch-shared-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-mvp-client/0.5/gwtp-mvp-client-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-processors/0.5/gwtp-processors-0.5.jar:/home/vjrj/.m2/repository/com/gwtplatform/gwtp-tester/0.5/gwtp-tester-0.5.jar:/home/vjrj/.m2/repository/com/googlecode/gwtupload/gwtupload/0.6.3-compat/gwtupload-0.6.3-compat.jar:/home/vjrj/.m2/repository/com/extjs/gxt/2.2.1/gxt-2.2.1.jar:/home/vjrj/.m2/repository/com/h2database/h2/1.0.20070617/h2-1.0.20070617.jar:/home/vjrj/.m2/repository/com/calclab/emite/hablar/r1697/hablar-r1697.jar:/home/vjrj/.m2/repository/org/hamcrest/hamcrest-all/1.1/hamcrest-all-1.1.jar:/home/vjrj/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-c3p0/3.3.1.GA/hibernate-c3p0-3.3.1.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-search/3.1.0.GA/hibernate-search-3.1.0.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-tools/3.2.3.GA/hibernate-tools-3.2.3.GA.jar:/home/vjrj/.m2/repository/org/hibernate/hibernate-validator/3.1.0.GA/hibernate-validator-3.1.0.GA.jar:/home/vjrj/.m2/repository/net/sourceforge/htmlunit/htmlunit/2.7/htmlunit-2.7.jar:/home/vjrj/.m2/repository/net/sourceforge/htmlunit/htmlunit-core-js/2.7/htmlunit-core-js-2.7.jar:/home/vjrj/.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar:/home/vjrj/.m2/repository/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1.jar:/home/vjrj/.m2/repository/com/beust/jcommander/1.12/jcommander-1.12.jar:/home/vjrj/.m2/repository/org/codehaus/jettison/jettison/1.0-RC2/jettison-1.0-RC2.jar:/home/vjrj/.m2/repository/jmagick/jmagick/6.2.6-0/jmagick-6.2.6-0.jar:/home/vjrj/.m2/repository/net/java/dev/jna/jna/3.2.2/jna-3.2.2.jar:/home/vjrj/.m2/repository/org/jruby/jruby-complete/1.2.0/jruby-complete-1.2.0.jar:/home/vjrj/.m2/repository/org/jruby/rack/jruby-rack/0.9.4/jruby-rack-0.9.4.jar:/home/vjrj/.m2/repository/org/json/json/20080701/json-20080701.jar:/home/vjrj/.m2/repository/net/sf/json-lib/json-lib/2.1/json-lib-2.1-jdk15.jar:/home/vjrj/.m2/repository/org/jsoup/jsoup/1.2.2/jsoup-1.2.2.jar:/home/vjrj/.m2/repository/net/sourceforge/findbugs/jsr-305/v0r47/jsr-305-v0r47.jar:/home/vjrj/.m2/repository/org/hibernate/jtidy/r8-20060801/jtidy-r8-20060801.jar:/home/vjrj/.m2/repository/org/jukito/jukito/1.0/jukito-1.0.jar:/home/vjrj/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar:/home/vjrj/.m2/repository/org/liquibase/liquibase-core/1.8.1/liquibase-core-1.8.1.jar:/home/vjrj/.m2/repository/org/liquibase/liquibase-plugin/1.8.1.0/liquibase-plugin-1.8.1.0.jar:/home/vjrj/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar:/home/vjrj/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar:/home/vjrj/.m2/repository/org/apache/lucene/lucene-core/2.4.0/lucene-core-2.4.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-artifact-manager/2.0/maven-artifact-manager-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-model/2.0/maven-model-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-plugin-api/2.0/maven-plugin-api-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-profile/2.0/maven-profile-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-project/2.0/maven-project-2.0.jar:/home/vjrj/.m2/repository/org/apache/maven/maven-repository-metadata/2.0/maven-repository-metadata-2.0.jar:/home/vjrj/.m2/repository/org/waveprotocol/media-src/0.3.1-SNAPSHOT/media-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/mockito/mockito-core/1.8.5/mockito-core-1.8.5.jar:/home/vjrj/.m2/repository/org/waveprotocol/model-src/0.3.1-SNAPSHOT/model-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/mvel/mvel2/2.0.16/mvel2-2.0.16.jar:/home/vjrj/.m2/repository/mysql/mysql-connector-java/5.1.13/mysql-connector-java-5.1.13.jar:/home/vjrj/.m2/repository/net/sourceforge/nekohtml/nekohtml/1.9.14/nekohtml-1.9.14.jar:/home/vjrj/.m2/repository/org/objenesis/objenesis/1.0/objenesis-1.0.jar:/home/vjrj/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar:/home/vjrj/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar:/home/vjrj/.m2/repository/org/waveprotocol/proto-msg/0.3.1-SNAPSHOT/proto-msg-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/w3c/css/sac/1.3/sac-1.3.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium/2.0a4/selenium-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-chrome-driver/2.0a4/selenium-chrome-driver-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-common/2.0a4/selenium-common-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-firefox-driver/2.0a4/selenium-firefox-driver-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-htmlunit-driver/2.0a4/selenium-htmlunit-driver-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-ie-driver/2.0a4/selenium-ie-driver-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-remote-client/2.0a4/selenium-remote-client-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-remote-common/2.0a4/selenium-remote-common-2.0a4.jar:/home/vjrj/.m2/repository/org/seleniumhq/selenium/selenium-support/2.0a4/selenium-support-2.0a4.jar:/home/vjrj/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/home/vjrj/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar:/home/vjrj/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar:/home/vjrj/.m2/repository/jivesoftware/smack/3.1.0/smack-3.1.0.jar:/home/vjrj/.m2/repository/jivesoftware/smackx/3.1.0/smackx-3.1.0.jar:/home/vjrj/.m2/repository/org/jivesoftware/smackx/debugger/smackx-debugger/3.0.4/smackx-debugger-3.0.4.jar:/home/vjrj/.m2/repository/org/yaml/snakeyaml/1.6/snakeyaml-1.6.jar:/home/vjrj/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar:/home/vjrj/.m2/repository/org/testng/testng/6.0.1/testng-6.0.1.jar:/home/vjrj/.m2/repository/tigase/tigase-xmltools/3.3.5/tigase-xmltools-3.3.5.jar:/home/vjrj/.m2/repository/org/waveprotocol/util-src/0.3.1-SNAPSHOT/util-src-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-alpha-5/wagon-provider-api-1.0-alpha-5.jar:/home/vjrj/.m2/repository/org/waveprotocol/waveinabox-server-0.3/0.3.1-SNAPSHOT/waveinabox-server-0.3-0.3.1-SNAPSHOT.jar:/home/vjrj/.m2/repository/xalan/xalan/2.7.1/xalan-2.7.1.jar:/home/vjrj/.m2/repository/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar:/home/vjrj/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar:/home/vjrj/.m2/repository/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar:/home/vjrj/.m2/repository/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar:/home/vjrj/.m2/repository/org/xwiki/platform/xwiki-web-gwt-dom/2.3-rc-1/xwiki-web-gwt-dom-2.3-rc-1.jar:/home/vjrj/bin/eclipse64-hel-new/plugins/com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/gwt-user.jar:/home/vjrj/bin/eclipse64-hel-new/plugins/com.google.gwt.eclipse.sdkbundle.2.1.1_2.1.1.v201012170127/gwt-2.1.1/gwt-dev.jar cc.kune.core.client.i18n.I18nConvertMethodName $1
\ No newline at end of file
Property changes on: trunk/script/convertI18nMsgToMethods.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/script/i18n-db2gwt.sh
===================================================================
--- trunk/script/i18n-db2gwt.sh (rev 0)
+++ trunk/script/i18n-db2gwt.sh 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This script should generate from Kune strings db translations to GWT I18n .java resources
+
+usage() {
+ echo "Use: $0 -l langcode"
+ echo "$0 -l en"
+}
+
+while getopts “hl:” OPTION
+do
+ case $OPTION in
+ h)
+ usage
+ exit 1
+ ;;
+ l)
+ L=$OPTARG
+ ;;
+ ?)
+ usage
+ exit
+ ;;
+ esac
+done
+
+if [[ -z $L ]]
+then
+ usage
+ exit 1
+fi
+
+
+
Property changes on: trunk/script/i18n-db2gwt.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/src/main/java/cc/kune/core/client/i18n/I18nConvertMethodName.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nConvertMethodName.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nConvertMethodName.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1,16 @@
+package cc.kune.core.client.i18n;
+
+public class I18nConvertMethodName {
+
+ public static void main(final String... args) {
+ if (args.length == 0) {
+ System.err.print("Syntax: I18nConvertMethodName 'Some string message to convert'\n");
+ } else {
+ final StringBuffer buf = new StringBuffer();
+ for (final String arg : args) {
+ buf.append(arg).append(" ");
+ }
+ System.out.print(I18nUtils.convertMethodName(buf.toString()));
+ }
+ }
+}
Modified: trunk/src/main/java/cc/kune/core/client/i18n/I18nTranslationServiceMocked.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nTranslationServiceMocked.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nTranslationServiceMocked.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -23,9 +23,10 @@
import cc.kune.core.shared.i18n.I18nTranslationService;
public class I18nTranslationServiceMocked extends I18nTranslationService {
- public String t(final String text) {
- String encodeText = TextUtils.escapeHtmlLight(text);
- String translation = removeNT(encodeText);
- return decodeHtml(translation);
- }
+ @Override
+ public String tWithNT(final String text, final String noteForTranslators) {
+ final String encodeText = TextUtils.escapeHtmlLight(text);
+ final String translation = encodeText;
+ return decodeHtml(translation);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -38,190 +38,191 @@
import com.google.inject.Inject;
public class I18nUITranslationService extends I18nTranslationService {
- private I18nLanguageDTO currentLang;
- private String currentLanguageCode;
- private final I18nServiceAsync i18nService;
- private HashMap<String, String> lexicon;
- private final Session session;
+ private I18nLanguageDTO currentLang;
+ private String currentLanguageCode;
+ private final I18nServiceAsync i18nService;
+ private HashMap<String, String> lexicon;
+ private final Session session;
- @Inject
- public I18nUITranslationService(final Session session, final I18nServiceAsync i18nService, final EventBus eventBus) {
- this.session = session;
- this.i18nService = i18nService;
- final Location loc = WindowUtils.getLocation();
- final String locale = loc.getParameter("locale");
- i18nService.getInitialLanguage(locale, new AsyncCallback<I18nLanguageDTO>() {
- @Override
- public void onFailure(final Throwable caught) {
- Log.error("Workspace adaptation to your language failed: " + caught.getMessage());
- }
+ @Inject
+ public I18nUITranslationService(final Session session, final I18nServiceAsync i18nService,
+ final EventBus eventBus) {
+ this.session = session;
+ this.i18nService = i18nService;
+ final Location loc = WindowUtils.getLocation();
+ final String locale = loc.getParameter("locale");
+ i18nService.getInitialLanguage(locale, new AsyncCallback<I18nLanguageDTO>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ Log.error("Workspace adaptation to your language failed: " + caught.getMessage());
+ }
- @Override
- public void onSuccess(final I18nLanguageDTO result) {
- currentLang = result;
- currentLanguageCode = currentLang.getCode();
- session.setCurrentLanguage(currentLang);
- i18nService.getLexicon(currentLang.getCode(), new AsyncCallback<HashMap<String, String>>() {
- @Override
- public void onFailure(final Throwable caught) {
- Log.error("Workspace adaptation to your language failed:" + caught.getMessage());
- }
+ @Override
+ public void onSuccess(final I18nLanguageDTO result) {
+ currentLang = result;
+ currentLanguageCode = currentLang.getCode();
+ session.setCurrentLanguage(currentLang);
+ i18nService.getLexicon(currentLang.getCode(), new AsyncCallback<HashMap<String, String>>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ Log.error("Workspace adaptation to your language failed:" + caught.getMessage());
+ }
- @Override
- public void onSuccess(final HashMap<String, String> result) {
- lexicon = result;
- session.setCurrentLanguage(currentLang);
- eventBus.fireEvent(new I18nReadyEvent());
- }
- });
- }
+ @Override
+ public void onSuccess(final HashMap<String, String> result) {
+ lexicon = result;
+ session.setCurrentLanguage(currentLang);
+ eventBus.fireEvent(new I18nReadyEvent());
+ }
});
- }
+ }
+ });
+ }
- public void changeCurrentLanguage(final String newLanguage) {
- if (!newLanguage.equals(this.currentLanguageCode)) {
- setCurrentLanguage(newLanguage);
- changeLocale(newLanguage);
- }
+ public void changeCurrentLanguage(final String newLanguage) {
+ if (!newLanguage.equals(this.currentLanguageCode)) {
+ setCurrentLanguage(newLanguage);
+ changeLocale(newLanguage);
}
+ }
- /**
- *
- * See in:
- * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread
- * /5e4e25050d3be984/7035ec39354d06aa?lnk=gst&q=get+locale&rnum=23
- *
- * JSNI method to change the locale of the application - it effectively
- * parses the existing URL and creates a new one for the chosen locale.
- *
- * It additionally launches any JavaScript debugger that might be attached
- * to the system (Windows only). To disable this functionality just remove
- * the "debugger" line.
- *
- * @param newLocale
- * String value of the new locale to go to.
- */
- private native void changeLocale(String newLocale)
- /*-{
- // Uncomment the "debugger;" line to see how to set debug statements in JSNI code
- // When in web mode, if your browser has a JavaScript debugger attached, it will
- // launch at this point in the code (when the user changes locale through the menu system).
- // debugger;
+ /**
+ *
+ * See in:
+ * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread
+ * /5e4e25050d3be984/7035ec39354d06aa?lnk=gst&q=get+locale&rnum=23
+ *
+ * JSNI method to change the locale of the application - it effectively parses
+ * the existing URL and creates a new one for the chosen locale.
+ *
+ * It additionally launches any JavaScript debugger that might be attached to
+ * the system (Windows only). To disable this functionality just remove the
+ * "debugger" line.
+ *
+ * @param newLocale
+ * String value of the new locale to go to.
+ */
+ private native void changeLocale(String newLocale)
+ /*-{
+ // Uncomment the "debugger;" line to see how to set debug statements in JSNI code
+ // When in web mode, if your browser has a JavaScript debugger attached, it will
+ // launch at this point in the code (when the user changes locale through the menu system).
+ // debugger;
- // Get the current location
- var currLocation = $wnd.location.toString();
- // Get rid of any GWT History tokens that might be present
- var noHistoryCurrLocArray = currLocation.split("#");
- var noHistoryCurrLoc = noHistoryCurrLocArray[0];
- var currHistory = noHistoryCurrLocArray[1];
- // Get rid of any locale string
- var locArray = noHistoryCurrLoc.split("?");
- // Build the new href location and then send the browser there.
- // $wnd.location.href = locArray[0]+"?locale="+newLocale+"#"+currHistory;
- $wnd.location.href = locArray[0]+"?locale="+newLocale
+ // Get the current location
+ var currLocation = $wnd.location.toString();
+ // Get rid of any GWT History tokens that might be present
+ var noHistoryCurrLocArray = currLocation.split("#");
+ var noHistoryCurrLoc = noHistoryCurrLocArray[0];
+ var currHistory = noHistoryCurrLocArray[1];
+ // Get rid of any locale string
+ var locArray = noHistoryCurrLoc.split("?");
+ // Build the new href location and then send the browser there.
+ // $wnd.location.href = locArray[0]+"?locale="+newLocale+"#"+currHistory;
+ $wnd.location.href = locArray[0] + "?locale=" + newLocale
- // extjs part:
- // commented because the error: "Ext is not defined"
- // we have to try other way
- // var head = document.getElementsByTagName("head")[0];
- // var script = document.createElement('script');
- // script.id = 'localScript';
- // script.type = 'text/javascript';
- // script.src = "js/ext/locale/ext-lang-"+newLocale+".js";
- // head.appendChild(script);
- }-*/;
+ // extjs part:
+ // commented because the error: "Ext is not defined"
+ // we have to try other way
+ // var head = document.getElementsByTagName("head")[0];
+ // var script = document.createElement('script');
+ // script.id = 'localScript';
+ // script.type = 'text/javascript';
+ // script.src = "js/ext/locale/ext-lang-"+newLocale+".js";
+ // head.appendChild(script);
+ }-*/;
- public String formatDateWithLocale(final Date date) {
- return formatDateWithLocale(date, false);
- }
+ public String formatDateWithLocale(final Date date) {
+ return formatDateWithLocale(date, false);
+ }
- public String formatDateWithLocale(final Date date, final boolean shortFormat) {
- String dateFormat = shortFormat ? currentLang.getDateFormatShort() : currentLang.getDateFormat();
+ public String formatDateWithLocale(final Date date, final boolean shortFormat) {
+ String dateFormat = shortFormat ? currentLang.getDateFormatShort() : currentLang.getDateFormat();
- final DateTimeFormat fmt;
- if (dateFormat == null) {
- fmt = DateTimeFormat.getFormat("M/d/yyyy h:mm a");
- } else {
- if (shortFormat) {
- fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
- } else {
- final String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(date);
- final String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
- dateFormat = dateFormat.replaceFirst("MMM", "'" + t(monthToTranslate) + "'");
- fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
- }
- }
- final String dateFormated = fmt.format(date);
- return dateFormated;
+ final DateTimeFormat fmt;
+ if (dateFormat == null) {
+ fmt = DateTimeFormat.getFormat("M/d/yyyy h:mm a");
+ } else {
+ if (shortFormat) {
+ fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
+ } else {
+ final String abrevMonthInEnglish = DateTimeFormat.getFormat("MMM").format(date);
+ final String monthToTranslate = abrevMonthInEnglish + " [%NT abbreviated month]";
+ dateFormat = dateFormat.replaceFirst("MMM", "'" + t(monthToTranslate) + "'");
+ fmt = DateTimeFormat.getFormat(dateFormat + " h:mm a");
+ }
}
+ final String dateFormated = fmt.format(date);
+ return dateFormated;
+ }
- public String getCurrentLanguage() {
- return currentLanguageCode;
- }
+ public String getCurrentLanguage() {
+ return currentLanguageCode;
+ }
- public HashMap<String, String> getLexicon() {
- return lexicon;
- }
+ public HashMap<String, String> getLexicon() {
+ return lexicon;
+ }
- public void init(final I18nServiceAsync i18nService, final Session session, final Listener0 onReady) {
+ public void init(final I18nServiceAsync i18nService, final Session session, final Listener0 onReady) {
- }
+ }
- public void setCurrentLanguage(final String newLanguage) {
- this.currentLanguageCode = newLanguage;
- }
+ public void setCurrentLanguage(final String newLanguage) {
+ this.currentLanguageCode = newLanguage;
+ }
- public void setLexicon(final HashMap<String, String> lexicon) {
- this.lexicon = lexicon;
- }
+ public void setLexicon(final HashMap<String, String> lexicon) {
+ this.lexicon = lexicon;
+ }
- public void setTranslationAfterSave(final String text, final String translation) {
- lexicon.put(text, translation);
+ public void setTranslationAfterSave(final String text, final String translation) {
+ lexicon.put(text, translation);
+ }
+
+ /**
+ * In production, this method uses a hashmap. In development, if the text is
+ * not in the hashmap, it makes a server petition (that stores the text
+ * pending for translation in db).
+ *
+ * Warning: text is escaped as html before insert in the db. Don't use html
+ * here (o user this method with params).
+ *
+ * @param text
+ * @return text translated in the current language
+ */
+ @Override
+ public String tWithNT(final String text, final String noteForTranslators) {
+ if (lexicon == null) {
+ Log.warn("i18n not initialized");
+ return text;
}
+ final String encodeText = TextUtils.escapeHtmlLight(text);
+ String translation = lexicon.get(encodeText);
+ if (lexicon.containsKey(encodeText)) {
+ if (translation == UNTRANSLATED_VALUE) {
+ // Not translated but in db, return text
+ translation = encodeText;
+ }
+ } else {
+ // Not translated and not in db, make a petition for translation
+ if (session.isLogged()) {
+ i18nService.getTranslation(session.getUserHash(), currentLanguageCode, text, noteForTranslators,
+ new AsyncCallback<String>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ }
- /**
- * In production, this method uses a hashmap. In development, if the text is
- * not in the hashmap, it makes a server petition (that stores the text
- * pending for translation in db).
- *
- * Warning: text is escaped as html before insert in the db. Don't use html
- * here (o user this method with params).
- *
- * @param text
- * @return text translated in the current language
- */
- @Override
- public String t(final String text) {
- if (lexicon == null) {
- Log.warn("i18n not initialized");
- return text;
- }
- final String encodeText = TextUtils.escapeHtmlLight(text);
- String translation = lexicon.get(encodeText);
- if (lexicon.containsKey(encodeText)) {
- if (translation == UNTRANSLATED_VALUE) {
- // Not translated but in db, return text
- translation = removeNT(encodeText);
- }
- } else {
- // Not translated and not in db, make a petition for translation
- if (session.isLogged()) {
- i18nService.getTranslation(session.getUserHash(), currentLanguageCode, text,
- new AsyncCallback<String>() {
- @Override
- public void onFailure(final Throwable caught) {
- }
-
- @Override
- public void onSuccess(final String result) {
- }
- });
- Log.debug("Registering in db '" + text + "' as pending translation");
- lexicon.put(encodeText, UNTRANSLATED_VALUE);
- }
- translation = removeNT(encodeText);
- }
- return decodeHtml(translation);
+ @Override
+ public void onSuccess(final String result) {
+ }
+ });
+ Log.debug("Registering in db '" + text + "' as pending translation");
+ lexicon.put(encodeText, UNTRANSLATED_VALUE);
+ }
+ translation = encodeText;
}
+ return decodeHtml(translation);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/client/i18n/I18nUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nUtils.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nUtils.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -13,7 +13,7 @@
result = result.replaceAll("\\[%d\\]", "N");
result = result.replaceAll("\\[%s\\]", "Param");
final char[] delimiters = { ' ', '.', '?', ',', ';', '&', '(', ')', '"', '$', '!', '/', '\'', '-',
- '%', ':', '{', '}', '[', ']' };
+ '%', ':', '{', '}', '[', ']', '©', '«', '»' };
result = TextUtils.capitalizeFully(result, delimiters);
result = result.replaceAll("[ \\.\\?,;&\\(\\)\"\\$!\\/\\'\\-%:{}\\[\\]]", "");
return TextUtils.abbreviate(
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nService.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -39,7 +39,7 @@
List<I18nTranslationDTO> getTranslatedLexicon(String userHash, final String language,
boolean toTranslate);
- String getTranslation(String userHash, String language, String text);
+ String getTranslation(String userHash, String language, String text, String noteForTranslators);
String setTranslation(String userHash, Long 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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/I18nServiceAsync.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -36,7 +36,8 @@
void getTranslatedLexicon(String userHash, String language, boolean toTranslate,
AsyncCallback<List<I18nTranslationDTO>> callback);
- void getTranslation(String userHash, String language, String text, AsyncCallback<String> callback);
+ void getTranslation(String userHash, String language, String text, String noteForTranslators,
+ AsyncCallback<String> callback);
void setTranslation(String userHash, Long id, String translation, AsyncCallback<String> asyncCallback);
Modified: trunk/src/main/java/cc/kune/core/server/i18n/I18nTranslationServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/i18n/I18nTranslationServiceDefault.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/i18n/I18nTranslationServiceDefault.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -19,7 +19,6 @@
*/
package cc.kune.core.server.i18n;
-
import cc.kune.common.client.utils.TextUtils;
import cc.kune.core.server.UserSession;
import cc.kune.core.server.manager.I18nTranslationManager;
@@ -33,42 +32,59 @@
@Singleton
public class I18nTranslationServiceDefault extends I18nTranslationService {
- private final I18nTranslationManager translationManager;
+ private final I18nTranslationManager translationManager;
- // private final Provider<UserSession> userSessionProvider;
+ // private final Provider<UserSession> userSessionProvider;
- @Inject
- public I18nTranslationServiceDefault(final I18nTranslationManager translationManager,
- final Provider<UserSession> userSessionProvider) {
- this.translationManager = translationManager;
- // this.userSessionProvider = userSessionProvider;
- }
+ @Inject
+ public I18nTranslationServiceDefault(final I18nTranslationManager translationManager,
+ final Provider<UserSession> userSessionProvider) {
+ this.translationManager = translationManager;
+ // this.userSessionProvider = userSessionProvider;
+ }
- /**
- * If the text is not in the db, it stores the text pending for translation.
- *
- * Warning: text is escaped as html before insert in the db. Don't use html
- * here (o user this method with params).
- *
- * @param text
- * @return text translated in the current language
- */
- @Override
- public String t(final String text) {
- String language;
+ /**
+ * If the text is not in the db, it stores the text pending for translation.
+ *
+ * Warning: text is escaped as html before insert in the db. Don't use html
+ * here (o user this method with params).
+ *
+ * @param text
+ * @return text translated in the current language
+ */
+ @Override
+ public String t(final String text) {
+ return tWithNT(text, "");
+ }
- // final UserSession userSession = userSessionProvider.get();
- // if (userSession.isUserLoggedIn()) {
- // language = userSession.getUser().getLanguage().getCode();
- // } else {
- language = I18nTranslation.DEFAULT_LANG;
- // }
- final String encodeText = TextUtils.escapeHtmlLight(text);
- String translation = translationManager.getTranslation(language, text);
- if (translation == UNTRANSLATED_VALUE) {
- // Not translated but in db, return text
- translation = removeNT(encodeText);
- }
- return decodeHtml(translation);
+ /**
+ * If the text is not in the db, it stores the text pending for translation.
+ *
+ * Warning: text is escaped as html before insert in the db. Don't use html
+ * here (o user this method with params).
+ *
+ * @param text
+ * @param noteForTranslators
+ * some note for facilitate the translation
+ *
+ * @return text translated in the current language
+ */
+ @Override
+ public String tWithNT(final String text, final String noteForTranslators) {
+ String language;
+
+ // final UserSession userSession = userSessionProvider.get();
+ // if (userSession.isUserLoggedIn()) {
+ // language = userSession.getUser().getLanguage().getCode();
+ // } else {
+ language = I18nTranslation.DEFAULT_LANG;
+ // }
+ final String encodeText = TextUtils.escapeHtmlLight(text);
+ String translation = translationManager.getTranslation(language, text, noteForTranslators);
+ if (translation == UNTRANSLATED_VALUE) {
+ // Not translated but in db, return text
+ translation = encodeText;
}
+ return decodeHtml(translation);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/init/DatabaseInitializer.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -168,7 +168,7 @@
final I18nCountry gb = new I18nCountry(Long.valueOf(75), "GB", "GBP", ".", "£%n", "", ".",
"United Kingdom", "western", ",");
countryManager.persist(gb);
- final I18nTranslation test = new I18nTranslation("test", english, "test");
+ final I18nTranslation test = new I18nTranslation("test", english, "test", "");
translationManager.persist(test);
}
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/manager/I18nTranslationManager.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -23,31 +23,26 @@
import java.util.List;
import cc.kune.core.client.errors.DefaultException;
-import cc.kune.core.server.manager.impl.SearchResult;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+import cc.kune.core.shared.dto.SearchResultDTO;
import cc.kune.domain.I18nTranslation;
public interface I18nTranslationManager extends Manager<I18nTranslation, Long> {
HashMap<String, String> getLexicon(String language);
- List<I18nTranslation> getTranslatedLexicon(String language);
+ List<I18nTranslationDTO> getTranslatedLexicon(String language);
- SearchResult<I18nTranslation> getTranslatedLexicon(String language, Integer firstResult,
+ SearchResultDTO<I18nTranslationDTO> getTranslatedLexicon(String language, Integer firstResult,
Integer maxResults);
- String getTranslation(String language, String text);
+ String getTranslation(String language, String text, String noteForTranslators);
- String getTranslation(String language, String text, Integer arg);
+ List<I18nTranslationDTO> getUntranslatedLexicon(String language);
- String getTranslation(String language, String text, String arg);
-
- List<I18nTranslation> getUntranslatedLexicon(String language);
-
- SearchResult<I18nTranslation> getUntranslatedLexicon(String language, Integer firstResult,
+ SearchResultDTO<I18nTranslationDTO> getUntranslatedLexicon(String language, Integer firstResult,
Integer maxResults);
String setTranslation(Long id, String translation) throws DefaultException;
- 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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/I18nTranslationManagerDefault.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -29,6 +29,8 @@
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.server.manager.I18nLanguageManager;
import cc.kune.core.server.manager.I18nTranslationManager;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
+import cc.kune.core.shared.dto.SearchResultDTO;
import cc.kune.domain.I18nLanguage;
import cc.kune.domain.I18nTranslation;
import cc.kune.domain.finders.I18nTranslationFinder;
@@ -69,6 +71,9 @@
@SuppressWarnings("unchecked")
private HashMap<String, String> getLexiconFromDb(final String language) {
+ // FIXME
+ // 1) Generate English
+ // 2) Don't permit to translate English
HashMap<String, String> map = new HashMap<String, String>();
final List<I18nTranslation> set = finder.findByLanguage(language);
if (!language.equals(I18nTranslation.DEFAULT_LANG)) {
@@ -82,21 +87,21 @@
}
@Override
- public List<I18nTranslation> getTranslatedLexicon(final String languageCode) {
+ public List<I18nTranslationDTO> getTranslatedLexicon(final String languageCode) {
return finder.getTranslatedLexicon(getLanguage(languageCode));
}
@Override
- public SearchResult<I18nTranslation> getTranslatedLexicon(final String languageCode,
+ public SearchResultDTO<I18nTranslationDTO> 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 List<I18nTranslationDTO> list = finder.getTranslatedLexicon(language, firstResult, maxResults);
final Long count = finder.getTranslatedLexiconCount(language);
- return new SearchResult<I18nTranslation>(count.intValue(), list);
+ return new SearchResultDTO<I18nTranslationDTO>(count.intValue(), list);
}
@Override
- public String getTranslation(final String language, final String text) {
+ public String getTranslation(final String language, final String text, final String noteForTranslators) {
final HashMap<String, String> lexicon = getLexicon(language);
final String escapedText = TextUtils.escapeHtmlLight(text);
if (lexicon.containsKey(escapedText)) {
@@ -108,7 +113,8 @@
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));
+ I18nTranslation.DEF_NAMESPACE, languageManager.findByCode(I18nTranslation.DEFAULT_LANG),
+ null, noteForTranslators);
persist(newTranslation);
langCache.clear();
}
@@ -117,31 +123,18 @@
}
@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 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 List<I18nTranslation> getUntranslatedLexicon(final String languageCode) {
+ public List<I18nTranslationDTO> getUntranslatedLexicon(final String languageCode) {
return finder.getUntranslatedLexicon(initUnstranlated(languageCode));
}
@Override
- public SearchResult<I18nTranslation> getUntranslatedLexicon(final String languageCode,
+ public SearchResultDTO<I18nTranslationDTO> 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);
+ final List<I18nTranslationDTO> list = finder.getUnstranslatedLexicon(language, firstResult,
+ maxResults);
+ return new SearchResultDTO<I18nTranslationDTO>(count.intValue(), list);
}
private I18nLanguage initUnstranlated(final String languageCode) {
@@ -165,6 +158,8 @@
public String setTranslation(final Long id, final String translation) throws DefaultException {
final I18nTranslation trans = super.find(id);
if (trans != null) {
+ // Don't permit to translate the def language
+ assert trans.getLanguage().getCode() != I18nTranslation.DEFAULT_LANG;
final String escapedTranslation = TextUtils.escapeHtmlLight(translation);
trans.setText(escapedTranslation);
persist(trans);
@@ -174,16 +169,4 @@
}
}
- @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/rest/I18nTranslationJSONService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rest/I18nTranslationJSONService.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/rest/I18nTranslationJSONService.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -21,52 +21,53 @@
import java.util.List;
-
import cc.kune.core.server.manager.I18nTranslationManager;
-import cc.kune.core.server.manager.impl.SearchResult;
import cc.kune.core.server.mapper.Mapper;
import cc.kune.core.server.rack.filters.rest.REST;
import cc.kune.core.shared.SearcherConstants;
import cc.kune.core.shared.dto.I18nTranslationDTO;
import cc.kune.core.shared.dto.SearchResultDTO;
-import cc.kune.domain.I18nTranslation;
import com.google.inject.Inject;
public class I18nTranslationJSONService {
- private final I18nTranslationManager manager;
- private final Mapper mapper;
+ private final I18nTranslationManager manager;
+ private final Mapper mapper;
- @Inject
- public I18nTranslationJSONService(final I18nTranslationManager manager, final Mapper mapper) {
- this.manager = manager;
- this.mapper = mapper;
- }
+ @Inject
+ public I18nTranslationJSONService(final I18nTranslationManager manager, final Mapper mapper) {
+ this.manager = manager;
+ this.mapper = mapper;
+ }
- @REST(params = { SearcherConstants.QUERY_PARAM })
- public List<I18nTranslationDTO> search(final String language) {
- List<I18nTranslation> results = manager.getUntranslatedLexicon(language);
- return mapper.mapList(results, I18nTranslationDTO.class);
- }
+ @REST(params = { SearcherConstants.QUERY_PARAM })
+ public List<I18nTranslationDTO> search(final String language) {
+ final List<I18nTranslationDTO> results = manager.getUntranslatedLexicon(language);
+ return results;
+ }
- @REST(params = { SearcherConstants.QUERY_PARAM, SearcherConstants.START_PARAM, SearcherConstants.LIMIT_PARAM })
- public SearchResultDTO<I18nTranslationDTO> search(final String language, final Integer firstResult,
- final Integer maxResults) {
- SearchResult<I18nTranslation> results = manager.getUntranslatedLexicon(language, firstResult, maxResults);
- return mapper.mapSearchResult(results, I18nTranslationDTO.class);
- }
+ @REST(params = { SearcherConstants.QUERY_PARAM, SearcherConstants.START_PARAM,
+ SearcherConstants.LIMIT_PARAM })
+ public SearchResultDTO<I18nTranslationDTO> search(final String language, final Integer firstResult,
+ final Integer maxResults) {
+ final SearchResultDTO<I18nTranslationDTO> results = manager.getUntranslatedLexicon(language,
+ firstResult, maxResults);
+ return results;
+ }
- @REST(params = { SearcherConstants.QUERY_PARAM })
- public List<I18nTranslationDTO> searchtranslated(final String language) {
- List<I18nTranslation> results = manager.getTranslatedLexicon(language);
- return mapper.mapList(results, I18nTranslationDTO.class);
- }
+ @REST(params = { SearcherConstants.QUERY_PARAM })
+ public List<I18nTranslationDTO> searchtranslated(final String language) {
+ final List<I18nTranslationDTO> results = manager.getTranslatedLexicon(language);
+ return results;
+ }
- @REST(params = { SearcherConstants.QUERY_PARAM, SearcherConstants.START_PARAM, SearcherConstants.LIMIT_PARAM })
- public SearchResultDTO<I18nTranslationDTO> searchtranslated(final String language, final Integer firstResult,
- final Integer maxResults) {
- SearchResult<I18nTranslation> results = manager.getTranslatedLexicon(language, firstResult, maxResults);
- return mapper.mapSearchResult(results, I18nTranslationDTO.class);
- }
+ @REST(params = { SearcherConstants.QUERY_PARAM, SearcherConstants.START_PARAM,
+ SearcherConstants.LIMIT_PARAM })
+ public SearchResultDTO<I18nTranslationDTO> searchtranslated(final String language,
+ final Integer firstResult, final Integer maxResults) {
+ final SearchResultDTO<I18nTranslationDTO> results = manager.getTranslatedLexicon(language,
+ firstResult, maxResults);
+ return results;
+ }
}
\ No newline at end of file
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/server/rpc/I18nRPC.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -110,28 +110,28 @@
public List<I18nTranslationDTO> getTranslatedLexicon(final String userHash, final String language,
final boolean toTranslate) {
if (toTranslate) {
- return mapper.mapList(i18nTranslationManager.getUntranslatedLexicon(language),
- I18nTranslationDTO.class);
+ return i18nTranslationManager.getUntranslatedLexicon(language);
} else {
- return mapper.mapList(i18nTranslationManager.getTranslatedLexicon(language),
- I18nTranslationDTO.class);
+ return i18nTranslationManager.getTranslatedLexicon(language);
}
}
@Override
@Transactional
- public String getTranslation(final String userHash, final String language, final String text) {
+ public String getTranslation(final String userHash, final String language, final String text,
+ final String noteForTranslators) {
String translation = null;
try {
- translation = getTranslationWrapper(language, text);
+ translation = getTranslationWrapper(language, text, noteForTranslators);
} catch (final SessionExpiredException e) {
}
return translation;
}
@Authenticated(mandatory = false)
- private String getTranslationWrapper(final String language, final String text) {
- return i18nTranslationManager.getTranslation(language, text);
+ private String getTranslationWrapper(final String language, final String text,
+ final String noteForTranslators) {
+ return i18nTranslationManager.getTranslation(language, text, noteForTranslators);
}
private UserSession getUserSession() {
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/shared/dto/I18nTranslationDTO.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -35,29 +35,47 @@
};
private boolean dirty;
private Long id;
+ private String noteForTranslators;
+ private Long parentId;
+ private String parentTrKey;
private String text;
private String trKey;
public I18nTranslationDTO() {
- this(null, null, null);
+ this(null, null, null, null, null);
}
- public I18nTranslationDTO(final Long id, final String trKey, final String text) {
+ public I18nTranslationDTO(final Long id, final String trKey, final String text, final Long parentId,
+ final String parentTrKey) {
this.id = id;
this.trKey = trKey;
this.text = text;
+ this.parentId = parentId;
+ this.parentTrKey = parentTrKey;
setDirty(false);
}
@Override
public int compareTo(final I18nTranslationDTO o) {
- return (o == null || o.trKey == null) ? -1 : -o.trKey.compareTo(trKey);
+ return (o == null || o.id == null) ? -1 : -o.id.compareTo(id);
}
public Long getId() {
return id;
}
+ public String getNoteForTranslators() {
+ return noteForTranslators;
+ }
+
+ public Long getParentId() {
+ return parentId;
+ }
+
+ public String getParentTrKey() {
+ return parentTrKey;
+ }
+
public String getText() {
return text;
}
@@ -78,6 +96,18 @@
this.id = id;
}
+ public void setNoteForTranslators(final String noteForTranslators) {
+ this.noteForTranslators = noteForTranslators;
+ }
+
+ public void setParentId(final Long parentId) {
+ this.parentId = parentId;
+ }
+
+ public void setParentTrKey(final String parentTrKey) {
+ this.parentTrKey = parentTrKey;
+ }
+
public void setText(final String text) {
this.text = text;
}
Modified: trunk/src/main/java/cc/kune/core/shared/i18n/I18nTranslationService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/i18n/I18nTranslationService.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/core/shared/i18n/I18nTranslationService.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -19,119 +19,152 @@
*/
package cc.kune.core.shared.i18n;
+import cc.kune.common.client.utils.Pair;
+
public abstract class I18nTranslationService {
- protected static final String TRANSLATION_NOTE_REGEXP = " (\\[)%NT (.*)(\\])$";
- protected static final String NOTE_FOR_TRANSLATOR_TAG_BEGIN = " [%NT ";
- protected static final String NOTE_FOR_TRANSLATOR_TAG_END = "]";
- // Also in I18nTranslation
- protected static final String UNTRANSLATED_VALUE = null;
- public String decodeHtml(final String textToDecode) {
- String text = textToDecode;
- // text = text.replaceAll("©", "©");
- return text;
- }
+ // Also in I18nTranslation
+ protected static final String UNTRANSLATED_VALUE = null;
- public String removeNT(final String string) {
- return string.replaceAll(TRANSLATION_NOTE_REGEXP, "");
- }
+ public String decodeHtml(final String textToDecode) {
+ final String text = textToDecode;
+ // text = text.replaceAll("©", "©");
+ return text;
+ }
- /**
- * In production, this method uses a hashmap. In development, if the text is
- * not in the hashmap, it makes a server petition (that stores the text
- * pending for translation in db).
- *
- * Warning: text is escaped as html before insert in the db. Don't use html
- * here (o user this method with params).
- *
- * @param text
- * @return text translated in the current language
- */
- // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:49
- public abstract String t(final String text);
-
- /**
- * Use [%d] to reference the Integer parameters
- *
- */
- // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
- public String t(final String text, final Integer... args) {
- String translation = t(text);
- for (Integer arg : args) {
- translation = translation.replaceFirst("\\[%d\\]", arg.toString());
- }
- return decodeHtml(translation);
+ /**
+ * Use [%d] to reference the Integer parameters
+ *
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
+ private String t(final Pair<String, String> pair, final Integer... args) {
+ String translation = tWithNT(pair.getLeft(), pair.getRight());
+ for (final Integer arg : args) {
+ translation = translation.replaceFirst("\\[%d\\]", arg.toString());
}
+ return decodeHtml(translation);
+ }
- /**
- * Use [%d] to reference the Long parameter
- *
- */
- // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
- public String t(final String text, final Long... args) {
- String translation = t(text);
- for (Long arg : args) {
- translation = translation.replaceFirst("\\[%d\\]", arg.toString());
- }
- return decodeHtml(translation);
+ /**
+ * Use [%d] to reference the Long parameter
+ *
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
+ private String t(final Pair<String, String> pair, final Long... args) {
+ String translation = tWithNT(pair.getLeft(), pair.getRight());
+ for (final Long arg : args) {
+ translation = translation.replaceFirst("\\[%d\\]", arg.toString());
}
+ return decodeHtml(translation);
+ }
- /**
- * Use [%s] to reference the string parameter
- *
- */
- // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
- public String t(final String text, final String... args) {
- String translation = t(text);
- for (String arg : args) {
- translation = translation.replaceFirst("\\[%s\\]", arg);
- }
- return decodeHtml(translation);
+ /**
+ * Use [%s] to reference the string parameter
+ *
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
+ private String t(final Pair<String, String> pair, final String... args) {
+ String translation = tWithNT(pair.getLeft(), pair.getRight());
+ for (final String arg : args) {
+ translation = translation.replaceFirst("\\[%s\\]", arg);
}
+ return decodeHtml(translation);
+ }
- /**
- * Adds [%NT noteForTranslators] at the end of text. This tag is later
- * renderer in the translator panel to inform translator how to do this
- * translation
- *
- */
- public String tWithNT(final String text, final String noteForTranslators) {
- return t(text + NOTE_FOR_TRANSLATOR_TAG_BEGIN + noteForTranslators + NOTE_FOR_TRANSLATOR_TAG_END);
- }
+ /**
+ * In production, this method uses a hashmap. In development, if the text is
+ * not in the hashmap, it makes a server petition (that stores the text
+ * pending for translation in db).
+ *
+ * Warning: text is escaped as html before insert in the db. Don't use html
+ * here (o user this method with params).
+ *
+ * @param text
+ * some note for facilitate the translation
+ *
+ * @return text translated in the current language
+ */
+ public String t(final String text) {
+ return tWithNT(text, "");
+ }
- /**
- * Use [%d] to reference the Integer parameter.
- *
- * Also adds [%NT noteForTranslators] at the end of text. This tag is later
- * renderer in the translator panel to inform translator how to do this
- * translation
- *
- */
- public String tWithNT(final String text, final String noteForTranslators, final Integer... args) {
- return t(text + NOTE_FOR_TRANSLATOR_TAG_BEGIN + noteForTranslators + NOTE_FOR_TRANSLATOR_TAG_END, args);
- }
+ /**
+ * Use [%d] to reference the Integer parameters
+ *
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
+ public String t(final String text, final Integer... args) {
+ return t(Pair.create(text, ""), args);
+ }
- /**
- * Use [%d] to reference the Long parameter.
- *
- * Also adds [%NT noteForTranslators] at the end of text. This tag is later
- * renderer in the translator panel to inform translator how to do this
- * translation
- *
- */
- public String tWithNT(final String text, final String noteForTranslators, final Long... args) {
- return t(text + NOTE_FOR_TRANSLATOR_TAG_BEGIN + noteForTranslators + NOTE_FOR_TRANSLATOR_TAG_END, args);
- }
+ /**
+ * Use [%d] to reference the Long parameter
+ *
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:50
+ public String t(final String text, final Long... args) {
+ return t(Pair.create(text, ""), args);
+ }
- /**
- * Use [%s] to reference the String parameter.
- *
- * Also adds [%NT noteForTranslators] at the end of text. This tag is later
- * renderer in the translator panel to inform translator how to do this
- * translation
- *
- */
- public String tWithNT(final String text, final String noteForTranslators, final String... args) {
- return t(text + NOTE_FOR_TRANSLATOR_TAG_BEGIN + noteForTranslators + NOTE_FOR_TRANSLATOR_TAG_END, args);
- }
+ /**
+ * Use [%s] to reference the String parameter.
+ *
+ */
+ public String t(final String text, final String... args) {
+ return t(Pair.create(text, ""), args);
+ }
+
+ /**
+ * In production, this method uses a hashmap. In development, if the text is
+ * not in the hashmap, it makes a server petition (that stores the text
+ * pending for translation in db).
+ *
+ * Warning: text is escaped as html before insert in the db. Don't use html
+ * here (o user this method with params).
+ *
+ * @param text
+ * @param noteForTranslators
+ * some note for facilitate the translation
+ *
+ * @return text translated in the current language
+ */
+ // @PMD:REVIEWED:ShortMethodName: by vjrj on 21/05/09 13:49
+ public abstract String tWithNT(final String text, final String noteForTranslators);
+
+ /**
+ * - Use [%d] to reference the Integer parameter.
+ *
+ * Also adds [%NT noteForTranslators] at the end of text. This tag is later
+ * renderer in the translator panel to inform translator how to do this
+ * translation
+ *
+ */
+ public String tWithNT(final String text, final String noteForTranslators, final Integer... args) {
+ return t(Pair.create(text, noteForTranslators), args);
+ }
+
+ /**
+ * Use [%d] to reference the Long parameter.
+ *
+ * Also adds [%NT noteForTranslators] at the end of text. This tag is later
+ * renderer in the translator panel to inform translator how to do this
+ * translation
+ *
+ */
+ public String tWithNT(final String text, final String noteForTranslators, final Long... args) {
+ return t(Pair.create(text, noteForTranslators), args);
+ }
+
+ /**
+ * Use [%s] to reference the String parameter.
+ *
+ * Also adds [%NT noteForTranslators] at the end of text. This tag is later
+ * renderer in the translator panel to inform translator how to do this
+ * translation
+ *
+ */
+ public String tWithNT(final String text, final String noteForTranslators, final String... args) {
+ return t(Pair.create(text, noteForTranslators), args);
+ }
+
}
Modified: trunk/src/main/java/cc/kune/domain/I18nTranslation.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/I18nTranslation.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/domain/I18nTranslation.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -42,154 +42,204 @@
@Table(name = "globalize_translations")
public class I18nTranslation implements HasId {
- public static final String DEF_NAMESPACE = "kune_core";
- public static final Integer DEF_PLUR_INDEX = 1;
- public static final String DEFAULT_LANG = "en";
+ public static final String DEF_NAMESPACE = "kune_core";
+ public static final Integer DEF_PLUR_INDEX = 1;
+ public static final String DEFAULT_LANG = "en";
+ public static final String UNTRANSLATED_VALUE = null;
- public static final String UNTRANSLATED_VALUE = null;
+ @Column(name = "facet")
+ private String facet;
- @Column(name = "facet")
- private String facet;
+ @Id
+ @GeneratedValue
+ @DocumentId
+ @Column(name = "id", unique = true, nullable = false)
+ private Long id;
- @Id
- @GeneratedValue
- @DocumentId
- @Column(name = "id", unique = true, nullable = false)
- private Long id;
+ @Column(name = "item_id")
+ private Integer itemId;
- @Column(name = "item_id")
- private Integer itemId;
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "language_id")
+ private I18nLanguage language;
- @ManyToOne(cascade = CascadeType.ALL)
- @JoinColumn(name = "language_id")
- private I18nLanguage language;
+ private String noteForTranslators;
- @Column(name = "pluralization_index")
- private Integer pluralizationIndex;
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "parent_id")
+ private I18nTranslation parent;
- @Column(name = "table_name")
- private String tableName;
+ @Column(name = "pluralization_index")
+ private Integer pluralizationIndex;
- @Column(name = "text")
- private String text;
+ @Column(name = "table_name")
+ private String tableName;
- @Column(name = "tr_key")
- private String trKey;
+ @Column(name = "text")
+ private String text;
- @Column(name = "gtype")
- private String type;
+ @Column(name = "tr_key")
+ private String trKey;
- public I18nTranslation() {
- this(null, null, null, null, null, null, null, null);
- }
+ @Column(name = "gtype")
+ private String type;
- public I18nTranslation(final String trKey, final I18nLanguage language, final String text) {
- this("", null, DEF_PLUR_INDEX, "", text, trKey, DEF_NAMESPACE, language);
- }
+ public I18nTranslation() {
+ this(null, null, null, null, null, null, null, null, null, null);
+ }
- public I18nTranslation(final String facet, final Integer itemId, final Integer pluralizationIndex,
- final String tableName, final String text, final String trKey, final String type,
- final I18nLanguage language) {
- this.type = type;
- this.trKey = trKey;
- this.tableName = tableName;
- this.itemId = itemId;
- this.facet = facet;
- this.language = language;
- this.pluralizationIndex = pluralizationIndex;
- this.text = text;
- }
+ public I18nTranslation(final I18nLanguage language, final String text, final I18nTranslation parent,
+ final String noteForTranslators) {
+ this("", null, DEF_PLUR_INDEX, "", text, null, DEF_NAMESPACE, language, parent, noteForTranslators);
+ }
- public I18nTranslation cloneForNewLanguage() {
- final I18nTranslation clone = new I18nTranslation();
- clone.type = type;
- clone.trKey = trKey;
- clone.tableName = tableName;
- clone.itemId = itemId;
- clone.facet = facet;
- clone.language = null;
- clone.pluralizationIndex = pluralizationIndex;
- clone.text = null;
- return clone;
- }
+ public I18nTranslation(final String trKey, final I18nLanguage language, final String text,
+ final String noteForTranslators) {
+ this("", null, DEF_PLUR_INDEX, "", text, trKey, DEF_NAMESPACE, language, null, noteForTranslators);
+ }
- public String getFacet() {
- return this.facet;
+ public I18nTranslation(final String facet, final Integer itemId, final Integer pluralizationIndex,
+ final String tableName, final String text, final String trKey, final String type,
+ final I18nLanguage language, final I18nTranslation parent, final String noteForTranslators) {
+ this.type = type;
+ this.trKey = trKey;
+ this.tableName = tableName;
+ this.itemId = itemId;
+ this.facet = facet;
+ this.language = language;
+ this.pluralizationIndex = pluralizationIndex;
+ this.text = text;
+ this.parent = parent;
+ this.setNoteForTranslators(noteForTranslators);
+ if (parent == null) {
+ assert trKey != null;
}
-
- @Override
- public Long getId() {
- return this.id;
+ if (parent != null) {
+ assert trKey == null;
}
+ }
- public Integer getItemId() {
- return this.itemId;
- }
+ public I18nTranslation cloneForNewLanguage() {
+ final I18nTranslation clone = new I18nTranslation();
+ clone.type = type;
+ clone.trKey = null;
+ clone.tableName = tableName;
+ clone.itemId = itemId;
+ clone.facet = facet;
+ clone.language = null;
+ clone.pluralizationIndex = pluralizationIndex;
+ clone.text = null;
+ clone.parent = this;
+ return clone;
+ }
- public I18nLanguage getLanguage() {
- return language;
- }
+ public String getFacet() {
+ return this.facet;
+ }
- public Integer getPluralizationIndex() {
- return this.pluralizationIndex;
- }
+ @Override
+ public Long getId() {
+ return this.id;
+ }
- public String getTableName() {
- return this.tableName;
- }
+ public Integer getItemId() {
+ return this.itemId;
+ }
- public String getText() {
- return this.text;
- }
+ public I18nLanguage getLanguage() {
+ return language;
+ }
- public String getTrKey() {
- return this.trKey;
- }
+ public String getNoteForTranslators() {
+ return noteForTranslators;
+ }
- public String getType() {
- return this.type;
- }
+ /**
+ *
+ * The id of what we are translating
+ *
+ * @return the parent id
+ */
+ public I18nTranslation getParent() {
+ return parent;
+ }
- public void setFacet(final String facet) {
- this.facet = facet;
- }
+ public Long getParentId() {
+ return parent == null ? null : parent.getId();
+ }
- @Override
- public void setId(final Long id) {
- this.id = id;
- }
+ public Integer getPluralizationIndex() {
+ return this.pluralizationIndex;
+ }
- public void setItemId(final Integer itemId) {
- this.itemId = itemId;
- }
+ public String getTableName() {
+ return this.tableName;
+ }
- public void setLanguage(final I18nLanguage language) {
- this.language = language;
- }
+ public String getText() {
+ return this.text;
+ }
- public void setPluralizationIndex(final Integer pluralizationIndex) {
- this.pluralizationIndex = pluralizationIndex;
+ public String getTrKey() {
+ if (parent != null) {
+ return parent.getTrKey();
+ } else {
+ return this.trKey;
}
+ }
- public void setTableName(final String tableName) {
- this.tableName = tableName;
- }
+ public String getType() {
+ return this.type;
+ }
- public void setText(final String text) {
- this.text = text;
- }
+ public void setFacet(final String facet) {
+ this.facet = facet;
+ }
- public void setTrKey(final String trKey) {
- this.trKey = trKey;
- }
+ @Override
+ public void setId(final Long id) {
+ this.id = id;
+ }
- public void setType(final String type) {
- this.type = type;
- }
+ public void setItemId(final Integer itemId) {
+ this.itemId = itemId;
+ }
- @Override
- public String toString() {
- return "I18nTranslation[" + trKey + " (" + language + ") " + text + "]";
- }
+ public void setLanguage(final I18nLanguage language) {
+ this.language = language;
+ }
+ public void setNoteForTranslators(final String noteForTranslators) {
+ this.noteForTranslators = noteForTranslators;
+ }
+
+ public void setParentId(final I18nTranslation parent) {
+ this.parent = parent;
+ }
+
+ public void setPluralizationIndex(final Integer pluralizationIndex) {
+ this.pluralizationIndex = pluralizationIndex;
+ }
+
+ public void setTableName(final String tableName) {
+ this.tableName = tableName;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+ public void setTrKey(final String trKey) {
+ this.trKey = trKey;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return "I18nTranslation[" + getTrKey() + " (" + language + ") " + text + "]";
+ }
+
}
Modified: trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/domain/finders/I18nTranslationFinder.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
+import cc.kune.core.shared.dto.I18nTranslationDTO;
import cc.kune.domain.I18nLanguage;
import cc.kune.domain.I18nTranslation;
@@ -32,9 +33,9 @@
public interface I18nTranslationFinder {
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 TRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey) FROM I18nTranslation gt LEFT JOIN gt.parent gp WHERE gt.language = :language AND gt.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";
+ String UNTRANSLATED_QUERY = "SELECT NEW cc.kune.core.shared.dto.I18nTranslationDTO(gt.id, gt.trKey, gt.text, gt.parent.id, gt.parent.trKey) FROM I18nTranslation gt LEFT JOIN gt.parent gp WHERE gt.language = :language AND gt.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);
@@ -45,23 +46,24 @@
@Named("language") final I18nLanguage language);
@Finder(query = TRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language);
+ public List<I18nTranslationDTO> getTranslatedLexicon(@Named("language") final I18nLanguage language);
@Finder(query = TRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getTranslatedLexicon(@Named("language") final I18nLanguage language,
+ public List<I18nTranslationDTO> getTranslatedLexicon(@Named("language") final I18nLanguage language,
@FirstResult final int first, @MaxResults final int max);
@Finder(query = TRANSLATED_COUNT_QUERY)
public Long getTranslatedLexiconCount(@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);
+ public List<I18nTranslationDTO> 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(query = UNTRANSLATED_QUERY, returnAs = ArrayList.class)
- public List<I18nTranslation> getUntranslatedLexicon(@Named("language") final I18nLanguage language);
+ public List<I18nTranslationDTO> getUntranslatedLexicon(@Named("language") final I18nLanguage language);
}
Copied: trunk/src/main/java/cc/kune/gspace/client/i18n/AbstractLanguageSelectorPanel.java (from rev 1511, trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java)
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/AbstractLanguageSelectorPanel.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/AbstractLanguageSelectorPanel.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1,161 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+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;
+import cc.kune.core.shared.i18n.I18nTranslationService;
+
+import com.extjs.gxt.ui.client.data.BaseModel;
+import com.extjs.gxt.ui.client.event.BaseEvent;
+import com.extjs.gxt.ui.client.event.Events;
+import com.extjs.gxt.ui.client.event.Listener;
+import com.extjs.gxt.ui.client.store.ListStore;
+import com.extjs.gxt.ui.client.widget.form.ComboBox;
+import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
+import com.extjs.gxt.ui.client.widget.form.FormPanel;
+
+public abstract class AbstractLanguageSelectorPanel extends FormPanel {
+
+ @SuppressWarnings("serial")
+ public class LanguageData extends BaseModel {
+
+ private static final String CODE = "code";
+ private static final String ENGLISH_NAME = "englishName";
+
+ public LanguageData(final String code, final String englishName) {
+ set(CODE, code);
+ set(ENGLISH_NAME, englishName);
+ }
+
+ public String getCode() {
+ return get(CODE);
+ }
+
+ public String getEnglishName() {
+ return get(ENGLISH_NAME);
+ }
+ }
+
+ public static final String LANG_FIELD = "k-langsp-lf";
+
+ private final I18nTranslationService i18n;
+ private ComboBox<LanguageData> langCombo;
+ private final Session session;
+
+ public AbstractLanguageSelectorPanel(final I18nTranslationService i18n, final Session session,
+ final boolean withEnglish) {
+ super();
+ this.i18n = i18n;
+ this.session = session;
+ setBorders(false);
+ setFrame(false);
+ setHeaderVisible(false);
+ setBodyBorder(false);
+ createLangCombo(withEnglish);
+ super.add(langCombo);
+ }
+
+ public void addChangeListener(final SimpleCallback onChange) {
+ langCombo.addListener(Events.Select, new Listener<BaseEvent>() {
+ @Override
+ public void handleEvent(final BaseEvent be) {
+ onChange.onCallback();
+ }
+ });
+ }
+
+ private void createLangCombo(final boolean withEnglish) {
+ // Field.setMsgTarget("side");
+ langCombo = new ComboBox<LanguageData>();
+ langCombo.setName(LANG_FIELD);
+ langCombo.setMinChars(1);
+ // langCombo.setMode(ComboBox.LOCAL);
+ langCombo.setStore(createStore(withEnglish));
+ langCombo.setDisplayField("language");
+ langCombo.setTriggerAction(TriggerAction.ALL);
+ langCombo.setEmptyText(i18n.t("Enter language"));
+ langCombo.setLoadingText(i18n.t("Searching..."));
+ langCombo.setDisplayField(LanguageData.ENGLISH_NAME);
+ langCombo.setValueField(LanguageData.CODE);
+ langCombo.setTypeAhead(true);
+ langCombo.setTypeAheadDelay(1000);
+ langCombo.setSelectOnFocus(false);
+ langCombo.setWidth(140);
+ langCombo.setPageSize(7);
+ langCombo.setForceSelection(true);
+ langCombo.setAllowBlank(false);
+ }
+
+ private ListStore<LanguageData> createStore(final boolean withEnglish) {
+ final ListStore<LanguageData> list = new ListStore<LanguageData>();
+
+ for (final I18nLanguageSimpleDTO lang : session.getLanguages()) {
+ final boolean isEnglish = lang.getCode().equals("en");
+ if (!isEnglish || (isEnglish && withEnglish)) {
+ list.add(new LanguageData(lang.getCode(), lang.getEnglishName()));
+ }
+ }
+ 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();
+ }
+
+ public String getLanguageEnglishName() {
+ return langCombo.getValue().getEnglishName();
+ }
+
+ @Override
+ public void reset() {
+ langCombo.reset();
+ }
+
+ public void setLangSeparator(final String separator) {
+ langCombo.setLabelSeparator(separator);
+ }
+
+ public void setLangTitle(final String langFieldTitle) {
+ if (langFieldTitle == null) {
+ setHideLabels(true);
+ } else {
+ if (langFieldTitle != null) {
+ langCombo.setFieldLabel(langFieldTitle);
+ }
+ }
+ }
+
+ public void setLanguage(final I18nLanguageSimpleDTO language) {
+ langCombo.setRawValue(language.getEnglishName());
+ }
+}
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nCellList.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -93,7 +93,8 @@
+ (odd ? ODD_STYLE : "") + "'>");
sb.appendHtmlConstant("<div style='display: table-cell; width: 100%; padding: 1px 5px;"
+ (value.isDirty() ? DIRTY_STYLE : "") + "'>");
- sb.appendEscaped(value.getTrKey());
+ final String trKey = value.getTrKey();
+ sb.appendEscaped(trKey == null ? value.getParentTrKey() : trKey);
sb.appendHtmlConstant("</div></div>");
}
}
@@ -134,7 +135,7 @@
// 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.setEmptyListMessage(SafeHtmlUtils.fromTrustedString("<span style='padding: 10px; font-style: italic;'>Empty list</span>"));
cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
final SingleSelectionModel<I18nTranslationDTO> selectionModel = new SingleSelectionModel<I18nTranslationDTO>(
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorForm.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -140,37 +140,32 @@
item.setText(translation.getText());
item.setDirty(true);
dataProvider.refreshDisplays();
- saver.save(new I18nTranslationDTO(item.getId(), item.getTrKey(), newTranslation));
+ saver.save(new I18nTranslationDTO(item.getId(), item.getTrKey(), newTranslation,
+ item.getParentId(), item.getParentTrKey()));
}
}
public void setInfo(final I18nTranslationDTO item) {
saveIfNeeded();
this.item = item;
- final String[] splitted = splitNT(item.getTrKey());
- toTranslate.setText(splitted[0]);
- final boolean hasNT = splitted.length > 1;
+ final String trKey = item.getTrKey();
+ toTranslate.setText(trKey == null ? item.getParentTrKey() : trKey);
+ translation.setText(item.getText());
+ final boolean hasNT = TextUtils.notEmpty(item.getNoteForTranslators());
noteForTranslators.setVisible(hasNT);
noteForTranslatorsTittle.setVisible(hasNT);
if (hasNT) {
- noteForTranslators.setText(splitted[1]);
+ noteForTranslators.setText(item.getNoteForTranslators());
}
- translation.setText(item.getText());
}
public void setToLanguage(final I18nLanguageSimpleDTO language) {
toLanguageTitle.setText(i18n.tWithNT("to [%s]:", "For example, 'to Spanish':",
language.getEnglishName()));
- }
+ toTranslate.setText("");
+ translation.setText("");
+ noteForTranslators.setVisible(false);
- 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 updateWithTimer() {
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPanel.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -17,26 +17,21 @@
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 = 570;
- private final LanguageSelectorPanel lanSelectorPanel;
+ private final AbstractLanguageSelectorPanel lanSelectorPanel;
private final I18nToTranslateGridPanel toTranslateGrid;
private final I18nTranslatedGridPanel translatedGrid;
private final I18nTranslateRecomendPanel transRecommend;
@Inject
public I18nTranslatorPanel(final I18nTranslationService i18n, final NotifyLevelImages images,
- final I18nTranslatorTabsCollection transGroup, final LanguageSelectorPanel lanSelectorPanel,
+ final I18nTranslatorTabsCollection transGroup,
+ final LanguageSelectorWithoutEnglishPanel lanSelectorPanel,
final I18nToTranslateGridPanel toTranslateGrid, final I18nTranslatedGridPanel translatedGrid,
final I18nTranslateRecomendPanel transRecommend, final CoreResources res) {
super(TRANSLATOR_PANEL_ID, "", 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;
@@ -47,6 +42,12 @@
lanSelectorPanel.setLangTitle(i18n.t("to"));
lanSelectorPanel.setLabelAlign(LabelAlign.RIGHT);
lanSelectorPanel.setLangSeparator(":");
+ lanSelectorPanel.addChangeListener(new SimpleCallback() {
+ @Override
+ public void onCallback() {
+ setLanguage(lanSelectorPanel.getLanguage());
+ }
+ });
}
@Override
Modified: trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/I18nTranslatorPresenter.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -62,7 +62,9 @@
@Override
public void show() {
final I18nLanguageDTO userLang = session.getCurrentLanguage();
- getView().setLanguage(new I18nLanguageSimpleDTO(userLang.getCode(), userLang.getEnglishName()));
+ if (!userLang.getCode().equals("en")) {
+ getView().setLanguage(new I18nLanguageSimpleDTO(userLang.getCode(), userLang.getEnglishName()));
+ }
getView().show();
}
}
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorPanel.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -1,159 +1,15 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
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;
import cc.kune.core.shared.i18n.I18nTranslationService;
-import com.extjs.gxt.ui.client.data.BaseModel;
-import com.extjs.gxt.ui.client.event.BaseEvent;
-import com.extjs.gxt.ui.client.event.Events;
-import com.extjs.gxt.ui.client.event.Listener;
-import com.extjs.gxt.ui.client.store.ListStore;
-import com.extjs.gxt.ui.client.widget.form.ComboBox;
-import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
-import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.google.inject.Inject;
-public class LanguageSelectorPanel extends FormPanel {
+public class LanguageSelectorPanel extends AbstractLanguageSelectorPanel {
- @SuppressWarnings("serial")
- public class LanguageData extends BaseModel {
-
- private static final String CODE = "code";
- private static final String ENGLISH_NAME = "englishName";
-
- public LanguageData(final String code, final String englishName) {
- set(CODE, code);
- set(ENGLISH_NAME, englishName);
- }
-
- public String getCode() {
- return get(CODE);
- }
-
- public String getEnglishName() {
- return get(ENGLISH_NAME);
- }
- }
-
- public static final String LANG_FIELD = "k-langsp-lf";
-
- private final I18nTranslationService i18n;
- private ComboBox<LanguageData> langCombo;
- private final Session session;
-
@Inject
public LanguageSelectorPanel(final I18nTranslationService i18n, final Session session) {
- super();
- this.i18n = i18n;
- this.session = session;
- setBorders(false);
- setFrame(false);
- setHeaderVisible(false);
- createLangCombo();
- super.add(langCombo);
- setBodyBorder(false);
+ super(i18n, session, true);
}
- public void addChangeListener(final SimpleCallback onChange) {
- langCombo.addListener(Events.Select, new Listener<BaseEvent>() {
- @Override
- public void handleEvent(final BaseEvent be) {
- onChange.onCallback();
- }
- });
- }
-
- private void createLangCombo() {
- // Field.setMsgTarget("side");
- langCombo = new ComboBox<LanguageData>();
- langCombo.setName(LANG_FIELD);
- langCombo.setMinChars(1);
- // langCombo.setMode(ComboBox.LOCAL);
- langCombo.setStore(createStore());
- langCombo.setDisplayField("language");
- langCombo.setTriggerAction(TriggerAction.ALL);
- langCombo.setEmptyText(i18n.t("Enter language"));
- langCombo.setLoadingText(i18n.t("Searching..."));
- langCombo.setDisplayField(LanguageData.ENGLISH_NAME);
- langCombo.setValueField(LanguageData.CODE);
- langCombo.setTypeAhead(true);
- langCombo.setTypeAheadDelay(1000);
- langCombo.setSelectOnFocus(false);
- langCombo.setWidth(140);
- langCombo.setPageSize(7);
- langCombo.setForceSelection(true);
- langCombo.setAllowBlank(false);
- }
-
- private ListStore<LanguageData> createStore() {
- final ListStore<LanguageData> list = new ListStore<LanguageData>();
-
- for (final I18nLanguageSimpleDTO lang : session.getLanguages()) {
- list.add(new LanguageData(lang.getCode(), lang.getEnglishName()));
- }
- 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();
- }
-
- public String getLanguageEnglishName() {
- return langCombo.getValue().getEnglishName();
- }
-
- @Override
- public void reset() {
- langCombo.reset();
- }
-
- public void setLangSeparator(final String separator) {
- langCombo.setLabelSeparator(separator);
- }
-
- public void setLangTitle(final String langFieldTitle) {
- if (langFieldTitle == null) {
- setHideLabels(true);
- } else {
- if (langFieldTitle != null) {
- langCombo.setFieldLabel(langFieldTitle);
- }
- }
- }
-
- public void setLanguage(final I18nLanguageSimpleDTO language) {
- langCombo.setRawValue(language.getEnglishName());
- }
}
Added: trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorWithoutEnglishPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorWithoutEnglishPanel.java (rev 0)
+++ trunk/src/main/java/cc/kune/gspace/client/i18n/LanguageSelectorWithoutEnglishPanel.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1,15 @@
+package cc.kune.gspace.client.i18n;
+
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.i18n.I18nTranslationService;
+
+import com.google.inject.Inject;
+
+public class LanguageSelectorWithoutEnglishPanel extends AbstractLanguageSelectorPanel {
+
+ @Inject
+ public LanguageSelectorWithoutEnglishPanel(final I18nTranslationService i18n, final Session session) {
+ super(i18n, session, false);
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/gspace/client/ui/footer/license/EntityLicensePanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/ui/footer/license/EntityLicensePanel.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/java/cc/kune/gspace/client/ui/footer/license/EntityLicensePanel.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -34,54 +34,54 @@
import com.gwtplatform.mvp.client.ViewImpl;
public class EntityLicensePanel extends ViewImpl implements EntityLicenseView {
- public static final String LICENSE_LABEL = "k-elp-lic-lab";
- private final I18nTranslationService i18n;
- private final FlowPanel licenseBar;
- private final Image licenseImage;
- private final Tooltip tooltip;
+ public static final String LICENSE_LABEL = "k-elp-lic-lab";
+ private final I18nTranslationService i18n;
+ private final FlowPanel licenseBar;
+ private final Image licenseImage;
+ private final Tooltip tooltip;
- @Inject
- public EntityLicensePanel(final I18nTranslationService i18n, final GSpaceArmor armor) {
- this.i18n = i18n;
- licenseImage = new Image();
+ @Inject
+ public EntityLicensePanel(final I18nTranslationService i18n, final GSpaceArmor armor) {
+ this.i18n = i18n;
+ licenseImage = new Image();
- licenseBar = new FlowPanel();
- licenseBar.add(licenseImage);
- licenseImage.addStyleName("k-footer-license-img");
- armor.getEntityFooter().add(licenseBar);
- tooltip = Tooltip.to(licenseImage, ".");
- }
+ licenseBar = new FlowPanel();
+ licenseBar.add(licenseImage);
+ licenseImage.addStyleName("k-footer-license-img");
+ armor.getEntityFooter().add(licenseBar);
+ tooltip = Tooltip.to(licenseImage, ".");
+ }
- @Override
- public Widget asWidget() {
- return null;
- }
+ @Override
+ public Widget asWidget() {
+ return null;
+ }
- @Override
- public void attach() {
- licenseBar.setVisible(true);
- }
+ @Override
+ public void attach() {
+ licenseBar.setVisible(true);
+ }
- @Override
- public void detach() {
- licenseBar.setVisible(false);
- }
+ @Override
+ public void detach() {
+ licenseBar.setVisible(false);
+ }
- @Override
- public HasClickHandlers getImage() {
- return licenseImage;
- }
+ @Override
+ public HasClickHandlers getImage() {
+ return licenseImage;
+ }
- @Override
- public void openWindow(final String url) {
- KuneWindowUtils.open(url);
- }
+ @Override
+ public void openWindow(final String url) {
+ KuneWindowUtils.open(url);
+ }
- @Override
- public void showLicense(final String groupName, final LicenseDTO licenseDTO) {
- final String licenseText = i18n.t("© [%s], under license: [%s]", groupName, licenseDTO.getLongName());
- // KuneUiUtils.setQuickTip(licenseLabel, licenseText);
- licenseImage.setUrl(licenseDTO.getImageUrl());
- tooltip.setText(licenseText);
- }
+ @Override
+ public void showLicense(final String groupName, final LicenseDTO licenseDTO) {
+ final String licenseText = i18n.t("© [%s], under license: [%s]", groupName, licenseDTO.getLongName());
+ // KuneUiUtils.setQuickTip(licenseLabel, licenseText);
+ licenseImage.setUrl(licenseDTO.getImageUrl());
+ tooltip.setText(licenseText);
+ }
}
Modified: trunk/src/main/resources/db/liquibase_changelog.xml
===================================================================
--- trunk/src/main/resources/db/liquibase_changelog.xml 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/resources/db/liquibase_changelog.xml 2011-09-19 13:00:39 UTC (rev 1521)
@@ -143,4 +143,10 @@
encoding="utf8" stripComments="1" />
<rollback>SELECT * FROM globalize_countries;</rollback>
</changeSet>
+ <changeSet id="22" author="vjrj">
+ <comment>I18n translations cleanup</comment>
+ <sqlFile path="src/main/resources/db/update-0017-i18nclean2.sql"
+ encoding="utf8" stripComments="1" />
+ <rollback>SELECT * FROM globalize_countries;</rollback>
+ </changeSet>
</databaseChangeLog>
Added: trunk/src/main/resources/db/update-0017-i18nclean2.sql
===================================================================
--- trunk/src/main/resources/db/update-0017-i18nclean2.sql (rev 0)
+++ trunk/src/main/resources/db/update-0017-i18nclean2.sql 2011-09-19 13:00:39 UTC (rev 1521)
@@ -0,0 +1,3 @@
+BEGIN WORK;
+TRUNCATE TABLE globalize_translations;
+COMMIT;
\ No newline at end of file
Modified: trunk/src/main/resources/kune.properties
===================================================================
--- trunk/src/main/resources/kune.properties 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/main/resources/kune.properties 2011-09-19 13:00:39 UTC (rev 1521)
@@ -1,16 +1,13 @@
### kune.properties
-### general
+### general site config
-kune.upload.location = /var/lib/kune/uploads/
-
-### site config
-
kune.siteurl = http://localhost:8080
kune.sitelogourl = images/kune-logo-16px.png
# Every kune site have a group with this name:
+
kune.default.site.name = Site Administration
kune.default.site.shortName = site
kune.site.domain = localhost
@@ -90,12 +87,17 @@
kune.wsthemes.blackwhite.colors = #FFF, #FFF, #000, #FFF, #FFF, #000, #000, #FFF
kune.wsthemes.transparent.backgrounds = transparent, transparent, #e3dbdb, transparent, transparent, #e3dbdb, transparent, transparent
kune.wsthemes.transparent.colors = #000, #000, #000, #000, #000, #000, #000, #000
-### Gallery options
-kune.upload.gallerypermittedextensions = jpg,jpeg,png,gif,bmp,svg,avi,mpg,mpeg,ogg,mov,tif,tiff,mp3,wav
+### Uploads
+
+kune.upload.location = /var/lib/kune/uploads/
kune.upload.maxfilesizeinmegas = 10
kune.upload.maxfilesizeinks = 10000000
kune.upload.delayfortest = 50
+
+### Gallery options
+kune.upload.gallerypermittedextensions = jpg,jpeg,png,gif,bmp,svg,avi,mpg,mpeg,ogg,mov,tif,tiff,mp3,wav
+
# Images are resized to thumbsize pixels and later cropped (centered) to cropsize
# (integer values)
kune.images.resizewidth = 400
Modified: trunk/src/test/java/cc/kune/core/client/i18n/I18nUtilsTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/i18n/I18nUtilsTest.java 2011-09-16 00:01:50 UTC (rev 1520)
+++ trunk/src/test/java/cc/kune/core/client/i18n/I18nUtilsTest.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -24,6 +24,8 @@
@Test
public void basicTests() {
assertEquals("yesOrNo", I18nUtils.convertMethodName("yes, or & no?"));
+ assertEquals("yesOrNo", I18nUtils.convertMethodName("yes or no"));
+ assertEquals("yesOrNo", I18nUtils.convertMethodName("yes or no"));
}
@Test
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-16 00:01:50 UTC (rev 1520)
+++ trunk/src/test/java/cc/kune/core/server/manager/I18nManagerDefaultTest.java 2011-09-19 13:00:39 UTC (rev 1521)
@@ -74,8 +74,10 @@
final int initialSize = map.size();
final int initialSize2 = map2.size();
- final String translation = translationManager.getTranslation("es", "Foo foo foo");
- final String translation2 = translationManager.getTranslation("aa", "Foo foo foo");
+ final String translation = translationManager.getTranslation("es", "Foo foo foo",
+ "note for translators");
+ final String translation2 = translationManager.getTranslation("aa", "Foo foo foo",
+ "note for translators");
assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation);
assertEquals(I18nTranslation.UNTRANSLATED_VALUE, translation2);
@@ -91,47 +93,32 @@
@Test
public void getNonExistentTranslationReturnsDefaultLanguage() {
- final String translation = translationManager.getTranslation("af", "January [month]");
+ final String translation = translationManager.getTranslation("af", "January [month]",
+ "note for translators");
assertEquals("January", translation);
}
@Test
public void getTranslation() {
- final String translation = translationManager.getTranslation("af", "Sunday [weekday]");
+ final String translation = translationManager.getTranslation("af", "Sunday [weekday]",
+ "note for translators");
assertEquals("Sondag", translation);
}
@Test
public void getTranslationUTF8() {
- final String translation = translationManager.getTranslation("el", "January [month]");
+ final String translation = translationManager.getTranslation("el", "January [month]",
+ "note for translators");
assertEquals("Ιανουάριος", translation);
}
@Test
- public void getTranslationWithIntArg() {
- final String translation = translationManager.getTranslation("en", "[%d] users", 20);
- assertEquals("20 users", translation);
- }
-
- @Test
public void getTranslationWithIntArgFromService() {
final String translation = translationService.t("[%d] users", 20);
assertEquals("20 users", translation);
}
@Test
- public void getTranslationWithIntArgFromWithNtService() {
- final String translation = translationService.tWithNT("[%d] users", "foo foo", 20);
- assertEquals("20 users", translation);
- }
-
- @Test
- public void getTranslationWithStringArg() {
- final String translation = translationManager.getTranslation("en", "[%s] users", "Twenty");
- assertEquals("Twenty users", translation);
- }
-
- @Test
public void getTranslationWithStringArgFromService() {
final String translation = translationService.t("[%s] users", "Twenty");
assertEquals("Twenty users", translation);
@@ -154,27 +141,24 @@
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("Sunday [weekday]", english, "Sunday",
+ "note for translators"));
+ translationManager.persist(new I18nTranslation("January [month]", english, "January",
+ "note for translators"));
+ translationManager.persist(new I18nTranslation("Sunday [weekday]", afrikaans, "Sondag",
+ "note for translators"));
+ translationManager.persist(new I18nTranslation("January [month]", greek, "Ιανουάριος",
+ "note for translators"));
translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%s] users"), english,
- StringEscapeUtils.escapeHtml("[%s] users")));
+ StringEscapeUtils.escapeHtml("[%s] users"), "note for translators"));
translationManager.persist(new I18nTranslation(StringEscapeUtils.escapeHtml("[%d] users"), english,
- StringEscapeUtils.escapeHtml("[%d] users")));
+ StringEscapeUtils.escapeHtml("[%d] users"), "note for translators"));
final I18nCountry gb = new I18nCountry(Long.valueOf(75), "GB", "GBP", ".", "£%n", "", ".",
"United Kingdom", "western", ",");
countryManager.persist(gb);
}
@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