Fix missing localization (#772)
* fix typos Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Add localization to documentation link description Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Add localization for rollouts errorthreshold Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Add CN to available localizations Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * fix NO TAG localization Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Fix sonar findings Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * Make Localization configurable Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * fix sonar findings Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * fix review findings Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * fix review findings Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com> * add final Signed-off-by: Jeroen Laverman <jeroen.laverman@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
347fac7f00
commit
b06928d089
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.ErrorView;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.NotificationUnreadButton;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardMenu;
|
||||
import org.eclipse.hawkbit.ui.push.EventPushStrategy;
|
||||
@@ -43,8 +44,9 @@ public class MyUI extends AbstractHawkbitUI {
|
||||
@Autowired
|
||||
MyUI(final EventPushStrategy pushStrategy, final UIEventBus eventBus, final SpringViewProvider viewProvider,
|
||||
final ApplicationContext context, final DashboardMenu dashboardMenu, final ErrorView errorview,
|
||||
final NotificationUnreadButton notificationUnreadButton) {
|
||||
super(pushStrategy, eventBus, viewProvider, context, dashboardMenu, errorview, notificationUnreadButton);
|
||||
final NotificationUnreadButton notificationUnreadButton, final UiProperties uiProperties) {
|
||||
super(pushStrategy, eventBus, viewProvider, context, dashboardMenu, errorview, notificationUnreadButton,
|
||||
uiProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ spring.rabbitmq.port=5672
|
||||
# Monitoring
|
||||
endpoints.health.enabled=true
|
||||
|
||||
# UI Localization
|
||||
hawkbit.server.ui.localization.defaultLocal=en
|
||||
hawkbit.server.ui.localization.availableLocals=en,de
|
||||
|
||||
# UI demo account
|
||||
hawkbit.server.ui.demo.password=admin
|
||||
hawkbit.server.ui.demo.user=admin
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
@@ -81,9 +81,11 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
|
||||
|
||||
private Label viewTitle;
|
||||
|
||||
private final UiProperties uiProperties;
|
||||
|
||||
protected AbstractHawkbitUI(final EventPushStrategy pushStrategy, final UIEventBus eventBus,
|
||||
final SpringViewProvider viewProvider, final ApplicationContext context, final DashboardMenu dashboardMenu,
|
||||
final ErrorView errorview, final NotificationUnreadButton notificationUnreadButton) {
|
||||
final ErrorView errorview, final NotificationUnreadButton notificationUnreadButton, final UiProperties uiProperties) {
|
||||
this.pushStrategy = pushStrategy;
|
||||
this.eventBus = eventBus;
|
||||
this.viewProvider = viewProvider;
|
||||
@@ -91,6 +93,7 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
|
||||
this.dashboardMenu = dashboardMenu;
|
||||
this.errorview = errorview;
|
||||
this.notificationUnreadButton = notificationUnreadButton;
|
||||
this.uiProperties = uiProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,7 +167,7 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
|
||||
navigator.addView(EMPTY_VIEW, new Navigator.EmptyView());
|
||||
// set locale is required for I18N class also, to get the locale from
|
||||
// cookie
|
||||
final String locale = getLocaleId(SPUIDefinitions.getAvailableLocales());
|
||||
final String locale = getLocaleId(uiProperties.getLocalization().getAvailableLocals());
|
||||
setLocale(new Locale(locale));
|
||||
|
||||
if (UI.getCurrent().getErrorHandler() == null) {
|
||||
@@ -209,9 +212,9 @@ public abstract class AbstractHawkbitUI extends UI implements DetachListener {
|
||||
* as set
|
||||
* @return String as preferred locale
|
||||
*/
|
||||
private static String getLocaleId(final Set<String> availableLocalesInApp) {
|
||||
private String getLocaleId(final List<String> availableLocalesInApp) {
|
||||
final String[] localeChain = getLocaleChain();
|
||||
String spLocale = SPUIDefinitions.DEFAULT_LOCALE;
|
||||
String spLocale = uiProperties.getLocalization().getDefaultLocal();
|
||||
if (null != localeChain) {
|
||||
// Find best matching locale
|
||||
for (final String localeId : localeChain) {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
package org.eclipse.hawkbit.ui;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -23,6 +25,8 @@ public class UiProperties implements Serializable {
|
||||
|
||||
private boolean gravatar;
|
||||
|
||||
private final Localization localization = new Localization();
|
||||
|
||||
private final Links links = new Links();
|
||||
|
||||
private final Login login = new Login();
|
||||
@@ -39,6 +43,41 @@ public class UiProperties implements Serializable {
|
||||
this.gravatar = gravatar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Localization information
|
||||
*/
|
||||
public static class Localization implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default localization
|
||||
*/
|
||||
private String defaultLocal = "en";
|
||||
|
||||
/**
|
||||
* List of available localizations
|
||||
*/
|
||||
private List<String> availableLocals = Collections.singletonList("en");
|
||||
|
||||
public String getDefaultLocal() {
|
||||
return defaultLocal;
|
||||
}
|
||||
|
||||
public List<String> getAvailableLocals() {
|
||||
return availableLocals;
|
||||
}
|
||||
|
||||
public void setDefaultLocal(final String defaultLocal) {
|
||||
this.defaultLocal = defaultLocal;
|
||||
}
|
||||
|
||||
public void setAvailableLocals(final List<String> availableLocals) {
|
||||
this.availableLocals = availableLocals;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo account login information.
|
||||
*
|
||||
@@ -375,4 +414,8 @@ public class UiProperties implements Serializable {
|
||||
return event;
|
||||
}
|
||||
|
||||
public Localization getLocalization() {
|
||||
return localization;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ public class CommonDialogWindow extends Window {
|
||||
if (StringUtils.isEmpty(helpLink)) {
|
||||
return;
|
||||
}
|
||||
final Link helpLinkComponent = SPUIComponentProvider.getHelpLink(helpLink);
|
||||
final Link helpLinkComponent = SPUIComponentProvider.getHelpLink(i18n, helpLink);
|
||||
buttonsLayout.addComponent(helpLinkComponent);
|
||||
buttonsLayout.setComponentAlignment(helpLinkComponent, Alignment.MIDDLE_RIGHT);
|
||||
}
|
||||
|
||||
@@ -333,17 +333,19 @@ public final class SPUIComponentProvider {
|
||||
/**
|
||||
* Generates help/documentation links from within management UI.
|
||||
*
|
||||
* @param i18n
|
||||
* the i18n
|
||||
* @param uri
|
||||
* to documentation site
|
||||
*
|
||||
* @return generated link
|
||||
*/
|
||||
public static Link getHelpLink(final String uri) {
|
||||
public static Link getHelpLink(final VaadinMessageSource i18n, final String uri) {
|
||||
|
||||
final Link link = new Link("", new ExternalResource(uri));
|
||||
link.setTargetName("_blank");
|
||||
link.setIcon(FontAwesome.QUESTION_CIRCLE);
|
||||
link.setDescription("Documentation");
|
||||
link.setDescription(i18n.getMessage("tooltip.documentation.link"));
|
||||
return link;
|
||||
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
saveButton = createSaveButton();
|
||||
searchIcon = createSearchIcon();
|
||||
|
||||
helpLink = SPUIComponentProvider.getHelpLink(uiProperties.getLinks().getDocumentation().getTargetfilterView());
|
||||
helpLink = SPUIComponentProvider.getHelpLink(i18n, uiProperties.getLinks().getDocumentation().getTargetfilterView());
|
||||
|
||||
closeIcon = createSearchResetIcon();
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
|
||||
private Link maintenanceWindowHelpLinkControl() {
|
||||
final String maintenanceWindowHelpUrl = uiProperties.getLinks().getDocumentation().getMaintenanceWindowView();
|
||||
return SPUIComponentProvider.getHelpLink(maintenanceWindowHelpUrl);
|
||||
return SPUIComponentProvider.getHelpLink(getI18n(), maintenanceWindowHelpUrl);
|
||||
}
|
||||
|
||||
private void initMaintenanceWindow() {
|
||||
|
||||
@@ -145,7 +145,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
targetsCountLabel = getStatusCountLabel();
|
||||
bulkUploader = getBulkUploadHandler();
|
||||
linkToSystemConfigHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiproperties.getLinks().getDocumentation().getDeploymentView());
|
||||
.getHelpLink(i18n, uiproperties.getLinks().getDocumentation().getDeploymentView());
|
||||
windowCaption = new Label(i18n.getMessage("caption.bulk.upload.targets"));
|
||||
minimizeButton = getMinimizeButton();
|
||||
closeButton = getCloseButton();
|
||||
|
||||
@@ -582,7 +582,7 @@ public class TargetTable extends AbstractTable<Target> {
|
||||
final String tagName = HawkbitCommonUtil.removePrefix(wrapperSource.getId(),
|
||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||
if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
||||
if ("NO TAG".equals(tagName)) {
|
||||
if (getI18n().getMessage("label.no.tag").equals(tagName)) {
|
||||
getNotification()
|
||||
.displayValidationError(getI18n().getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
|
||||
return false;
|
||||
@@ -1033,7 +1033,7 @@ public class TargetTable extends AbstractTable<Target> {
|
||||
|
||||
private Link maintenanceWindowHelpLinkControl() {
|
||||
final String maintenanceWindowHelpUrl = uiProperties.getLinks().getDocumentation().getMaintenanceWindowView();
|
||||
return SPUIComponentProvider.getHelpLink(maintenanceWindowHelpUrl);
|
||||
return SPUIComponentProvider.getHelpLink(getI18n(), maintenanceWindowHelpUrl);
|
||||
}
|
||||
|
||||
private void initMaintenanceWindow() {
|
||||
|
||||
@@ -361,7 +361,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
|
||||
private int getErrorThresholdPercentage(final int amountGroup) {
|
||||
int errorThresoldPercent = Integer.parseInt(errorThreshold.getValue());
|
||||
if (errorThresholdOptionGroup.getValue().equals(ERROR_THRESHOLD_OPTIONS.COUNT.getValue())) {
|
||||
if (errorThresholdOptionGroup.getValue().equals(ERROR_THRESHOLD_OPTIONS.COUNT.getValue(i18n))) {
|
||||
final int groupSize = (int) Math.ceil((double) totalTargetsCount / (double) amountGroup);
|
||||
final int erroThresoldCount = Integer.parseInt(errorThreshold.getValue());
|
||||
errorThresoldPercent = (int) Math.ceil(((float) erroThresoldCount / (float) groupSize) * 100);
|
||||
@@ -683,7 +683,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
private OptionGroup createErrorThresholdOptionGroup() {
|
||||
final OptionGroup errorThresoldOptions = new OptionGroup();
|
||||
for (final ERROR_THRESHOLD_OPTIONS option : ERROR_THRESHOLD_OPTIONS.values()) {
|
||||
errorThresoldOptions.addItem(option.getValue());
|
||||
errorThresoldOptions.addItem(option.getValue(i18n));
|
||||
}
|
||||
errorThresoldOptions.setId(UIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_OPTION_ID);
|
||||
errorThresoldOptions.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
|
||||
@@ -696,7 +696,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
private void listenerOnErrorThresoldOptionChange(final ValueChangeEvent event) {
|
||||
errorThreshold.clear();
|
||||
errorThreshold.removeAllValidators();
|
||||
if (event.getProperty().getValue().equals(ERROR_THRESHOLD_OPTIONS.COUNT.getValue())) {
|
||||
if (event.getProperty().getValue().equals(ERROR_THRESHOLD_OPTIONS.COUNT.getValue(i18n))) {
|
||||
errorThreshold.addValidator(new ErrorThresholdOptionValidator());
|
||||
} else {
|
||||
errorThreshold.addValidator(new ThresholdFieldValidator());
|
||||
@@ -828,7 +828,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
}
|
||||
|
||||
private void setDefaultSaveStartGroupOption() {
|
||||
errorThresholdOptionGroup.setValue(ERROR_THRESHOLD_OPTIONS.PERCENT.getValue());
|
||||
errorThresholdOptionGroup.setValue(ERROR_THRESHOLD_OPTIONS.PERCENT.getValue(i18n));
|
||||
}
|
||||
|
||||
private static TextArea createDescription() {
|
||||
@@ -1106,18 +1106,17 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
|
||||
private enum ERROR_THRESHOLD_OPTIONS {
|
||||
|
||||
PERCENT("%"),
|
||||
|
||||
COUNT("Count");
|
||||
PERCENT("label.errorthreshold.option.percent"),
|
||||
COUNT("label.errorthreshold.option.count");
|
||||
|
||||
private final String value;
|
||||
|
||||
ERROR_THRESHOLD_OPTIONS(final String val) {
|
||||
value = val;
|
||||
ERROR_THRESHOLD_OPTIONS(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String getValue() {
|
||||
return value;
|
||||
private String getValue(final VaadinMessageSource i18n) {
|
||||
return i18n.getMessage(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3);
|
||||
|
||||
final Link linkToSecurityHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getSecurity());
|
||||
.getHelpLink(i18n, uiProperties.getLinks().getDocumentation().getSecurity());
|
||||
gridLayout.addComponent(linkToSecurityHelp, 2, 3);
|
||||
gridLayout.setComponentAlignment(linkToSecurityHelp, Alignment.BOTTOM_RIGHT);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RolloutConfigurationView extends BaseConfigurationView
|
||||
hLayout.addComponent(approvalConfigurationItem);
|
||||
|
||||
final Link linkToApprovalHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getRollout());
|
||||
.getHelpLink(i18n, uiProperties.getLinks().getDocumentation().getRollout());
|
||||
hLayout.addComponent(linkToApprovalHelp);
|
||||
hLayout.setComponentAlignment(linkToApprovalHelp, Alignment.BOTTOM_RIGHT);
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
|
||||
hlayout.addComponent(undoConfigurationBtn);
|
||||
|
||||
final Link linkToSystemConfigHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getSystemConfigurationView());
|
||||
.getHelpLink(i18n, uiProperties.getLinks().getDocumentation().getSystemConfigurationView());
|
||||
hlayout.addComponent(linkToSystemConfigHelp);
|
||||
|
||||
return hlayout;
|
||||
|
||||
@@ -8,25 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.utils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
/**
|
||||
* Class to provide the unchanged constants.
|
||||
*/
|
||||
public final class SPUIDefinitions {
|
||||
/**
|
||||
* Available locales.
|
||||
*/
|
||||
private static final Set<String> AVAILABLE_LOCALES = Stream.of("en", "de").collect(Collectors.toSet());
|
||||
|
||||
/**
|
||||
* Default locale.
|
||||
*/
|
||||
public static final String DEFAULT_LOCALE = "en";
|
||||
/**
|
||||
* Locale cookie name.
|
||||
*/
|
||||
@@ -388,13 +375,4 @@ public final class SPUIDefinitions {
|
||||
private SPUIDefinitions() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the locales
|
||||
*
|
||||
* @return the availableLocales
|
||||
*/
|
||||
public static Set<String> getAvailableLocales() {
|
||||
return AVAILABLE_LOCALES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +242,14 @@ label.scheduled = Scheduled
|
||||
label.approval.decision = Approval decision
|
||||
label.approval.remark = Remark (optional)
|
||||
label.drop.area.upload = Drop Files to upload
|
||||
label.errorthreshold.option.percent = %
|
||||
label.errorthreshold.option.count = Count
|
||||
label.targetUpdateStatus.unknown = Unknown
|
||||
label.targetUpdateStatus.in_sync = In Sync
|
||||
label.targetUpdateStatus.pending = Pending
|
||||
label.targetUpdateStatus.error = Error
|
||||
label.targetUpdateStatus.registered = Registered
|
||||
|
||||
|
||||
# Checkbox label prefix with - checkbox
|
||||
checkbox.dist.migration.required = Required Migration Step :
|
||||
@@ -279,6 +287,7 @@ tooltip.metadata.icon = Manage Metadata..
|
||||
tooltip.next.maintenance.window = next on {0}
|
||||
tooltip.target.attributes.update.request = Request attributes update
|
||||
tooltip.target.attributes.update.requested = Update already requested
|
||||
tooltip.documentation.link=Documentation
|
||||
|
||||
#rollout action
|
||||
tooltip.rollout.run = Run
|
||||
@@ -313,7 +322,7 @@ message.dist.pending.action = Target {0} is already assigned with distribution
|
||||
message.empty.target.tags= No Tags Created
|
||||
message.empty.disttype.tags = No Distribution type tags created
|
||||
message.select.row = Please select a row to drag
|
||||
message.error = Unknown error occured during the operation. Please contact administrator
|
||||
message.error = Unknown error occurred during the operation. Please contact administrator
|
||||
message.dist.assigned.one = {0} is assigned to {1}
|
||||
message.dist.assigned.many = {0} DistributionSets are assigned to {1}
|
||||
message.dist.unassigned.one = {0} is unassigned from {1}
|
||||
@@ -324,12 +333,12 @@ message.target.unassigned.one = {0} is unassigned from {1}
|
||||
message.target.unassigned.many = {0} Targets are unassigned from {1}
|
||||
message.target.assigned.pending = Some target(s) are already assigned.Pending for action
|
||||
message.cannot.delete = Cannot be deleted
|
||||
message.check.softwaremodule = Please provide both name and verion!
|
||||
message.check.softwaremodule = Please provide both name and version!
|
||||
message.duplicate.softwaremodule = {0} : {1} already exists!
|
||||
message.tag.delete = Please unclick the tag {0} before deleting
|
||||
message.dist.type.check.delete = Please unclick the distribution type {0} before deleting
|
||||
message.tag.delete = Please deselect the tag {0} before deleting
|
||||
message.dist.type.check.delete = Please deselect the distribution type {0} before deleting
|
||||
message.cannot.delete.default.dstype = Default distribution set type cannot be deleted
|
||||
message.swmodule.type.check.delete = Please unclick the Software Module type {0} before deleting
|
||||
message.swmodule.type.check.delete = Please deselect the Software Module type {0} before deleting
|
||||
message.targets.already.deleted = Few Target(s) are already deleted. Pending for action
|
||||
message.dists.already.deleted = Few distribution(s) are already deleted.Pending for action
|
||||
message.target.deleted.pending = Target(s) already deleted.Pending for action
|
||||
|
||||
Reference in New Issue
Block a user