Search in sources :

Example 1 with ComponentMessagesSource

use of org.apache.tapestry5.services.messages.ComponentMessagesSource in project tapestry-5 by apache.

the class JavaScriptModule method setupApplicationCatalogModules.

@Contribute(ModuleManager.class)
public static void setupApplicationCatalogModules(MappedConfiguration<String, Object> configuration, LocalizationSetter localizationSetter, ComponentMessagesSource messagesSource, ResourceChangeTracker resourceChangeTracker, @Symbol(SymbolConstants.COMPACT_JSON) boolean compactJSON) {
    for (Locale locale : localizationSetter.getSupportedLocales()) {
        MessageCatalogResource resource = new MessageCatalogResource(locale, messagesSource, resourceChangeTracker, compactJSON);
        configuration.add("t5/core/messages/" + locale.toString(), new JavaScriptModuleConfiguration(resource));
    }
}
Also used : Locale(java.util.Locale) MessageCatalogResource(org.apache.tapestry5.internal.util.MessageCatalogResource) JavaScriptModuleConfiguration(org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 2 with ComponentMessagesSource

use of org.apache.tapestry5.services.messages.ComponentMessagesSource in project tapestry-5 by apache.

the class ComponentMessagesSourceImplTest method no_app_catalog.

@Test
public void no_app_catalog() {
    ComponentModel model = mockComponentModel();
    ComponentModel parent = mockComponentModel();
    train_getComponentClassName(model, "org.apache.tapestry5.internal.services.SubclassComponent");
    train_getBaseResource(model, new ClasspathResource("org/apache/tapestry5/internal/services/SubclassComponent.class"));
    train_getParentModel(model, parent);
    train_getComponentClassName(parent, SIMPLE_COMPONENT_CLASS_NAME);
    train_getBaseResource(parent, simpleComponentResource);
    train_getParentModel(parent, null);
    replay();
    forceCacheClear();
    Resource resource = simpleComponentResource.forFile("NoSuchAppCatalog.properties");
    List<Resource> resources = Arrays.asList(resource);
    ComponentMessagesSource source = new ComponentMessagesSourceImpl(true, resources, new PropertiesFileParserImpl(), resourceLocator, converter, componentRequestSelectorAnalyzer, threadLocale);
    Messages messages = source.getMessages(model, Locale.ENGLISH);
    assertEquals(messages.get("color"), "color");
    assertEquals(messages.get("app-catalog-source"), "[[missing key: app-catalog-source]]");
    assertEquals(messages.get("app-catalog-overridden"), "Overridden by Component");
    verify();
}
Also used : ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) PropertiesFileParserImpl(org.apache.tapestry5.internal.services.messages.PropertiesFileParserImpl) Messages(org.apache.tapestry5.commons.Messages) ComponentModel(org.apache.tapestry5.model.ComponentModel) Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) ComponentMessagesSource(org.apache.tapestry5.services.messages.ComponentMessagesSource) Test(org.testng.annotations.Test)

Aggregations

Locale (java.util.Locale)1 Messages (org.apache.tapestry5.commons.Messages)1 Resource (org.apache.tapestry5.commons.Resource)1 PropertiesFileParserImpl (org.apache.tapestry5.internal.services.messages.PropertiesFileParserImpl)1 MessageCatalogResource (org.apache.tapestry5.internal.util.MessageCatalogResource)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)1 ComponentModel (org.apache.tapestry5.model.ComponentModel)1 JavaScriptModuleConfiguration (org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration)1 ComponentMessagesSource (org.apache.tapestry5.services.messages.ComponentMessagesSource)1 Test (org.testng.annotations.Test)1