ISIS-903: refactoring in the direction of also reading .po files
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/759e322c Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/759e322c Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/759e322c Branch: refs/heads/master Commit: 759e322c1990aec4c816c1cb45d7500103309060 Parents: 67e234b Author: Dan Haywood <[email protected]> Authored: Fri Feb 13 18:57:49 2015 +0000 Committer: Dan Haywood <[email protected]> Committed: Wed Feb 18 14:07:30 2015 +0000 ---------------------------------------------------------------------- .../i18n/TranslatableMessagesService.java | 96 ----------------- .../services/i18n/TranslationService.java | 14 --- .../isis/applib/services/i18n/TrStringTest.java | 6 -- .../facets/all/i18n/I18nFacetFactory.java | 2 +- .../i18n/TranslationServiceLogging.java | 72 ------------- .../services/i18n/TranslationServicePoMenu.java | 71 +++++++++++++ .../services/i18n/po/MsgIdAndContext.java | 70 +++++++++++++ .../metamodel/services/i18n/po/PoAbstract.java | 39 +++++++ .../metamodel/services/i18n/po/PoReader.java | 70 +++++++++++++ .../metamodel/services/i18n/po/PotWriter.java | 102 +++++++++++++++++++ .../services/ServicesInstallerFallback.java | 4 +- 11 files changed, 355 insertions(+), 191 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableMessagesService.java ---------------------------------------------------------------------- diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableMessagesService.java b/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableMessagesService.java deleted file mode 100644 index 63b6fad..0000000 --- a/core/applib/src/main/java/org/apache/isis/applib/services/i18n/TranslatableMessagesService.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.isis.applib.services.i18n; - -import java.util.Collection; -import java.util.Map; -import java.util.Properties; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import org.apache.isis.applib.annotation.Action; -import org.apache.isis.applib.annotation.ActionLayout; -import org.apache.isis.applib.annotation.DomainService; -import org.apache.isis.applib.annotation.DomainServiceLayout; -import org.apache.isis.applib.annotation.NatureOfService; -import org.apache.isis.applib.annotation.ParameterLayout; -import org.apache.isis.applib.annotation.Programmatic; -import org.apache.isis.applib.annotation.SemanticsOf; -import org.apache.isis.applib.value.Clob; - -@DomainService( - nature = NatureOfService.VIEW_MENU_ONLY -) -@DomainServiceLayout( - menuBar = DomainServiceLayout.MenuBar.SECONDARY, - named = "Prototyping" -) -public class TranslatableMessagesService { - - @Programmatic - @PostConstruct - public void init(final Map<String,String> config) { - final Properties props = new Properties(); - for (final String key : config.keySet()) { - props.put(key, config.get(key)); - } - props.list(System.out); - } - - @Programmatic - @PreDestroy - public void shutdown() { - - } - - - @Action( - semantics = SemanticsOf.SAFE - ) - @ActionLayout( - cssClassFa = "fa-download" - ) - public Clob downloadPotFile( - @ParameterLayout(named = ".pot file name") - final String potFileName) { - final Map<String, Collection<String>> messages = translationService.messages(); - final StringBuilder buf = new StringBuilder(); - for (String message : messages.keySet()) { - final Collection<String> contexts = messages.get(message); - for (String context : contexts) { - buf.append("#: ").append(context).append("\n"); - } - buf.append("msgid: \"").append(message).append("\"\n"); - buf.append("msgstr: \"\"\n"); - buf.append("\n\n\n"); - } - return new Clob(potFileName, "text/plain", buf.toString()); - } - - public String default0DownloadPotFile() { - return "myapp.pot"; - } - - // ////////////////////////////////////// - - - @Inject - private TranslationService translationService; - -} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/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 6204cdd..df182ad 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 @@ -18,9 +18,7 @@ */ package org.apache.isis.applib.services.i18n; -import java.util.Collection; import java.util.Locale; -import java.util.Map; import org.apache.isis.applib.annotation.Programmatic; public interface TranslationService { @@ -28,17 +26,5 @@ public interface TranslationService { @Programmatic public String translate(final String context, final String originalText, final Locale targetLocale); - /** - * Returns the set of messages encountered and cached by the service (the key of the map) along with a set of - * context strings (the value of the map) - * - * <p> - * The intention is that an implementation running in prototype mode should retain all requests to - * {@link #translate(String, String, java.util.Locale)}, such that they can be translated and used by the - * same implementation in non-prototype mode. - * </p> - */ - @Programmatic - public Map<String, Collection<String>> messages(); } http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/applib/src/test/java/org/apache/isis/applib/services/i18n/TrStringTest.java ---------------------------------------------------------------------- diff --git a/core/applib/src/test/java/org/apache/isis/applib/services/i18n/TrStringTest.java b/core/applib/src/test/java/org/apache/isis/applib/services/i18n/TrStringTest.java index 552f9e1..7399a2d 100644 --- a/core/applib/src/test/java/org/apache/isis/applib/services/i18n/TrStringTest.java +++ b/core/applib/src/test/java/org/apache/isis/applib/services/i18n/TrStringTest.java @@ -1,8 +1,6 @@ package org.apache.isis.applib.services.i18n; -import java.util.Collection; import java.util.Locale; -import java.util.Map; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -76,10 +74,6 @@ public class TrStringTest { originalTextToTranslate = originalText; return originalText; } - @Override - public Map<String, Collection<String>> messages() { - return null; - } }; } http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/I18nFacetFactory.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/I18nFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/I18nFacetFactory.java index 6761b04..f866f94 100644 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/I18nFacetFactory.java +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/all/i18n/I18nFacetFactory.java @@ -151,7 +151,7 @@ public class I18nFacetFactory extends FacetFactoryAbstract implements Contribute /** * Looks up from {@link org.apache.isis.core.metamodel.runtimecontext.ServicesInjector}, otherwise defaults to - * {@link org.apache.isis.core.metamodel.services.i18n.TranslationServiceLogging}. + * {@link org.apache.isis.core.metamodel.services.i18n.po.TranslationServicePo}. */ TranslationService lookupTranslationService() { if(translationService == null) { http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServiceLogging.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServiceLogging.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServiceLogging.java deleted file mode 100644 index e4f8467..0000000 --- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServiceLogging.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.isis.core.metamodel.services.i18n; - -import java.util.Collection; -import java.util.Locale; -import java.util.Map; -import java.util.NavigableSet; -import com.google.common.collect.TreeMultimap; -import org.joda.time.LocalDateTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.isis.applib.annotation.Programmatic; -import org.apache.isis.applib.services.i18n.TranslationService; - -/** - * Not annotated with @DomainService, but is registered as a fallback by <tt>ServicesInstallerFallback</tt>. - */ -public class TranslationServiceLogging implements TranslationService { - - public static Logger LOG = LoggerFactory.getLogger(TranslationServiceLogging.class); - - private final TreeMultimap<String, String> messages = TreeMultimap.create(); - - public TranslationServiceLogging() { - - LOG.info(""); - LOG.info(""); - LOG.info(""); - LOG.info("################################################################################"); - LOG.info("#"); - LOG.info("# " + LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss")); - LOG.info("#"); - LOG.info("################################################################################"); - LOG.info(""); - LOG.info(""); - - } - - @Override - @Programmatic - public String translate(final String context, final String originalText, final Locale targetLocale) { - - final NavigableSet<String> contexts = messages.get(originalText); - final boolean added = contexts.add(context); - if(added) { - LOG.info(String.format("%s_%s: %s", targetLocale.getISO3Country(), targetLocale.getISO3Language(), originalText)); - } - return originalText; - } - - @Programmatic - public Map<String, Collection<String>> messages() { - return messages.asMap(); - } -} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java new file mode 100644 index 0000000..1e38bc5 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/TranslationServicePoMenu.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.core.metamodel.services.i18n; + +import javax.inject.Inject; +import org.apache.isis.applib.annotation.Action; +import org.apache.isis.applib.annotation.ActionLayout; +import org.apache.isis.applib.annotation.DomainService; +import org.apache.isis.applib.annotation.DomainServiceLayout; +import org.apache.isis.applib.annotation.NatureOfService; +import org.apache.isis.applib.annotation.ParameterLayout; +import org.apache.isis.applib.annotation.RestrictTo; +import org.apache.isis.applib.annotation.SemanticsOf; +import org.apache.isis.applib.value.Clob; +import org.apache.isis.core.metamodel.services.i18n.po.TranslationServicePo; + +@DomainService( + nature = NatureOfService.VIEW_MENU_ONLY +) +@DomainServiceLayout( + menuBar = DomainServiceLayout.MenuBar.SECONDARY, + named = "Prototyping" +) +public class TranslationServicePoMenu { + + private boolean prototype; + + @Action( + semantics = SemanticsOf.SAFE, + restrictTo = RestrictTo.PROTOTYPING + ) + @ActionLayout( + cssClassFa = "fa-download" + ) + public Clob downloadPotFile( + @ParameterLayout(named = ".pot file name") + final String potFileName) { + final String chars = translationService.toPo(); + return new Clob(potFileName, "text/plain", chars); + } + + public String default0DownloadPotFile() { + return "myapp.pot"; + } + public boolean hideDownloadPotFile() { + return translationService == null; + } + + // ////////////////////////////////////// + + + @Inject + private TranslationServicePo translationService; + +} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/MsgIdAndContext.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/MsgIdAndContext.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/MsgIdAndContext.java new file mode 100644 index 0000000..f7fbd65 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/MsgIdAndContext.java @@ -0,0 +1,70 @@ +package org.apache.isis.core.metamodel.services.i18n.po; + +/** + * The combination of a <tt>msgId</tt> and context (optionally null) that represents a key to a translatable resource. + * + * <p> + * For example, with this <i>.pot</i> file: + * </p> + * <pre> + * #: org.isisaddons.module.sessionlogger.dom.SessionLoggingServiceMenu#activeSessions() + msgid: "Active Sessions" + + #: org.isisaddons.module.audit.dom.AuditingServiceMenu + #: org.isisaddons.module.command.dom.CommandServiceMenu + #: org.isisaddons.module.publishing.dom.PublishingServiceMenu + msgid: "Activity" + + * </pre> + * + * <p> + * the combination of <code>{org.isisaddons.module.sessionlogger.dom.SessionLoggingServiceMenu#activeSessions(), "Active Sessions"}</code> represents such a key, as does <code>{org.isisaddons.module.audit.dom.AuditingServiceMenu, "Activity"}</code> + * </p> + */ +public class MsgIdAndContext implements Comparable<MsgIdAndContext> { + + private final String context; + private final String msgId; + + public MsgIdAndContext(final String msgId, final String context) { + this.msgId = msgId; + this.context = context == null? "": context; + } + + public String getMsgId() { + return msgId; + } + + public String getContext() { + return context; + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final MsgIdAndContext that = (MsgIdAndContext) o; + + if (context != null ? !context.equals(that.context) : that.context != null) return false; + if (msgId != null ? !msgId.equals(that.msgId) : that.msgId != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = context != null ? context.hashCode() : 0; + result = 31 * result + (msgId != null ? msgId.hashCode() : 0); + return result; + } + + @Override + public int compareTo(final MsgIdAndContext o) { + final int i = msgId.compareTo(o.msgId); + if(i != 0) { + return i; + } + return context.compareTo(o.context); + } +} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoAbstract.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoAbstract.java new file mode 100644 index 0000000..b910984 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoAbstract.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.core.metamodel.services.i18n.po; + +import java.util.Locale; +import java.util.Map; + +abstract class PoAbstract { + + protected final TranslationServicePo translationServicePo; + + PoAbstract(final TranslationServicePo translationServicePo) { + this.translationServicePo = translationServicePo; + } + + + abstract void init(final Map<String,String> config); + + abstract void shutdown(); + + abstract String translate(final String context, final String msgId, final Locale targetLocale); + +} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java new file mode 100644 index 0000000..293488f --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PoReader.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.core.metamodel.services.i18n.po; + +import java.util.Locale; +import java.util.Map; +import com.google.common.collect.Maps; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class PoReader extends PoAbstract { + + public static Logger LOG = LoggerFactory.getLogger(PoReader.class); + + private final Map<Locale, Map<MsgIdAndContext, String>> translationByKeyByLocale = Maps.newHashMap(); + + public PoReader(final TranslationServicePo translationServicePo) { + super(translationServicePo); + } + + //region > init, shutdown + void init(final Map<String,String> config) { + } + + void shutdown() { + } + //endregion + + + public String translate(final String context, final String msgId, final Locale targetLocale) { + + Map<MsgIdAndContext, String> translationByKey = translationByKeyByLocale.get(targetLocale); + if(translationByKey == null) { + translationByKey = Maps.newTreeMap(); + translationByKeyByLocale.put(targetLocale, translationByKey); + } + + final MsgIdAndContext key = new MsgIdAndContext(msgId, context); + String translation = translationByKey.get(key); + if (translation == null) { + translation = translate(targetLocale, key); + translationByKey.put(key, translation); + } + + return translation; + } + + private String translate(final Locale locale, final MsgIdAndContext key) { + // TODO + return key.getMsgId(); + } + + +} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PotWriter.java ---------------------------------------------------------------------- diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PotWriter.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PotWriter.java new file mode 100644 index 0000000..6247c86 --- /dev/null +++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/i18n/po/PotWriter.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.core.metamodel.services.i18n.po; + +import java.util.Collection; +import java.util.Locale; +import java.util.Map; +import java.util.NavigableSet; +import com.google.common.collect.TreeMultimap; +import org.joda.time.LocalDateTime; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class PotWriter extends PoAbstract { + + public static Logger LOG = LoggerFactory.getLogger(PotWriter.class); + + private final TreeMultimap<String, String> contextsByMsgId = TreeMultimap.create(); + + public PotWriter(final TranslationServicePo translationServicePo) { + super(translationServicePo); + } + + + //region > init, shutdown + void init(final Map<String,String> config) { + } + + void shutdown() { + LOG.info(""); + LOG.info(""); + LOG.info("################################################################################"); + LOG.info("#"); + LOG.info("# " + LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss")); + LOG.info("#"); + LOG.info("################################################################################"); + LOG.info(""); + LOG.info(""); + LOG.info(""); + LOG.info(toPo()); + LOG.info(""); + LOG.info(""); + LOG.info(""); + } + //endregion + + + public String translate(final String context, final String originalText, final Locale targetLocale) { + final NavigableSet<String> contexts = contextsByMsgId.get(originalText); + contexts.add(context); + return originalText; + } + + /** + * Not API + */ + String toPo() { + final Map<String, Collection<String>> messages = messagesWithContext(); + final StringBuilder buf = new StringBuilder(); + for (String message : messages.keySet()) { + final Collection<String> contexts = messages.get(message); + for (String context : contexts) { + buf.append("#: ").append(context).append("\n"); + } + buf.append("msgid: \"").append(message).append("\"\n"); + buf.append("msgstr: \"\"\n"); + buf.append("\n\n\n"); + } + return buf.toString(); + } + + /** + * Returns the set of messages encountered and cached by the service (the key of the map) along with a set of + * context strings (the value of the map) + * + * <p> + * The intention is that an implementation running in prototype mode should retain all requests to + * {@link #translate(String, String, java.util.Locale)}, such that they can be translated and used by the + * same implementation in non-prototype mode. + * </p> + */ + Map<String, Collection<String>> messagesWithContext() { + return contextsByMsgId.asMap(); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/759e322c/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFallback.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFallback.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFallback.java index dcf4ed0..9f560ce 100644 --- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFallback.java +++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFallback.java @@ -25,7 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.isis.core.commons.config.InstallerAbstract; import org.apache.isis.core.metamodel.services.i18n.LocaleProviderDefault; -import org.apache.isis.core.metamodel.services.i18n.TranslationServiceLogging; +import org.apache.isis.core.metamodel.services.i18n.po.TranslationServicePo; import org.apache.isis.core.runtime.system.DeploymentType; public class ServicesInstallerFallback extends InstallerAbstract implements ServicesInstaller { @@ -38,7 +38,7 @@ public class ServicesInstallerFallback extends InstallerAbstract implements Serv @Override public List<Object> getServices(final DeploymentType deploymentType) { - return Lists.newArrayList(new TranslationServiceLogging(), new LocaleProviderDefault()); + return Lists.newArrayList(new TranslationServicePo(), new LocaleProviderDefault()); } @Override
