Skip to content

Commit

Permalink
MID-9865 localization of label panel for Boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jul 24, 2024
1 parent 90065e3 commit d471c67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,19 @@ public static void setTaskStateBeforeSave(
}
}

public static IModel<String> createLocalizedModelForBoolean(Boolean object) {
return () -> {
String key;
if (object == null) {
key = KEY_BOOLEAN_NULL;
} else {
key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE;
}

return com.evolveum.midpoint.gui.api.util.LocalizationUtil.translate(key);
};
}

public enum AssignmentOrder {

ASSIGNMENT(0),
Expand Down Expand Up @@ -2045,16 +2058,7 @@ public Boolean getObject(String id, IModel<? extends List<? extends Boolean>> ch

@Override
public String getDisplayValue(Boolean object) {
String key;
if (object == null) {
key = KEY_BOOLEAN_NULL;
} else {
key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE;
}

StringResourceModel model = PageBase.createStringResourceStatic(key);

return model.getString();
return WebComponentUtil.createLocalizedModelForBoolean(object).getObject();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public org.apache.wicket.Component createPanel(PrismPropertyPanelContext<T> pane
return new Label(panelCtx.getComponentId(), WebComponentUtil.createLocalizedModelForEnum((Enum<?>) object, panelCtx.getPageBase()));
} else if (object instanceof PolyString) {
return new Label(panelCtx.getComponentId(), LocalizationUtil.translatePolyString((PolyString) object));
} else if (object instanceof Boolean) {
return new Label(panelCtx.getComponentId(), WebComponentUtil.createLocalizedModelForBoolean((Boolean) object));
}

return new Label(panelCtx.getComponentId(), panelCtx.getRealValueStringModel());
Expand Down

0 comments on commit d471c67

Please sign in to comment.