Example usage for com.liferay.portal.kernel.language LanguageUtil get

List of usage examples for com.liferay.portal.kernel.language LanguageUtil get

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.language LanguageUtil get.

Prototype

public static String get(ResourceBundle resourceBundle, String key) 

Source Link

Usage

From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java

License:Open Source License

protected void addPortletTitleAddBookmarkMenuItem(List<MenuItem> menuItems, BookmarksFolder folder,
        ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException {

    long folderId = _getFolderId(folder);

    if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId,
            ActionKeys.ADD_ENTRY)) {//from   www  .jav  a 2 s  .  c  o  m

        return;
    }

    URLMenuItem urlMenuItem = new URLMenuItem();

    urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "bookmark"));

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(),
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_entry");
    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("folderId", String.valueOf(folderId));

    urlMenuItem.setURL(portletURL.toString());

    menuItems.add(urlMenuItem);
}

From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java

License:Open Source License

protected void addPortletTitleAddFolderMenuItem(List<MenuItem> menuItems, BookmarksFolder folder,
        ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException {

    long folderId = _getFolderId(folder);

    if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId,
            ActionKeys.ADD_FOLDER)) {/*from   w  ww.  ja  va  2 s  .  co m*/

        return;
    }

    URLMenuItem urlMenuItem = new URLMenuItem();

    urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest),
            (folder != null) ? "subfolder" : "folder"));

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(),
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_folder");
    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("parentFolderId", String.valueOf(folderId));

    urlMenuItem.setURL(portletURL.toString());

    menuItems.add(urlMenuItem);
}

From source file:com.liferay.bookmarks.web.internal.portlet.util.BookmarksUtil.java

License:Open Source License

public static Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest,
        String emailFromAddress, String emailFromName) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Map<String, String> definitionTerms = new LinkedHashMap<>();

    definitionTerms.put("[$BOOKMARKS_ENTRY_USER_NAME$]",
            LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-added-the-bookmark-entry"));
    definitionTerms.put("[$BOOKMARKS_ENTRY_STATUS_BY_USER_NAME$]",
            LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-updated-the-bookmark-entry"));
    definitionTerms.put("[$BOOKMARKS_ENTRY_URL$]",
            LanguageUtil.get(themeDisplay.getLocale(), "the-bookmark-entry-url"));
    definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress));
    definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName));

    Company company = themeDisplay.getCompany();

    definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname());

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape(portletDisplay.getTitle()));

    definitionTerms.put("[$TO_ADDRESS$]",
            LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient"));
    definitionTerms.put("[$TO_NAME$]",
            LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient"));

    return definitionTerms;
}

From source file:com.liferay.calendar.notification.impl.NotificationTemplateContextFactory.java

License:Open Source License

public static NotificationTemplateContext getInstance(NotificationType notificationType,
        NotificationTemplateType notificationTemplateType, CalendarBooking calendarBooking, User user)
        throws Exception {

    CalendarBooking parentCalendarBooking = calendarBooking.getParentCalendarBooking();

    Calendar calendar = parentCalendarBooking.getCalendar();

    NotificationTemplateContext notificationTemplateContext = new NotificationTemplateContext();

    CalendarNotificationTemplate calendarNotificationTemplate = CalendarNotificationTemplateLocalServiceUtil
            .fetchCalendarNotificationTemplate(calendar.getCalendarId(), notificationType,
                    notificationTemplateType);

    notificationTemplateContext.setCalendarNotificationTemplate(calendarNotificationTemplate);

    notificationTemplateContext.setCompanyId(calendarBooking.getCompanyId());
    notificationTemplateContext.setGroupId(calendarBooking.getGroupId());
    notificationTemplateContext.setCalendarId(calendar.getCalendarId());
    notificationTemplateContext.setNotificationTemplateType(notificationTemplateType);
    notificationTemplateContext.setNotificationType(notificationType);

    // Attributes

    Map<String, Serializable> attributes = new HashMap<>();

    TimeZone userTimezone = user.getTimeZone();

    Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(user.getLocale(),
            CalendarUtil.getCalendarBookingDisplayTimeZone(calendarBooking, userTimezone));

    String userTimezoneDisplayName = userTimezone.getDisplayName(false, TimeZone.SHORT, user.getLocale());

    String endTime = dateFormatDateTime.format(calendarBooking.getEndTime()) + StringPool.SPACE
            + userTimezoneDisplayName;/*from  w w  w  .  java2s .c o  m*/

    attributes.put("endTime", endTime);

    attributes.put("location", calendarBooking.getLocation());

    Group group = GroupLocalServiceUtil.getGroup(user.getCompanyId(), GroupConstants.GUEST);

    String portalURL = _getPortalURL(group.getCompanyId(), group.getGroupId());

    attributes.put("portalURL", portalURL);

    PortletConfig portletConfig = getPortletConfig();

    ResourceBundle resourceBundle = portletConfig.getResourceBundle(user.getLocale());

    attributes.put("portletName",
            LanguageUtil.get(resourceBundle, "javax.portlet.title.".concat(CalendarPortletKeys.CALENDAR)));

    String startTime = dateFormatDateTime.format(calendarBooking.getStartTime()) + StringPool.SPACE
            + userTimezoneDisplayName;

    attributes.put("startTime", startTime);

    attributes.put("title", calendarBooking.getTitle(user.getLocale()));

    String calendarBookingURL = _getCalendarBookingURL(user, calendarBooking.getCalendarBookingId());

    attributes.put("url", calendarBookingURL);

    notificationTemplateContext.setAttributes(attributes);

    return notificationTemplateContext;
}

From source file:com.liferay.calendar.notification.NotificationTemplateContextFactory.java

License:Open Source License

public static NotificationTemplateContext getInstance(NotificationType notificationType,
        NotificationTemplateType notificationTemplateType, CalendarBooking calendarBooking, User user)
        throws Exception {

    CalendarBooking parentCalendarBooking = calendarBooking.getParentCalendarBooking();

    Calendar calendar = parentCalendarBooking.getCalendar();

    NotificationTemplateContext notificationTemplateContext = new NotificationTemplateContext();

    CalendarNotificationTemplate calendarNotificationTemplate = CalendarNotificationTemplateLocalServiceUtil
            .fetchCalendarNotificationTemplate(calendar.getCalendarId(), notificationType,
                    notificationTemplateType);

    notificationTemplateContext.setCalendarNotificationTemplate(calendarNotificationTemplate);

    notificationTemplateContext.setCompanyId(calendarBooking.getCompanyId());
    notificationTemplateContext.setGroupId(calendarBooking.getGroupId());
    notificationTemplateContext.setCalendarId(calendar.getCalendarId());
    notificationTemplateContext.setNotificationTemplateType(notificationTemplateType);
    notificationTemplateContext.setNotificationType(notificationType);

    // Attributes

    Map<String, Serializable> attributes = new HashMap<String, Serializable>();

    TimeZone userTimezone = user.getTimeZone();

    Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(user.getLocale(), userTimezone);

    String userTimezoneDisplayName = userTimezone.getDisplayName(false, TimeZone.SHORT, user.getLocale());

    String endTime = dateFormatDateTime.format(calendarBooking.getEndTime()) + StringPool.SPACE
            + userTimezoneDisplayName;//from w  w  w .j av a2s.  c  o m

    attributes.put("endTime", endTime);

    attributes.put("location", calendarBooking.getLocation());

    Group group = user.getGroup();

    String portalURL = _getPortalURL(group.getCompanyId(), group.getGroupId());

    attributes.put("portalURL", portalURL);

    PortletConfig portletConfig = getPortletConfig();

    ResourceBundle resourceBundle = portletConfig.getResourceBundle(user.getLocale());

    attributes.put("portletName",
            LanguageUtil.get(resourceBundle, "javax.portlet.title.".concat(PortletKeys.CALENDAR)));

    String startTime = dateFormatDateTime.format(calendarBooking.getStartTime()) + StringPool.SPACE
            + userTimezoneDisplayName;

    attributes.put("startTime", startTime);

    attributes.put("title", calendarBooking.getTitle(user.getLocale()));

    String calendarBookingURL = _getCalendarBookingURL(user, calendarBooking.getCalendarBookingId());

    attributes.put("url", calendarBookingURL);

    notificationTemplateContext.setAttributes(attributes);

    return notificationTemplateContext;
}

From source file:com.liferay.configuration.admin.web.internal.portlet.configuration.icon.ExportAllConfigurationIcon.java

License:Open Source License

@Override
public String getMessage(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(themeDisplay.getLocale());

    return LanguageUtil.get(resourceBundle, "export-all-settings");
}

From source file:com.liferay.configuration.admin.web.internal.portlet.configuration.icon.ExportFactoryInstancesIcon.java

License:Open Source License

@Override
public String getMessage(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(themeDisplay.getLocale());

    return LanguageUtil.get(resourceBundle, "export-entries");
}

From source file:com.liferay.configuration.admin.web.internal.util.ConfigurationModelToDDMFormConverter.java

License:Open Source License

protected String translate(String key) {
    if ((_resourceBundle == null) || (key == null)) {
        return key;
    }//from w  ww  .j  a  v a2 s.  c  om

    String value = LanguageUtil.get(_resourceBundle, key);

    if (value == null) {
        return key;
    }

    return value;
}

From source file:com.liferay.content.targeting.rule.browser.BrowserRule.java

License:Open Source License

@Override
public String getSummary(RuleInstance ruleInstance, Locale locale) {
    return LanguageUtil.get(locale, ruleInstance.getTypeSettings());
}

From source file:com.liferay.content.targeting.rule.device.DeviceRule.java

License:Open Source License

@Override
public String getSummary(RuleInstance ruleInstance, Locale locale) {
    long mdrRuleGroupId = getMDRRuleGroupId(ruleInstance);

    if (mdrRuleGroupId <= 0) {
        return StringPool.BLANK;
    }/*w ww  .  ja  v  a 2 s  .  c  om*/

    MDRRuleGroup mdrRuleGroup = null;

    try {
        mdrRuleGroup = MDRRuleGroupLocalServiceUtil.fetchMDRRuleGroup(mdrRuleGroupId);
    } catch (SystemException se) {
        _log.error(se);
    }

    if (mdrRuleGroup == null) {
        return StringPool.BLANK;
    }

    StringBuilder sb = new StringBuilder(3);

    sb.append(LanguageUtil.get(locale, "device-family"));
    sb.append(StringPool.COLON);
    sb.append(StringPool.SPACE);
    sb.append(mdrRuleGroup.getName(locale));

    String description = mdrRuleGroup.getDescription(locale);

    if (Validator.isNotNull(description)) {
        sb.append(StringPool.COLON);
        sb.append(StringPool.SPACE);
        sb.append(mdrRuleGroup.getDescription(locale));
    }

    return sb.toString();
}