use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method no_extra_context.
private void no_extra_context(boolean finalSlash) throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest(false);
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = neverWhitelistProtected();
String path = "/foo/Bar" + (finalSlash ? "/" : "");
train_getPath(request, path);
train_setLocaleFromLocaleName(ls, "foo", false);
train_isPageName(resolver, "foo/Bar", true);
train_canonicalizePageName(resolver, "foo/Bar", "foo/bar");
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, null, null, null, null, true, null, "", metaDataLocator, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertEquals(parameters.getLogicalPageName(), "foo/bar");
assertEquals(parameters.getActivationContext().getCount(), 0);
assertFalse(parameters.isLoopback());
verify();
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class LocalizationSetterImplTest method get_locale_model.
@Test
public void get_locale_model() {
LocalizationSetter setter = new LocalizationSetterImpl(null, null, null, "en,fr");
SelectModel model = setter.getSupportedLocalesModel();
assertNull(model.getOptionGroups());
List<OptionModel> options = model.getOptions();
assertEquals(options.size(), 2);
assertEquals(options.get(0).getLabel(), "English");
// Note that the label is localized to the underlying locale, not the default locale.
// That's why its "français" (i.e., as a French speaker would say it), not "French"
// (like an English speaker).
assertEquals(options.get(1).getLabel(), "fran\u00e7ais");
assertEquals(options.get(0).getValue(), Locale.ENGLISH);
assertEquals(options.get(1).getValue(), Locale.FRENCH);
}
use of org.apache.tapestry5.services.LocalizationSetter 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.LocalizationSetter in project tapestry-5 by apache.
the class JavaScriptModule method setupModuleDispatchers.
@Contribute(Dispatcher.class)
@Primary
public static void setupModuleDispatchers(OrderedConfiguration<Dispatcher> configuration, ModuleManager moduleManager, OperationTracker tracker, ResourceStreamer resourceStreamer, PathConstructor pathConstructor, JavaScriptStackSource javaScriptStackSource, JavaScriptStackPathConstructor javaScriptStackPathConstructor, LocalizationSetter localizationSetter, @Symbol(SymbolConstants.MODULE_PATH_PREFIX) String modulePathPrefix, @Symbol(SymbolConstants.ASSET_PATH_PREFIX) String assetPathPrefix) {
configuration.add("Modules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, false), "after:Asset", "before:ComponentEvent");
configuration.add("ComnpressedModules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, true), "after:Modules", "before:ComponentEvent");
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method just_the_locale_name.
@Test
public void just_the_locale_name() throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest();
Response response = mockResponse();
LocalizationSetter ls = mockLocalizationSetter();
train_getPath(request, "/en");
train_setLocaleFromLocaleName(ls, "en", true);
train_isPageName(resolver, "", false);
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", null, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertNull(parameters);
verify();
}
Aggregations