package de.ivu.elect.presentation.wahl.menu.dynamic;

import java.io.Serializable;

import javax.inject.Inject;

import de.ivu.elect.business.wahl.entity.Wahl;
import de.ivu.elect.jee.faces.Messages;


import static de.ivu.elect.presentation.menu.AbstractMenuItemEntry.cutLabelLength;

public class WahlMenuItemLabeler implements Serializable {
  private static final long serialVersionUID = 1L;

  @Inject
  private transient Messages messages;

  public String getLabel(String labelKey, Wahl wahl) {
    return getLabel(labelKey, wahl.getName());
  }

  protected String getLabel(String labelKey, String wahlName) {
    return messages.getMessageForMessageKey(labelKey, cutLabelLength(wahlName, messages));
  }
}
