List of usage examples for com.liferay.portal.kernel.language LanguageUtil getAvailableLocales
public static Set<Locale> getAvailableLocales()
From source file:com.sqli.liferay.imex.core.role.RoleImporter.java
License:Open Source License
private void initializeLocale(String value, Map<java.util.Locale, String> map) { List<Locale> availableLocales = Arrays.asList(LanguageUtil.getAvailableLocales()); for (Locale locale : availableLocales) { map.put(locale, value);//from w ww . jav a 2 s . c o m } }
From source file:com.wcs.newsletter.util.LiferayUtil.java
License:Open Source License
public static Locale[] getAvailableLocales() { Locale[] availableLocales = LanguageUtil.getAvailableLocales(); if (availableLocales == null) { availableLocales = new Locale[] {}; }//from www.j a v a2 s.co m return availableLocales; }
From source file:jorgediazest.indexchecker.data.DataIndexCheckerModelComparator.java
License:Open Source License
public boolean equalsAttributes(Data data1, Data data2, String attr1, String attr2, Object o1, Object o2) { if (super.equalsAttributes(data1, data2, attr1, attr2, o1, o2)) { return true; }//from w w w .ja va 2 s .c om if (o1 instanceof Set && o2 instanceof Set) { for (Locale key : LanguageUtil.getAvailableLocales()) { Set<String> values1 = new HashSet<String>(); Set<String> values2 = new HashSet<String>(); if (!fillMapValues(o1, key, values1)) { return false; } if (!fillMapValues(o2, key, values2)) { return false; } if (!values1.equals(values2)) { return false; } } return true; } return false; }
From source file:jorgediazest.indexchecker.model.IndexCheckerModel.java
License:Open Source License
public void fillDataObject(Data data, String[] attributes, Document doc) { data.set("uid", doc.getUID()); Set<Locale> locales = LanguageUtil.getAvailableLocales(); Locale siteLocale = LocaleUtil.getSiteDefault(); for (String attribute : attributes) { String attrDoc = IndexSearchUtil.getAttributeForDocument(this, attribute); List<Map<Locale, String>> listValueMap = null; Class<?> typeClass = data.getAttributeTypeClass(attribute); if (typeClass.equals(String.class) || typeClass.equals(Object.class)) { listValueMap = IndexSearchUtil.getLocalizedMap(locales.toArray(new Locale[0]), doc, attrDoc); }/*from ww w . ja v a2 s.c om*/ if ((listValueMap != null) && !listValueMap.isEmpty()) { String[] xml = new String[listValueMap.size()]; int pos = 0; for (Map<Locale, String> valueMap : listValueMap) { xml[pos++] = LocalizationUtil.updateLocalization(valueMap, "", "data", LocaleUtil.toLanguageId(siteLocale)); } data.set(attribute, xml); } else if (doc.hasField(attrDoc)) { data.set(attribute, doc.getField(attrDoc).getValues()); } } }
From source file:jorgediazest.indexchecker.model.IndexCheckerModelQuery.java
License:Open Source License
public void fillDataObject(Data data, String[] attributes, Document doc) { data.set("uid", doc.getUID()); Locale[] locales = LanguageUtil.getAvailableLocales().toArray(new Locale[0]); Locale siteLocale = LocaleUtil.getSiteDefault(); for (String attribute : attributes) { String attrDoc = IndexSearchUtil.getAttributeForDocument(getModel(), attribute); List<Map<Locale, String>> listValueMap = null; Class<?> typeClass = data.getAttributeTypeClass(attribute); if (typeClass.equals(String.class) || typeClass.equals(Object.class)) { listValueMap = IndexSearchUtil.getLocalizedMap(locales, doc, attrDoc); }/*from w ww.j a v a 2 s.c om*/ if ((listValueMap != null) && !listValueMap.isEmpty()) { String[] xml = new String[listValueMap.size()]; int pos = 0; for (Map<Locale, String> valueMap : listValueMap) { xml[pos++] = LocalizationUtil.updateLocalization(valueMap, "", "data", LocaleUtil.toLanguageId(siteLocale)); } data.set(attribute, xml); } else if (doc.hasField(attrDoc)) { data.set(attribute, doc.getField(attrDoc).getValues()); } } }
From source file:jorgediazest.util.data.DataUtil.java
License:Open Source License
protected static Map<Locale, String> transformXmlToMap(String xml) { Map<Locale, String> map = LocalizationUtil.getLocalizationMap(xml); Map<Locale, String> cleanMap = new HashMap<>(); for (Locale key : LanguageUtil.getAvailableLocales()) { if (!map.containsKey(key)) { continue; }//from w w w . j ava2 s . com String value = map.get(key); if (DataUtil.isNotNull(value)) { if (DataUtil.getIgnoreCase()) { value = StringUtil.toLowerCase(value); } cleanMap.put(key, value); } } return cleanMap; }
From source file:net.sareweb.mshowcase.model.impl.OfferModelImpl.java
License:Open Source License
public void setOfferTextMap(Map<Locale, String> offerTextMap, Locale defaultLocale) { if (offerTextMap == null) { return;/* w w w . j av a 2 s. c o m*/ } Locale[] locales = LanguageUtil.getAvailableLocales(); for (Locale locale : locales) { String offerText = offerTextMap.get(locale); setOfferText(offerText, locale, defaultLocale); } }
From source file:net.sareweb.mshowcase.model.OfferClp.java
License:Open Source License
public void setOfferTextMap(Map<Locale, String> offerTextMap, Locale defaultLocale) { if (offerTextMap == null) { return;//from ww w .j a va 2s .com } ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader(); Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); try { if (contextClassLoader != portalClassLoader) { currentThread.setContextClassLoader(portalClassLoader); } Locale[] locales = LanguageUtil.getAvailableLocales(); for (Locale locale : locales) { String offerText = offerTextMap.get(locale); setOfferText(offerText, locale, defaultLocale); } } finally { if (contextClassLoader != portalClassLoader) { currentThread.setContextClassLoader(contextClassLoader); } } }
From source file:org.apache.jsp.html.portal.layout.edit.article_jsp.java
License:Open Source License
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;/*from ww w. j a v a2s.c o m*/ HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); // liferay-theme:defineObjects com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .get(com.liferay.taglib.theme.DefineObjectsTag.class); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null); int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doStartTag(); if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); com.liferay.portal.theme.ThemeDisplay themeDisplay = null; com.liferay.portal.model.Company company = null; com.liferay.portal.model.Account account = null; com.liferay.portal.model.User user = null; com.liferay.portal.model.User realUser = null; com.liferay.portal.model.Contact contact = null; com.liferay.portal.model.Layout layout = null; java.util.List layouts = null; java.lang.Long plid = null; com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null; java.lang.Long scopeGroupId = null; com.liferay.portal.security.permission.PermissionChecker permissionChecker = null; java.util.Locale locale = null; java.util.TimeZone timeZone = null; com.liferay.portal.model.Theme theme = null; com.liferay.portal.model.ColorScheme colorScheme = null; com.liferay.portal.theme.PortletDisplay portletDisplay = null; java.lang.Long portletGroupId = null; themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay"); company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company"); account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account"); user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user"); realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser"); contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact"); layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout"); layouts = (java.util.List) _jspx_page_context.findAttribute("layouts"); plid = (java.lang.Long) _jspx_page_context.findAttribute("plid"); layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context .findAttribute("layoutTypePortlet"); scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId"); permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context .findAttribute("permissionChecker"); locale = (java.util.Locale) _jspx_page_context.findAttribute("locale"); timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone"); theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme"); colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme"); portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context .findAttribute("portletDisplay"); portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId"); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); Layout selLayout = (Layout) request.getAttribute(WebKeys.SEL_LAYOUT); String currentLanguageId = LanguageUtil.getLanguageId(request); Locale currentLocale = LocaleUtil.fromLanguageId(currentLanguageId); Locale defaultLocale = LocaleUtil.getDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); Locale[] locales = LanguageUtil.getAvailableLocales(); out.write("\n"); out.write("\n"); out.write("<table class=\"lfr-table\">\n"); out.write("<tr>\n"); out.write("\t<td>\n"); out.write("\t\t"); if (_jspx_meth_liferay_002dui_005fmessage_005f0(_jspx_page_context)) return; out.write("\n"); out.write("\t</td>\n"); out.write("\t<td>\n"); out.write( "\t\t<input class=\"lfr-input-text\" name=\"TypeSettingsProperties--article-id--\" type=\"text\" value=\""); if (_jspx_meth_bean_005fwrite_005f0(_jspx_page_context)) return; out.write("\" />\n"); out.write("\t</td>\n"); out.write("</tr>\n"); out.write("</table>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
From source file:org.kisti.edison.multiboard.service.impl.BoardDivLocalServiceImpl.java
License:Open Source License
public List<Map<String, Object>> getAllBoardDivs() throws SystemException { List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>(); List<BoardDiv> boardDivList = boardDivPersistence.findAll(); Locale[] locale = LanguageUtil.getAvailableLocales(); for (BoardDiv boardDiv : boardDivList) { Map<String, Object> returnMap = new HashMap<String, Object>(); returnMap.put("divCd", boardDiv.getDivCd()); for (int i = 0; i < locale.length; i++) { returnMap.put("titleNm" + (i + 1), boardDiv.getTitleNm(locale[i])); }//from w w w . j a va 2 s. c om // returnMap.put("titleNmKor", boardDiv.getTitleNm("ko_KR")); // returnMap.put("titleNmEng", boardDiv.getTitleNm("en_US")); returnMap.put("contentNm", boardDiv.getContentNm()); returnMap.put("divNm", boardDiv.getDivNm()); returnMap.put("fileUpLoadUseYn", boardDiv.getFileUpLoadUseYn()); returnMap.put("popupYn", boardDiv.getPopupYn()); returnMap.put("replyYn", boardDiv.getReplyYn()); returnList.add(returnMap); } return returnList; }