Forums de discussion

Language keys for configuring theme settings

Zak Thompson, modifié il y a 7 années.

Language keys for configuring theme settings

Junior Member Publications: 70 Date d'inscription: 13/06/16 Publications récentes
In 6.2, if you wanted to add language keys for the theme settings titles, it was a relatively easy task (See this link)

However, when I have tried to do the same thing in DXP, I have run into a brick wall.

My first step was to follow the localization steps outlined here, but it did not work.

My next step was to then add a resource bundle class, and override it as shown here

My class:
import com.liferay.portal.kernel.util.AggregateResourceBundleLoader;
import com.liferay.portal.kernel.util.CacheResourceBundleLoader;
import com.liferay.portal.kernel.util.ClassResourceBundleLoader;
import com.liferay.portal.kernel.util.ResourceBundleLoader;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import java.util.ResourceBundle;

@Component(
		immediate = true,
		property = {
				"bundle.symbolic.name=com.liferay.product.navigation.control.menu.web",
				"resource.bundle.base.name=content.Language",
				"servlet.context.name=product-navigation-control-menu-web"
		}
)
public class ResourceBundleLoaderComponent implements ResourceBundleLoader {

	private AggregateResourceBundleLoader _resourceBundleLoader;

	@Override
	public ResourceBundle loadResourceBundle(String languageId) {
		System.out.println("Hello there");
		return _resourceBundleLoader.loadResourceBundle(languageId);
	}

	@Reference(target = "(bundle.symbolic.name=com.liferay.product.navigation.control.menu.web)")
	public void setResourceBundleLoader(
			ResourceBundleLoader resourceBundleLoader) {

		_resourceBundleLoader = new AggregateResourceBundleLoader(
				new CacheResourceBundleLoader(
						new ClassResourceBundleLoader(
								"content.Language",
								ResourceBundleLoaderComponent.class.getClassLoader())),
				resourceBundleLoader);
	}
}


When I refresh the configuration page for the theme, my statement is properly logged to Tomcat, but the text is still not overwritten.

This led me to dig into the portal source for the admin page, and I discovered the following jsp.

If you look at lines 122 and 143-165, it seems that the name is pulled directly out of the themeSetting and put directly into the HTML without first checking to see if there is a language key.

Is this a bug in the admin page? Or is there a different set of tasks that I should be taking to accomplish this goal?