You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/02/18 18:09:04 UTC
isis git commit: ISIS-903: remove caching from the *FacetTranslated
Repository: isis
Updated Branches:
refs/heads/master 3b1d857d5 -> 7e7071422
ISIS-903: remove caching from the *FacetTranslated
... otherwise never re-renders correctly for concurrent users with different locales.
In addition:
- fixed tiny error in logging.properties (for simpleapp integtest)
- additional translations_en-GB.po for simpleapp
- javadoc fixes.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/7e707142
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/7e707142
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/7e707142
Branch: refs/heads/master
Commit: 7e7071422658b7b0e0110f177edff446f8d64094
Parents: 3b1d857
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Feb 18 17:08:29 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Feb 18 17:08:29 2015 +0000
----------------------------------------------------------------------
.../services/i18n/TranslatableString.java | 4 +-
.../services/i18n/TranslationService.java | 13 +-
.../all/i18n/DescribedAsFacetTranslated.java | 19 +--
.../facets/all/i18n/NamedFacetTranslated.java | 19 +--
.../simpleapp/integtests/logging.properties | 2 +-
.../src/main/webapp/WEB-INF/translations.po | 13 +-
.../main/webapp/WEB-INF/translations_en-GB.po | 149 +++++++++++++++++++
7 files changed, 174 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableString.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableString.java b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableString.java
index 5ab8eb5..47af1bc 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableString.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableString.java
@@ -30,7 +30,7 @@ public final class TranslatableString {
//region > tr, trn (factory methods); constructor
/**
- * A translatable string supporting both singular and plural forms.
+ * A translatable string with a single pattern for both singular and plural forms.
*
* @param pattern - pattern for all (singular and plural) form, with <code>${xxx}</code> placeholders
* @param paramArgs - parameter/argument pairs (string and object, string and object, ...)
@@ -42,7 +42,7 @@ public final class TranslatableString {
}
/**
- * A translatable string supporting both singular and plural forms.
+ * A translatable string with different patterns for singular and plural forms, selected automatically by the number
*
* @param singularPattern - pattern for the singular form, with <code>${xxx}</code> placeholders
* @param pluralPattern - pattern for the singular form, with <code>${xxx}</code> placeholders
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
index fc6eb1c..8a1ef5e 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslationService.java
@@ -23,7 +23,11 @@ import org.apache.isis.applib.annotation.Programmatic;
public interface TranslationService {
/**
- * Return a translation of the text, for the specified locale.
+ * Return a translation of the text, in the locale of the "current user".
+ *
+ * <p>
+ * The mechanism to determine the locale is implementation-specific.
+ * </p>
*
* @param context
* @param text
@@ -33,7 +37,12 @@ public interface TranslationService {
public String translate(final String context, final String text);
/**
- * Return a translation of either the singular or the plural text, dependent on the <tt>num</tt> parameter, for the specified locale.
+ * Return a translation of either the singular or the plural text, dependent on the <tt>num</tt> parameter,
+ * in the locale of the "current user".
+ *
+ * <p>
+ * The mechanism to determine the locale is implementation-specific.
+ * </p>
*
* @param context
* @param singularText
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/DescribedAsFacetTranslated.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/DescribedAsFacetTranslated.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/DescribedAsFacetTranslated.java
index 380f7e8..470a946 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/DescribedAsFacetTranslated.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/DescribedAsFacetTranslated.java
@@ -49,24 +49,7 @@ public class DescribedAsFacetTranslated extends FacetAbstract implements Describ
@Override
public String value() {
- // this strange algorithm is because the translationService's mode changes
- // between the time the metamodel is first built and when it is subsequently
- // used. We can't distinguish (when in write mode) as to whether it is
- // because we are in startup (prior to init'ing the services) or whether in
- // prototype mode. We therefore never cache if in write mode (this ensures that
- // the PoWriter gets to see the translation request) but do then start caching
- // if we find that we're in read mode (after init of the TranslationServicePo).
- switch (translationService.getMode()) {
- case WRITE:
- return translateText();
- case READ:
- // don't cache
- if(value == null) {
- value = translateText();
- }
- break;
- }
- return value;
+ return translateText();
}
private String translateText() {
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/NamedFacetTranslated.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/NamedFacetTranslated.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/NamedFacetTranslated.java
index 15800d9..0a84993 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/NamedFacetTranslated.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/NamedFacetTranslated.java
@@ -49,24 +49,7 @@ public class NamedFacetTranslated extends FacetAbstract implements NamedFacet {
@Override
public String value() {
- // this strange algorithm is because the translationService's mode changes
- // between the time the metamodel is first built and when it is subsequently
- // used. We can't distinguish (when in write mode) as to whether it is
- // because we are in startup (prior to init'ing the services) or whether in
- // prototype mode. We therefore never cache if in write mode (this ensures that
- // the PoWriter gets to see the translation request) but do then start caching
- // if we find that we're in read mode (after init of the TranslationServicePo).
- switch (translationService.getMode()) {
- case WRITE:
- return translateText();
- case READ:
- // don't cache
- if(value == null) {
- value = translateText();
- }
- break;
- }
- return value;
+ return translateText();
}
private String translateText() {
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/example/application/simpleapp/integtests/logging.properties
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/integtests/logging.properties b/example/application/simpleapp/integtests/logging.properties
index d6d3905..b552495 100644
--- a/example/application/simpleapp/integtests/logging.properties
+++ b/example/application/simpleapp/integtests/logging.properties
@@ -35,7 +35,7 @@ log4j.appender.File.layout.ConversionPattern=%d [%-20c{1} %-10t %-5p] %m%n
log4j.appender.translations-po=org.apache.log4j.FileAppender
log4j.appender.translations-po.File=./translations.pot
-log4j.appender.translationsn-po.Append=false
+log4j.appender.translations-po.Append=false
log4j.appender.translations-po.layout=org.apache.log4j.PatternLayout
log4j.appender.translations-po.layout.ConversionPattern=%m%n
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations.po
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations.po b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations.po
index a131802..9acd4ee 100644
--- a/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations.po
+++ b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations.po
@@ -12,18 +12,23 @@
#
##############################################################################
-#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadPotFile(java.lang.String)
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadTranslations(java.lang.String)
msgid ".pot file name"
msgstr ""
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#resetTranslationCache()
+msgid "Clear translation cache"
+msgstr ""
+
+
#: dom.simple.SimpleObjects#create()
msgid "Create"
msgstr ""
-#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadPotFile()
-msgid "Download Pot File"
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadTranslations()
+msgid "Download Translations"
msgstr ""
@@ -71,7 +76,7 @@ msgstr ""
#: dom.simple.SimpleObject#title()
msgid "Object: {name}"
-msgstr "'{name}'"
+msgstr ""
#: fixture.simple.SimpleObjectsFixturesService#runFixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript,java.lang.String)
http://git-wip-us.apache.org/repos/asf/isis/blob/7e707142/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations_en-GB.po
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations_en-GB.po b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations_en-GB.po
new file mode 100644
index 0000000..1a5f4ec
--- /dev/null
+++ b/example/application/simpleapp/webapp/src/main/webapp/WEB-INF/translations_en-GB.po
@@ -0,0 +1,149 @@
+##############################################################################
+#
+# .pot file
+#
+# Translate this file to each required language and place in WEB-INF, eg:
+#
+# /WEB-INF/translations_en-US.po
+# /WEB-INF/translations_en.po
+# /WEB-INF/translations_fr-FR.po
+# /WEB-INF/translations_fr.po
+# /WEB-INF/translations.po
+#
+##############################################################################
+
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadTranslations(java.lang.String)
+msgid ".pot file name"
+msgstr ""
+
+
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#resetTranslationCache()
+msgid "Clear translation cache"
+msgstr "Reload .po files"
+
+
+#: dom.simple.SimpleObjects#create()
+msgid "Create"
+msgstr ""
+
+
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu#downloadTranslations()
+msgid "Download Translations"
+msgstr "Download .pot file"
+
+
+#: dom.simple.SimpleObject#updateName()
+msgid "Exclamation mark is not allowed"
+msgstr "No exclamation marks, chum!"
+
+
+#: org.apache.isis.applib.fixturescripts.FixtureResult#fixtureScriptClassName
+msgid "Fixture script"
+msgstr ""
+
+
+#: org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault#isViewModel()
+msgid "Is View Model"
+msgstr ""
+
+
+#: dom.simple.SimpleObjects#listAll()
+msgid "List All"
+msgstr ""
+
+
+#: fixture.simple.scenario.RecreateSimpleObjects#lookup()
+#: org.apache.isis.applib.fixturescripts.FixtureScript#lookup()
+#: org.apache.isis.applib.services.bookmark.BookmarkHolderActionContributions#lookup()
+msgid "Lookup"
+msgstr ""
+
+
+#: dom.simple.SimpleObjects#create(java.lang.String)
+msgid "Name"
+msgstr ""
+
+
+#: dom.simple.SimpleObject#updateName(java.lang.String)
+msgid "New name"
+msgstr ""
+
+
+#: org.apache.isis.applib.services.bookmark.BookmarkHolderAssociationContributions#object()
+msgid "Object"
+msgstr ""
+
+
+#: dom.simple.SimpleObject#title()
+msgid "Object: {name}"
+msgstr ""
+
+
+#: fixture.simple.SimpleObjectsFixturesService#runFixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript,java.lang.String)
+#: org.apache.isis.applib.fixturescripts.FixtureScripts#runFixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript,java.lang.String)
+msgid "Parameters"
+msgstr ""
+
+
+#: fixture.simple.SimpleObjectsFixturesService
+#: org.apache.isis.core.runtime.services.i18n.po.TranslationServicePoMenu
+msgid "Prototyping"
+msgstr ""
+
+
+#: fixture.simple.SimpleObjectsFixturesService#recreateObjectsAndReturnFirst()
+msgid "Recreate Objects And Return First"
+msgstr ""
+
+
+#: org.apache.isis.applib.fixturescripts.FixtureResult#object
+msgid "Result"
+msgstr ""
+
+
+#: org.apache.isis.applib.fixturescripts.FixtureResult#className
+msgid "Result class"
+msgstr ""
+
+
+#: org.apache.isis.applib.fixturescripts.FixtureResult#key
+msgid "Result key"
+msgstr ""
+
+
+#: fixture.simple.SimpleObjectsFixturesService#runFixtureScript()
+#: org.apache.isis.applib.fixturescripts.FixtureScripts#runFixtureScript()
+msgid "Run Fixture Script"
+msgstr ""
+
+
+#: fixture.simple.scenario.RecreateSimpleObjects
+#: org.apache.isis.applib.fixturescripts.FixtureScript
+msgid "Script"
+msgstr ""
+
+
+#: fixture.simple.SimpleObjectsFixturesService#runFixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript,java.lang.String)
+#: org.apache.isis.applib.fixturescripts.FixtureScripts#runFixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript,java.lang.String)
+msgid "Script-specific parameters (if any). The format depends on the script implementation (eg key=value, CSV, JSON, XML etc)"
+msgstr ""
+
+
+#: dom.simple.SimpleObject#updateName()
+msgid "Update Name"
+msgstr ""
+
+
+#: fixture.simple.scenario.RecreateSimpleObjects#withDiscoverability()
+#: org.apache.isis.applib.fixturescripts.FixtureScript#withDiscoverability()
+msgid "With Discoverability"
+msgstr ""
+
+
+
+
+
+##############################################################################
+# end of .pot file
+##############################################################################
+