MenuEntryConfig addTranslation(final String locale, final String translation) { return addTranslation(new Locale(locale), translation); }
public String getLabel(final Locale locale) { if (locale == null || translations == null) { return getLabel(); } final Translation translation = getTranslation(locale); if (translation != null) { return translation.getTranslation(); } return getLabel(); }
/** * Walks through the tree and sets the parent menu entry for each descendant. */ public void setParents() { if (children == null) { return; } for (final MenuEntryConfig child : children) { child.setParent(this); child.setParents(); } }
public Translation getTranslation(final Locale locale) { if (locale == null || translations == null) { return null; } String lang = locale.toString().toLowerCase(); for (int i = 0; i < 4; i++) { // Endless loop protection. final Translation translation = getTranslation(lang); if (translation != null) { return translation; } final int pos = lang.lastIndexOf('_'); if (pos > 0) { lang = lang.substring(0, pos); } else { break; } } return null; }
/** * Find a pre-defined ProjectForge menu entry. */ public MenuEntryConfig findMenuEntry(final MenuItemDef menuItemDef) { if (menuItemDef != null && menuItemDef.getId() != null && menuItemDef.getId().equals(menuItemId) == true) { return this; } if (children == null) { return null; } for (final MenuEntryConfig child : children) { final MenuEntryConfig foundEntry = child.findMenuEntry(menuItemDef); if (foundEntry != null) { return foundEntry; } } return null; }
MenuEntryConfig addTranslation(final Locale locale, final String translation) { return addTranslation(new Translation(locale, translation)); }