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));
}
}
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();
}
Aggregations