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

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

Introduction

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

Prototype

public static String format(ResourceBundle resourceBundle, String pattern, Object[] arguments) 

Source Link

Usage

From source file:com.liferay.content.targeting.tracking.action.page.PageTrackingAction.java

License:Open Source License

@Override
public String getSummary(TrackingActionInstance trackingActionInstance, Locale locale) {

    String summary = LanguageUtil.format(locale, "tracking-page-x",
            new Object[] { trackingActionInstance.getAlias(), });

    return summary;
}

From source file:com.liferay.content.targeting.tracking.action.youtube.YoutubeTrackingAction.java

License:Open Source License

@Override
public String getSummary(TrackingActionInstance trackingActionInstance, Locale locale) {

    String summary = LanguageUtil.format(locale, "tracking-action-x-in-youtube-x",
            new Object[] { trackingActionInstance.getEventType(), trackingActionInstance.getElementId() });

    return summary;
}

From source file:com.liferay.dynamic.data.lists.form.web.internal.portlet.action.CopyRecordSetMVCActionCommand.java

License:Open Source License

protected Map<Locale, String> getNameMap(DDLRecordSet recordSet, Locale locale) {

    ResourceBundle resourceBundle = getResourceBundle(locale);

    String name = LanguageUtil.format(resourceBundle, "copy-of-x", recordSet.getName(locale, true));

    return saveRecordSetMVCCommandHelper.getLocalizedMap(locale, name);
}

From source file:com.liferay.dynamic.data.lists.internal.util.DDLImpl.java

License:Open Source License

protected String getFileEntryTitle(String uuid, long groupId) {
    try {/*from w  w w.j a v a  2 s  .com*/
        FileEntry fileEntry = _dlAppLocalService.getFileEntryByUuidAndGroupId(uuid, groupId);

        return fileEntry.getTitle();
    } catch (Exception e) {
        return LanguageUtil.format(LocaleUtil.getSiteDefault(), "is-temporarily-unavailable", "content");
    }
}

From source file:com.liferay.dynamic.data.lists.internal.util.DDLImpl.java

License:Open Source License

protected String getLayoutName(long groupId, boolean privateLayout, long layoutId, String languageId) {

    try {//from   w ww  .j av  a 2 s.c  o  m
        return _layoutService.getLayoutName(groupId, privateLayout, layoutId, languageId);
    } catch (Exception e) {
        return LanguageUtil.format(LocaleUtil.getSiteDefault(), "is-temporarily-unavailable", "content");
    }
}

From source file:com.liferay.dynamic.data.mapping.form.web.internal.portlet.action.CopyFormInstanceMVCActionCommand.java

License:Open Source License

protected Map<Locale, String> getNameMap(DDMFormInstance formInstance, Locale defaultLocale) {

    Map<Locale, String> nameMap = formInstance.getNameMap();

    ResourceBundle resourceBundle = getResourceBundle(defaultLocale);

    String name = LanguageUtil.format(resourceBundle, "copy-of-x", nameMap.get(defaultLocale));

    nameMap.put(defaultLocale, name);/*w  w  w. j  a v  a2  s .  c  o m*/

    return nameMap;
}

From source file:com.liferay.dynamic.data.mapping.internal.render.DateDDMFormFieldValueRenderer.java

License:Open Source License

private String _format(Serializable value, Locale locale) {
    try {/*w  w  w. j  ava  2s.co  m*/
        return DateUtil.formatDate("yyyy-MM-dd", value.toString(), locale);
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn(e, e);
        }

        return LanguageUtil.format(locale, "is-temporarily-unavailable", "content");
    }
}

From source file:com.liferay.dynamic.data.mapping.internal.render.DocumentLibraryDDMFormFieldValueRenderer.java

License:Open Source License

@Override
protected ValueAccessor getValueAcessor(Locale locale) {
    return new ValueAccessor(locale) {

        @Override/*from w  ww. j  av a 2s.c  o  m*/
        public String get(DDMFormFieldValue ddmFormFieldValue) {
            Value value = ddmFormFieldValue.getValue();

            JSONObject jsonObject = createJSONObject(value.getString(locale));

            String uuid = jsonObject.getString("uuid");
            long groupId = jsonObject.getLong("groupId");

            if (Validator.isNull(uuid) && (groupId == 0)) {
                return StringPool.BLANK;
            }

            try {
                FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);

                return fileEntry.getTitle();
            } catch (Exception e) {
                return LanguageUtil.format(locale, "is-temporarily-unavailable", "content");
            }
        }

        protected JSONObject createJSONObject(String json) {
            try {
                return JSONFactoryUtil.createJSONObject(json);
            } catch (JSONException jsone) {
                throw new ValueAccessorException(jsone);
            }
        }

    };
}

From source file:com.liferay.dynamic.data.mapping.internal.render.JournalArticleDDMFormFieldValueRenderer.java

License:Open Source License

@Override
protected ValueAccessor getValueAcessor(Locale locale) {
    return new ValueAccessor(locale) {

        @Override// w ww . j a va  2 s.c  om
        public String get(DDMFormFieldValue ddmFormFieldValue) {
            Value value = ddmFormFieldValue.getValue();

            JSONObject jsonObject = createJSONObject(value.getString(locale));

            String className = jsonObject.getString("className");
            long classPK = jsonObject.getLong("classPK");

            if (Validator.isNull(className) && (classPK == 0)) {
                return StringPool.BLANK;
            }

            try {
                AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK);

                return assetEntry.getTitle(locale);
            } catch (Exception e) {
                return LanguageUtil.format(locale, "is-temporarily-unavailable", "content");
            }
        }

        protected JSONObject createJSONObject(String json) {
            try {
                return JSONFactoryUtil.createJSONObject(json);
            } catch (JSONException jsone) {
                throw new ValueAccessorException(jsone);
            }
        }

    };
}

From source file:com.liferay.dynamic.data.mapping.internal.render.LinkToPageDDMFormFieldValueRenderer.java

License:Open Source License

@Override
protected ValueAccessor getValueAcessor(Locale locale) {
    return new ValueAccessor(locale) {

        @Override//from  w ww.  j a  va2 s .co m
        public String get(DDMFormFieldValue ddmFormFieldValue) {
            Value value = ddmFormFieldValue.getValue();

            JSONObject jsonObject = createJSONObject(value.getString(locale));

            long groupId = jsonObject.getLong("groupId");
            boolean privateLayout = jsonObject.getBoolean("privateLayout");
            long layoutId = jsonObject.getLong("layoutId");

            if ((groupId == 0) && (layoutId == 0)) {
                return StringPool.BLANK;
            }

            try {
                return LayoutServiceUtil.getLayoutName(groupId, privateLayout, layoutId,
                        LanguageUtil.getLanguageId(locale));
            } catch (PortalException pe) {
                if (_log.isWarnEnabled()) {
                    _log.warn(pe, pe);
                }

                return LanguageUtil.format(locale, "is-temporarily-unavailable", "content");
            }
        }

        protected JSONObject createJSONObject(String json) {
            try {
                return JSONFactoryUtil.createJSONObject(json);
            } catch (JSONException jsone) {
                throw new ValueAccessorException(jsone);
            }
        }

    };
}