Hi I have developed a nice feature to link better the products in the store front of Konakart.
So when an external site (it can be the official site of a manufacturer) links a product it can refer to the right language.
What do you think about it?
Here is my code.
In ShowProductDetailsAction I added at the end of the URL
// add the current locale
url.append("&locale=");
url.append(URLEncoder.encode(kkAppEng.getLocale(), "UTF-8"));
and
readLocale(request, kkAppEng);
final ProductIf selectedProd = kkAppEng.getProductMgr().getSelectedProduct();
where readLocale is
private void readLocale(final HttpServletRequest request, final KKAppEng kkAppEng) throws KKException,
KKAppException {
if (StringUtils.isEmpty(request.getParameter("locale"))) {
return;
}
if (!StringUtils.contains(request.getParameter("locale"), "_")) {
return;
}
String locale = request.getParameter("locale");
/*
* The locale should be in the form languageCode_countryCode (i.e. en_GB, it_IT). We need to split up the two
* codes.
*/
final String[] codes = locale.split("_");
/*
* Set the current locale in KonaKart so that calls to the engine use this locale.
*/
kkAppEng.setLocale(codes[0], codes[1]);
// Set the message resources in kkAppEng
kkAppEng.setMsgResources(getResources(request));
// Set the currrent locale so that it's picked up by Struts
setLocale(request, new Locale(codes[0], codes[1]));
}