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

Commit

Permalink
rhbz830009 - Source locale is now selectable when uploading documents.
Browse files Browse the repository at this point in the history
The default language is en-US when enabled, otherwise it will default to the first available language.
  • Loading branch information
Carlos Munoz committed Jul 4, 2012
1 parent d8c9020 commit fe19749
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
Expand Up @@ -49,11 +49,15 @@
import org.zanata.rest.dto.resource.TranslationsResource;
import org.zanata.security.ZanataIdentity;
import org.zanata.service.DocumentService;
import org.zanata.service.LocaleService;
import org.zanata.service.TranslationFileService;
import org.zanata.service.TranslationService;

import javax.faces.context.FacesContext;

import lombok.Getter;
import lombok.Setter;

@Name("projectIterationFilesAction")
@Scope(ScopeType.PAGE)
public class ProjectIterationFilesAction
Expand Down Expand Up @@ -173,6 +177,8 @@ public String uploadDocumentFile()
Resource doc = this.translationFileServiceImpl.parseDocumentFile(this.documentFileUpload.getFileContents(),
this.documentFileUpload.getDocumentPath(), this.documentFileUpload.getFileName());

doc.setLang( new LocaleId(this.documentFileUpload.getSourceLang()) );

// TODO Copy Trans values
// Extensions are hard-coded to GetText, since it is the only supported format at the time
this.documentServiceImpl.saveDocument(this.projectSlug, this.iterationSlug,
Expand All @@ -195,6 +201,11 @@ public String uploadDocumentFile()
return FacesContext.getCurrentInstance().getViewRoot().getViewId();
}

public List<HLocale> getAvailableSourceLocales()
{
return localeDAO.findAllActive();
}

public boolean isFileUploadAllowed()
{
HProjectIteration projectIteration = this.projectIterationDAO.getBySlug(projectSlug, iterationSlug);
Expand Down Expand Up @@ -331,40 +342,20 @@ public void setMergeTranslations(boolean mergeTranslations)
*/
public static class DocumentFileUploadHelper
{
@Getter
@Setter
private InputStream fileContents;

@Getter
@Setter
private String fileName;

@Getter
@Setter
private String documentPath;

public InputStream getFileContents()
{
return fileContents;
}

public void setFileContents(InputStream fileContents)
{
this.fileContents = fileContents;
}

public String getFileName()
{
return fileName;
}

public void setFileName(String fileName)
{
this.fileName = fileName;
}

public String getDocumentPath()
{
return documentPath;
}

public void setDocumentPath(String documentPath)
{
this.documentPath = documentPath;
}
@Getter
@Setter
private String sourceLang = "en-US"; // en-US by default
}
}
9 changes: 9 additions & 0 deletions zanata-war/src/main/webapp/iteration/files.xhtml
Expand Up @@ -246,6 +246,15 @@
value="#{projectIterationFilesAction.documentFileUpload.documentPath}">
<h:outputLabel for="docPath" value="#{messages['jsf.iteration.files.DocumentPath']}"/>
</h:inputText>
<br/>
<h:selectOneMenu value="#{projectIterationFilesAction.documentFileUpload.sourceLang}">
<s:selectItems value="#{projectIterationFilesAction.availableSourceLocales}"
var="locale"
label="#{locale.retrieveNativeName()}"
itemValue="#{locale.localeId.toString()}"
escape="true"/>
<h:outputLabel value="Source Language"/>
</h:selectOneMenu>
<div align="right">
<h:commandButton value="#{messages['jsf.iteration.files.Upload']}"
action="#{projectIterationFilesAction.uploadDocumentFile}"/>
Expand Down

0 comments on commit fe19749

Please sign in to comment.