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

Commit

Permalink
rhbz978666 - localize some strings and some styles change
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Jul 18, 2013
1 parent 6ce9e24 commit 4ff622c
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 17 deletions.
Expand Up @@ -110,7 +110,7 @@ protected void displayEntries(TransHistoryItem latest, List<TransHistoryItem> ot
List<String> newTargets = targetContentsPresenter.getNewTargets();
if (!Objects.equal(latest.getContents(), newTargets))
{
all.add(new TransHistoryItem(messages.unsaved(), newTargets, ContentState.New, messages.you(), new Date()));
all.add(new TransHistoryItem(messages.unsaved(), newTargets, null, messages.you(), new Date()));
}
}
all.addAll(otherEntries);
Expand Down
Expand Up @@ -56,4 +56,22 @@ public interface EnumMessages extends com.google.gwt.i18n.client.Messages

@DefaultMessage("Next Fuzzy/Rejected/Untranslated")
String nextIncomplete();

@DefaultMessage("Untranslated")
String contentStateUntranslated();

@DefaultMessage("Fuzzy")
String contentStateFuzzy();

@DefaultMessage("Translated")
String contentStateTranslated();

@DefaultMessage("Approved")
String contentStateApproved();

@DefaultMessage("Rejected")
String contentStateRejected();

@DefaultMessage("Unsaved")
String contentStateUnsaved();
}
Expand Up @@ -547,4 +547,10 @@ public interface WebTransMessages extends Messages

@DefaultMessage("You")
String you();

@DefaultMessage("Compare")
String compare();

@DefaultMessage("Remove from comparison")
String removeFromComparison();
}
@@ -0,0 +1,66 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/

package org.zanata.webtrans.client.ui;

import org.zanata.common.ContentState;
import org.zanata.webtrans.client.resources.EnumMessages;
import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@Singleton
public class ContentStateRenderer extends EnumRenderer<ContentState>
{
private final EnumMessages messages;

@Inject
public ContentStateRenderer(EnumMessages messages)
{
this.messages = messages;
}

@Override
public String render(ContentState object)
{
if (object == null)
{
return messages.contentStateUnsaved();
}
switch (object)
{
case New:
return messages.contentStateUntranslated();
case NeedReview:
return messages.contentStateFuzzy();
case Translated:
return messages.contentStateTranslated();
case Approved:
return messages.contentStateApproved();
case Rejected:
return messages.contentStateRejected();
default:
return getEmptyValue();
}
}
}
Expand Up @@ -23,7 +23,7 @@
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:HTMLPanel tag="li" styleName="l--pad-v-half">
<div class="g">
<div class="g__item w--1-12 txt--align-right"><i class="icon-comment-3"/><span class="is-invisible">Comment</span></div>
<div class="g__item w--1-12 txt--align-right"><i class="i--comment i"/><span class="is-invisible">Comment</span></div>
<div class="g__item w--9-12">
<g:InlineHTML ui:field="heading"/>
<g:InlineHTML ui:field="commentContent"/>
Expand Down
Expand Up @@ -22,6 +22,7 @@
package org.zanata.webtrans.client.ui;

import org.zanata.common.ContentState;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.util.DateUtil;
import org.zanata.webtrans.shared.model.TransHistoryItem;
import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -57,12 +58,16 @@ public class TransHistoryItemLine extends Composite
Anchor compare;
@UiField
Anchor copyIntoEditor;
@UiField
WebTransMessages messages;

public TransHistoryItemLine(TransHistoryItem item, TranslationHistoryDisplay.Listener listener)
public TransHistoryItemLine(TransHistoryItem item, TranslationHistoryDisplay.Listener listener, ContentStateRenderer stateRenderer)
{
this.item = item;
this.listener = listener;
heading = new InlineHTML(template.heading(item.getModifiedBy(), stateToStyle(item.getStatus()), item.getStatus().name()));
// modified by person can be empty if translation is pushed from client
String person = item.getModifiedBy().isEmpty() ? "(Someone offline)" : item.getModifiedBy();
heading = new InlineHTML(template.heading(person, stateToStyle(item.getStatus()), stateRenderer.render(item.getStatus())));
targetContents = new InlineHTML(template.targetContent(TextContentsDisplay.asSyntaxHighlight(item.getContents()).toSafeHtml()));
revision = new InlineHTML(template.targetRevision(item.getVersionNum(), item.getOptionalTag()));
initWidget(ourUiBinder.createAndBindUi(this));
Expand All @@ -72,18 +77,22 @@ public TransHistoryItemLine(TransHistoryItem item, TranslationHistoryDisplay.Lis

private static String stateToStyle(ContentState status)
{
if (status == null)
{
return "";
}
switch (status)
{
case New:
return "txt--status--new";
return "txt--state-neutral";
case NeedReview:
return "txt--status--unsure";
return "txt--state-unsure";
case Translated:
return "txt--status--success";
return "txt--state-success";
case Approved:
return "txt--status--approved";
return "txt--state-highlight";
case Rejected:
return "txt--status--warning";
return "txt--state-danger";
}
return "";
}
Expand All @@ -100,11 +109,11 @@ public void compareClicked(ClickEvent event)
listener.compareClicked(item);
if (listener.isItemInComparison(item))
{
compare.setText("Remove from comparison");
compare.setText(messages.removeFromComparison());
}
else
{
compare.setText("Compare");
compare.setText(messages.compare());
}
}

Expand Down
Expand Up @@ -21,10 +21,12 @@

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field="messages" type="org.zanata.webtrans.client.resources.WebTransMessages" />

<g:HTMLPanel tag="li" styleName="l--pad-v-1 bg--higher">
<div class="g">
<div class="g__item w--1-12 txt--align-right">
<i class="icon-edit"/>
<i class="i--pencil i"/>
<span class="is-invisible">Translation</span>
</div>
<div class="g__item w--9-12">
Expand Down
Expand Up @@ -38,6 +38,7 @@ public class TranslationHistoryView extends DialogBox implements TranslationHist
{
private static final int COMPARISON_TAB_INDEX = 1;
private static TranslationHistoryViewUiBinder uiBinder = GWT.create(TranslationHistoryViewUiBinder.class);
private final ContentStateRenderer stateRenderer;
@UiField
WebTransMessages messages;
@UiField
Expand All @@ -62,9 +63,11 @@ public class TranslationHistoryView extends DialogBox implements TranslationHist
private Listener listener;
private List<ComparableByDate> items = Lists.newArrayList();

public TranslationHistoryView()
@Inject
public TranslationHistoryView(ContentStateRenderer stateRenderer)
{
super(true, true);
this.stateRenderer = stateRenderer;
closeButton = new DialogBoxCloseButton(this);
HTMLPanel container = uiBinder.createAndBindUi(this);
ensureDebugId("transHistory");
Expand Down Expand Up @@ -93,7 +96,7 @@ private void redrawList()
{
if (item instanceof TransHistoryItem)
{
itemList.add(new TransHistoryItemLine((TransHistoryItem) item, listener));
itemList.add(new TransHistoryItemLine((TransHistoryItem) item, listener, stateRenderer));
}
if (item instanceof ReviewComment)
{
Expand Down
Expand Up @@ -14,7 +14,7 @@
</ui:style>

<g:HTMLPanel width="800px" height="600px" styleName="new-zanata">
<g:Button ui:field="compareButton" title="{messages.translationHistoryComparisonTitle}" styleName="icon-exchange {style.compareButton}" />
<g:Button ui:field="compareButton" title="{messages.translationHistoryComparisonTitle}" styleName="icon-exchange {style.compareButton} l--push-v-half" />
<g:TabLayoutPanel ui:field="tabLayoutPanel" barUnit='PX' barHeight='20' width="100%" height="95%">
<g:tab>
<g:customHeader>
Expand All @@ -25,8 +25,8 @@
<g:ScrollPanel>
<g:HTMLPanel ui:field="historyPanel" styleName="l__wrapper l--push-v-1" >
<div class="g">
<div class="g__item w--1-12 txt--align-right"><i class="icon-comment-3"/><span class="is-invisible">Comment</span></div>
<div class="w--9-12 g__item"><g:TextArea name="comment" ui:field="commentTextArea" /></div>
<div class="g__item w--1-12 txt--align-right"><i class="i--comment i"/><span class="is-invisible">Comment</span></div>
<div class="w--9-12 g__item"><g:TextArea name="comment" styleName="basic-input" ui:field="commentTextArea" /></div>
<div class="w--2-12 g__item"><g:Button addStyleNames="button--full" text="Add Comment" ui:field="addCommentButton" /></div>
</div>
<z:UnorderedListWidget styleName="list--slat d--top" ui:field="itemList"/>
Expand Down

0 comments on commit 4ff622c

Please sign in to comment.