Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Externalised strings in validation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 3, 2013
1 parent e813bba commit 17e187d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
Expand Up @@ -76,6 +76,7 @@
import org.zanata.service.TranslationService;
import org.zanata.service.ValidationService;
import org.zanata.util.ShortString;
import org.zanata.util.ZanataMessages;
import org.zanata.webtrans.shared.model.TransUnitId;
import org.zanata.webtrans.shared.model.TransUnitUpdateInfo;
import org.zanata.webtrans.shared.model.TransUnitUpdateRequest;
Expand Down Expand Up @@ -132,6 +133,9 @@ public class TranslationServiceImpl implements TranslationService {
@In
private TranslationMergeServiceFactory translationMergeServiceFactory;

@In
private ZanataMessages zanataMessages;

@Override
public List<TranslationResult> translate(LocaleId localeId,
List<TransUnitUpdateRequest> translationRequests) {
Expand All @@ -140,7 +144,7 @@ public List<TranslationResult> translate(LocaleId localeId,

/**
* This is used when reverting translation
*
*
* @param localeId
* @param translationRequests
* @return
Expand Down Expand Up @@ -271,7 +275,7 @@ private static boolean isReviewState(ContentState contentState) {
/**
* Generate a {@link HLocale} for the given localeId and check that
* translations for this locale are permitted.
*
*
* @param localeId
* @param projectIteration
* @return the valid hLocale
Expand Down Expand Up @@ -357,7 +361,7 @@ private boolean setContentIfChanged(
/**
* Check that requestedState is valid for the given content, adjust if
* necessary and set the new state if it has changed.
*
*
* @return true if the content state or contents list were updated, false
* otherwise
* @see #adjustContentsAndState(org.zanata.model.HTextFlowTarget, int,
Expand Down Expand Up @@ -397,7 +401,7 @@ private boolean setContentStateIfChanged(
/**
* Checks target state against its contents. If necessary, modifies target
* state and generates a warning
*
*
* @param target
* HTextFlowTarget to check/modify
* @param nPlurals
Expand All @@ -424,7 +428,7 @@ private static boolean adjustContentsAndState(

/**
* Ensures that target.contents has exactly legalSize elements
*
*
* @param target
* HTextFlowTarget to check/modify
* @param legalSize
Expand Down Expand Up @@ -503,7 +507,7 @@ List<String> translateAllInDoc(String projectSlug,
/**
* Run enforced validation check(Error) if target has changed and
* translation saving as 'Translated' or 'Approved'
*
*
* @param newState
* @param projectVersion
* @param targetId
Expand All @@ -523,13 +527,14 @@ private String validateTranslations(ContentState newState,

if (!validationMessages.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("Translation ")
.append(ShortString.shorten(translations.get(0)))
.append(" contains validation error - \n");
for (String validationMessage : validationMessages) {
sb.append(validationMessage).append("\n");
}
message = sb.toString();
message =
zanataMessages.getMessage(
"jsf.TranslationContainsError",
ShortString.shorten(translations.get(0)),
sb.toString());
}
}
return message;
Expand Down
Expand Up @@ -568,4 +568,7 @@ String undoUnsuccessful(@PluralCount int unsuccessfulCount,

@DefaultMessage("Confirm rejection (ctrl + enter)")
String confirmRejection();

@DefaultMessage("More details")
String moreDetais();
}
Expand Up @@ -23,6 +23,7 @@

import org.zanata.webtrans.client.events.NotificationEvent;
import org.zanata.webtrans.client.presenter.NotificationDetailListener;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.util.DateUtil;

import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class NotificationItem extends Composite {
private static NotificationItemLineUiBinder uiBinder = GWT
.create(NotificationItemLineUiBinder.class);

public NotificationItem(final NotificationEvent notificationEvent,
public NotificationItem(final WebTransMessages messages, final NotificationEvent notificationEvent,
final NotificationDetailListener listener) {

initWidget(uiBinder.createAndBindUi(this));
Expand All @@ -66,7 +67,7 @@ public NotificationItem(final NotificationEvent notificationEvent,
link.setVisible(false);
}

details.setText("More details");
details.setText(messages.moreDetais());
details.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Expand Down
Expand Up @@ -108,6 +108,8 @@ interface Styles extends CssResource {

private final NotificationDetailsBox notificationDetailsBox;

private final WebTransMessages messages;

private Listener listener;

@Inject
Expand All @@ -120,6 +122,7 @@ public AppView(WebTransMessages messages,
final UserWorkspaceContext userWorkspaceContext) {
// this must be initialized before uiBinder.createAndBindUi(), or an
// exception will be thrown at runtime
this.messages = messages;
translationStatsBar =
new TransUnitCountBar(userWorkspaceContext, messages,
LabelFormat.PERCENT_COMPLETE_HRS, true,
Expand Down Expand Up @@ -319,7 +322,7 @@ public void setKeyboardShorcutColor(boolean aliasKeyListening) {

public void showNotification(NotificationEvent notification) {
notifications.clear();
notifications.add(new NotificationItem(notification, this));
notifications.add(new NotificationItem(messages, notification, this));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion zanata-war/src/main/resources/messages.properties
Expand Up @@ -376,7 +376,7 @@ jsf.iteration.files.translateDenied.VersionIsObsolete=This project version is Ob
jsf.iteration.files.translateDenied.UserNotTranslatorInLanguageTeam=You are a not translator of the {0} language team.
! {0} is a list of user roles
jsf.iteration.files.translateDenied.UserNotInProjectRole=You must be part of these user roles to translate this project: {0}

jsf.TranslationContainsError=Translation \"{0}\" contains the following error:\n{1}


#------ [home] > Groups ------
Expand Down

0 comments on commit 17e187d

Please sign in to comment.