List of usage examples for com.liferay.portal.kernel.language LanguageUtil get
public static String get(ResourceBundle resourceBundle, String key)
From source file:com.liferay.faces.bridge.ext.i18n.internal.I18nLiferayImpl.java
License:Open Source License
@Override public String getMessage(FacesContext facesContext, Locale locale, String messageId) { String value = LanguageUtil.get(locale, messageId); if ((value == null) || value.equals(messageId)) { value = super.getMessage(facesContext, locale, messageId); }//from w w w . j a v a 2 s . co m return value; }
From source file:com.liferay.faces.portal.context.internal.MessageContextPortalImpl.java
License:Open Source License
@Override public String getMessage(Locale locale, String messageId) { String value = LanguageUtil.get(locale, messageId); if ((value == null) || value.equals(messageId)) { value = super.getMessage(locale, messageId); }//from www .j a v a 2s . c o m return value; }
From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message) throws Exception { FlagsRequest flagsRequest = (FlagsRequest) message.getPayload(); // Service context ServiceContext serviceContext = flagsRequest.getServiceContext(); // Company//from w w w . j a v a2 s. c o m long companyId = serviceContext.getCompanyId(); Company company = _companyLocalService.getCompany(serviceContext.getCompanyId()); // Group Layout layout = _layoutLocalService.getLayout(serviceContext.getPlid()); Group group = layout.getGroup(); // Reporter user String reporterUserName = null; String reporterEmailAddress = null; User reporterUser = _userLocalService.getUserById(serviceContext.getUserId()); Locale locale = LocaleUtil.getDefault(); if (reporterUser.isDefaultUser()) { reporterUserName = LanguageUtil.get(locale, "anonymous"); } else { reporterUserName = reporterUser.getFullName(); reporterEmailAddress = reporterUser.getEmailAddress(); } // Reported user String reportedUserName = StringPool.BLANK; String reportedEmailAddress = StringPool.BLANK; String reportedURL = StringPool.BLANK; User reportedUser = _userLocalService.getUserById(flagsRequest.getReportedUserId()); if (reportedUser.isDefaultUser()) { reportedUserName = group.getDescriptiveName(); } else { reportedUserName = reportedUser.getFullName(); reportedEmailAddress = reportedUser.getEmailAddress(); reportedURL = reportedUser.getDisplayURL(serviceContext.getThemeDisplay()); } // Content String contentType = ResourceActionsUtil.getModelResource(locale, flagsRequest.getClassName()); // Reason String reason = LanguageUtil.get(locale, flagsRequest.getReason()); // Email FlagsGroupServiceConfiguration flagsGroupServiceConfiguration = ConfigurationProviderUtil .getCompanyConfiguration(FlagsGroupServiceConfiguration.class, companyId); String fromName = flagsGroupServiceConfiguration.emailFromName(); String fromAddress = flagsGroupServiceConfiguration.emailFromAddress(); String subject = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailSubject()); String body = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailBody()); // Recipients Set<User> recipients = getRecipients(companyId, serviceContext.getScopeGroupId()); for (User recipient : recipients) { try { notify(reporterUser.getUserId(), company, group, reporterEmailAddress, reporterUserName, reportedEmailAddress, reportedUserName, reportedURL, flagsRequest.getClassPK(), flagsRequest.getContentTitle(), contentType, flagsRequest.getContentURL(), reason, fromName, fromAddress, recipient.getFullName(), recipient.getEmailAddress(), subject, body, serviceContext); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } } }
From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java
License:Open Source License
@Override public int doStartTag() { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String randomNamespace = StringUtil.randomId() + StringPool.UNDERLINE; try {//w w w.j av a 2 s .c o m Map<String, Object> context = getContext(); boolean enabled = GetterUtil.getBoolean(context.get("enabled"), true); Company company = themeDisplay.getCompany(); putValue("companyName", company.getName()); putValue("flagsEnabled", _isFlagsEnabled(themeDisplay)); putValue("formData", _getDataJSONObject(context)); putValue("id", randomNamespace + "id"); putValue("enabled", enabled); boolean label = GetterUtil.getBoolean(context.get("label"), true); putValue("label", label); String message = GetterUtil.getString(context.get("message"), LanguageUtil.get(request, "flag")); putValue("message", message); putValue("pathTermsOfUse", themeDisplay.getPathMain() + "/portal/terms_of_use"); putValue("pathThemeImages", themeDisplay.getPathThemeImages()); putValue("portletNamespace", PortalUtil.getPortletNamespace(PortletKeys.FLAGS)); boolean signedIn = themeDisplay.isSignedIn(); putValue("signedIn", signedIn); if (signedIn) { User user = themeDisplay.getUser(); putValue("reporterEmailAddress", user.getEmailAddress()); } String title = message; if (!enabled) { title = LanguageUtil.get(request, "flags-are-disabled-because-this-entry-is-in-the-recycle-" + "bin"); } putValue("title", title); putValue("uri", _getURI()); putValue("reasons", _getReasons(themeDisplay.getCompanyId())); } catch (Exception e) { _log.error(e, e); } setTemplateNamespace("Flags.render"); return super.doStartTag(); }
From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java
License:Open Source License
public void setMessage(String message) { putValue("message", LanguageUtil.get(request, message)); }
From source file:com.liferay.frontend.editor.alloyeditor.web.editor.configuration.AlloyEditorConfigContributor.java
License:Open Source License
protected JSONArray getStyleFormatsJSONArray(Locale locale) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ResourceBundle resourceBundle = null; try {//w w w . j a va2s . c o m resourceBundle = _resourceBundleLoader.loadResourceBundle(LocaleUtil.toLanguageId(locale)); } catch (MissingResourceException mre) { resourceBundle = ResourceBundleUtil.EMPTY_RESOURCE_BUNDLE; } jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "normal"), "p", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "1"), "h1", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "2"), "h2", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "3"), "h3", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "4"), "h4", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "preformatted-text"), "pre", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "cited-work"), "cite", null, _CKEDITOR_STYLE_INLINE)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "computer-code"), "code", null, _CKEDITOR_STYLE_INLINE)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "info-message"), "div", "portlet-msg-info", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "alert-message"), "div", "portlet-msg-alert", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "error-message"), "div", "portlet-msg-error", _CKEDITOR_STYLE_BLOCK)); return jsonArray; }
From source file:com.liferay.frontend.editor.alloyeditor.web.internal.editor.configuration.AlloyEditorBBCodeConfigContributor.java
License:Open Source License
protected JSONObject getLangJSONObject(Map<String, Object> inputEditorTaglibAttributes) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("code", LanguageUtil.get(getContentsLocale(inputEditorTaglibAttributes), "code")); return jsonObject; }
From source file:com.liferay.frontend.editor.alloyeditor.web.internal.editor.configuration.AlloyEditorBBCodeConfigContributor.java
License:Open Source License
protected JSONArray getStyleFormatsJSONArray(Locale locale) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ResourceBundle resourceBundle = null; try {// w w w . ja v a2s . c om resourceBundle = _resourceBundleLoader.loadResourceBundle(locale); } catch (MissingResourceException mre) { resourceBundle = ResourceBundleUtil.EMPTY_RESOURCE_BUNDLE; } jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "normal"), "p", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "cited-work"), "cite", null, _CKEDITOR_STYLE_INLINE)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "computer-code"), "code", null, _CKEDITOR_STYLE_INLINE)); return jsonArray; }
From source file:com.liferay.frontend.editor.alloyeditor.web.internal.editor.configuration.AlloyEditorConfigContributor.java
License:Open Source License
protected JSONArray getStyleFormatsJSONArray(Locale locale) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ResourceBundle resourceBundle = null; try {//from w w w .jav a2 s . co m resourceBundle = _resourceBundleLoader.loadResourceBundle(locale); } catch (MissingResourceException mre) { resourceBundle = ResourceBundleUtil.EMPTY_RESOURCE_BUNDLE; } jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "normal"), "p", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "1"), "h1", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "2"), "h2", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "3"), "h3", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "4"), "h4", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "preformatted-text"), "pre", null, _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "cited-work"), "cite", null, _CKEDITOR_STYLE_INLINE)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "computer-code"), "code", null, _CKEDITOR_STYLE_INLINE)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "info-message"), "div", "portlet-msg-info", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "alert-message"), "div", "portlet-msg-alert", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "error-message"), "div", "portlet-msg-error", _CKEDITOR_STYLE_BLOCK)); return jsonArray; }
From source file:com.liferay.frontend.editor.alloyeditor.web.internal.editor.configuration.AlloyEditorCreoleConfigContributor.java
License:Open Source License
protected JSONArray getStyleFormatsJSONArray(Locale locale) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); ResourceBundle resourceBundle = null; try {/*from www. j av a 2 s .c o m*/ resourceBundle = _resourceBundleLoader.loadResourceBundle(locale); } catch (MissingResourceException mre) { resourceBundle = ResourceBundleUtil.EMPTY_RESOURCE_BUNDLE; } jsonArray.put( getStyleFormatJSONObject(LanguageUtil.get(resourceBundle, "normal"), "p", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "1"), "h1", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "2"), "h2", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "3"), "h3", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "4"), "h4", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "5"), "h5", _CKEDITOR_STYLE_BLOCK)); jsonArray.put(getStyleFormatJSONObject(LanguageUtil.format(resourceBundle, "heading-x", "6"), "h6", _CKEDITOR_STYLE_BLOCK)); return jsonArray; }