/** * Get the language used currently. * * @return The language as a String. */ public String language() { return i18nContentSupport.get().getLocale().toString(); }
@Override public Control getLanguageChooser() { if (isEnabled() && i18nContentSupport.isEnabled() && i18nContentSupport.getLocales().size()>1){ Select select = new Select(); select.setName("locale"); select.setEvent("onchange", "window.location = this.value"); Content currentPage = MgnlContext.getAggregationState().getMainContent(); String currentUri = createURI(currentPage, i18nContentSupport.getLocale()); select.setValue(currentUri); for (Locale locale : i18nContentSupport.getLocales()) { String uri = createURI(currentPage, locale); String label = StringUtils.capitalize(locale.getDisplayLanguage(locale)); if(StringUtils.isNotEmpty(locale.getCountry())){ label += " (" + StringUtils.capitalize(locale.getDisplayCountry()) + ")"; } select.setOptions(label, uri); } return select; } return null; }
@Override public Locale getLocale() { return getI18nContentSupport().getLocale(); }
@Override public String getTitle() { return DateFormatUtils.format(monthToShow, "MMMM", i18nContentSupport.getLocale()); } };
protected String onClickForNewButton(String path, String nodeCollectionName, String nodeName, String paragraph, String repository, String dialogName) { return "mgnlOpenDialog('" + path + "','" + nodeCollectionName + "','" + nodeName + "','" + paragraph + "','" + repository + "','.magnolia/dialogs/" + dialogName + ".html'" + ", null" //width + ", null" //height + (i18nSupport.isEnabled()? ", '" + i18nSupport.getLocale().toString() + "'":"") +");"; }
/** * Return the message of a given message key, localized according to the content i18n settings. * @param key string * @return return the message string of a given message key */ public static String message(String key) { String value = MessagesManager.getMessages(Components.getComponent(I18nContentSupport.class).getLocale()).get( key); return value; }
/** * Return the message of a given message key, formatted with the given arguments and localized according to the * content i18n settings. * @param key string * @return return the message string of a given message key */ public static String messageWithArgs(String key, Object[] arguments) { String value = MessagesManager.getMessages(Components.getComponent(I18nContentSupport.class).getLocale()).get( key, arguments); return value; }
protected String createURI(Content currentPage, Locale locale) { // we are going to change the context language, this is ugly but is safe as only the current Thread is modified Locale currentLocale = i18nContentSupport.getLocale(); String uri=null; try { // this is going to set the local in the aggregation state and hence wont change the i18nSupport object itself i18nContentSupport.setLocale(locale); uri = LinkUtil.createAbsoluteLink(currentPage); } // make sure that we always reset to the original locale finally{ i18nContentSupport.setLocale(currentLocale); } return uri; }
final Locale currentLocale = i18nContentSupport.get().getLocale(); String uri = null; final AggregationState aggregationState;
public void setDefaultOnclick() { String nodeCollectionName = this.getNodeCollectionName(); if (nodeCollectionName == null) { nodeCollectionName = StringUtils.EMPTY; } String nodeName = this.getNodeName(); if (nodeName == null) { nodeName = StringUtils.EMPTY; } String repository = MgnlContext.getAggregationState().getRepository(); this.setOnclick("mgnlOpenDialog('" //$NON-NLS-1$ + this.getPath() + "','" //$NON-NLS-1$ + nodeCollectionName + "','" //$NON-NLS-1$ + nodeName + "','" //$NON-NLS-1$ + this.getDialog() + "','" //$NON-NLS-1$ + repository + "'," + (dialogPath != null ? "'" + dialogPath + "'" : "null") + ", null" //width + ", null" //height + (i18nSupport.isEnabled()? ", '" + i18nSupport.getLocale().toString() + "'":"") +");"); }
+ repository + "',null, null, null" + (i18nSupport.isEnabled()? ", '" + i18nSupport.getLocale().toString() + "'":"") + ")");
Locale locale; if (this.dateLanguage == null) { locale = I18nContentSupportFactory.getI18nSupport().getLocale();