Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable multilingual option in Apache tiles 3

I am getting following warning with Apche tiles 3 and Spring MVC 4 I does not added any extra configurations for multilingual support but it supporting by default. Can any one help me to disable this option to remove this warning in my site.

    org.apache.tiles.request.locale.PostfixedApplicationResource.
<init> No supported matching language for locale "sw". 
Using file:/opt/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/tiles/app-core_sw.xml as a non-localized resource path. see TILES-571
like image 961
Rakesh Avatar asked Sep 28 '16 07:09

Rakesh


2 Answers

You can disable this option by writing your own DefinitionFactory implementation and registering the same in TilesConfigurer.

public class CustomLocaleDefinitionsFactory extends LocaleDefinitionsFactory {

    /** {@inheritDoc} */
    @Override
    public Definition getDefinition(String name, Request tilesContext) {
    Definition retValue;
    Locale locale = null;

    retValue = definitionDao.getDefinition(name, locale);
    if (retValue != null) {
      retValue = new Definition(retValue);
      String parentDefinitionName = retValue.getExtends();
      while (parentDefinitionName != null) {
        Definition parent = definitionDao.getDefinition(parentDefinitionName, locale);
        if (parent == null) {
          throw new NoSuchDefinitionException("Cannot find definition '" + parentDefinitionName
              + "' ancestor of '" + retValue.getName() + "'");
        }
        retValue.inherit(parent);
        parentDefinitionName = parent.getExtends();
      }
    }

    return retValue;
    }
}

And then in register the above definition factor class, in TilesConfigurer in case using spring like this.

TilesConfigurer configurer = new TilesConfigurer();
configurer.setDefinitions(new String[] { "/WEB-INF/layouts/tiles.xml",
    "/WEB-INF/views/**/tiles.xml" });
configurer.setCheckRefresh(true);
configurer.setDefinitionsFactoryClass(CustomLocaleDefinitionsFactory.class);
return configurer;
like image 113
pradeep ruhil Avatar answered Sep 22 '22 05:09

pradeep ruhil


There is a workaround, just disable the log output will do, if you are using spring boot, it is very easy:

logging.level.org.apache.tiles.request.locale.PostfixedApplicationResource=ERROR
like image 28
Sam YC Avatar answered Sep 21 '22 05:09

Sam YC