Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8381 curation lables internationalization #8466

Merged
8 changes: 8 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,14 @@ Each set of labels is identified by a curationLabelSet name and a JSON Array of

``curl -X PUT -d '{"Standard Process":["Author contacted", "Privacy Review", "Awaiting paper publication", "Final Approval"], "Alternate Process":["State 1","State 2","State 3"]}' http://localhost:8080/api/admin/settings/:AllowedCurationLabels``

If the Dataverse Installation supports multiple languages, the curation label translations should be added to the ``CurationLabels`` properties files. (See :ref:`i18n` for more on properties files and internationalization in general.)
Since the Curation labels are free text, while creating the key, it has to be converted to lowercase, replace space with underscore.

Example::

standard_process=Standard Process
author_contacted=Author contacted

.. _:AllowCustomTermsOfUse:

:AllowCustomTermsOfUse
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5647,7 +5647,10 @@ public void setExternalStatus(String status) {
if (status == null || status.isEmpty()) {
JsfHelper.addInfoMessage(BundleUtil.getStringFromBundle("dataset.externalstatus.removed"));
} else {
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), BundleUtil.getStringFromBundle("dataset.externalstatus.info", Arrays.asList(status)));
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"),
BundleUtil.getStringFromBundle("dataset.externalstatus.info",
Arrays.asList(DatasetUtil.getLocaleExternalStatus(status))
));
}

} catch (CommandException ex) {
Expand All @@ -5656,7 +5659,7 @@ public void setExternalStatus(String status) {
JsfHelper.addErrorMessage(msg);
}
}

public List<String> getAllowedExternalStatuses() {
return settingsWrapper.getAllowedExternalStatuses(dataset);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.util.MarkupChecker;
import edu.harvard.iq.dataverse.util.BundleUtil;
import edu.harvard.iq.dataverse.DatasetFieldType.FieldType;
import edu.harvard.iq.dataverse.branding.BrandingUtil;
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataversePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.authorization.users.User;
import edu.harvard.iq.dataverse.dataaccess.DataAccess;
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
import edu.harvard.iq.dataverse.dataverse.DataverseUtil;
import edu.harvard.iq.dataverse.engine.command.Command;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
Expand Down Expand Up @@ -1249,8 +1250,10 @@ public Set<Entry<String, String>> getCurationLabelSetOptions() {
}
// Add an entry for disabled
setNames.put(BundleUtil.getStringFromBundle("dataverse.curationLabels.disabled"), SystemConfig.CURATIONLABELSDISABLED);

allowedSetNames.forEach(name -> {
setNames.put(name, name);
String localizedName = DatasetUtil.getLocaleExternalStatus(name) ;
setNames.put(localizedName,name);
});
}
curationLabelSetOptions = setNames.entrySet();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,19 @@ public static String getLicenseDescription(DatasetVersion dsv) {
License license = dsv.getTermsOfUseAndAccess().getLicense();
return license != null ? license.getShortDescription() : BundleUtil.getStringFromBundle("license.custom.description");
}

public static String getLocaleExternalStatus(String status) {
String localizedName = "" ;
try {
localizedName = BundleUtil.getStringFromPropertyFile(status.toLowerCase().replace(" ", "_"), "CurationLabels");
}
catch (Exception e) {
localizedName = status;
}

if (localizedName == null) {
localizedName = status ;
}
return localizedName;
}
}
6 changes: 4 additions & 2 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
<h:outputText value="#{bundle['dataset.versionUI.inReview']}" styleClass="label label-success" rendered="#{DatasetPage.workingVersion.inReview}"/>
<h:outputText value="#{bundle['dataset.versionUI.unpublished']}" styleClass="label label-warning" rendered="#{!DatasetPage.dataset.released}"/>
<h:outputText value="#{bundle['dataset.versionUI.deaccessioned']}" styleClass="label label-danger" rendered="#{DatasetPage.workingVersion.deaccessioned}"/>
<h:outputText value="#{DatasetPage.workingVersion.externalStatusLabel}" styleClass="label label-info" rendered="#{DatasetPage.workingVersion.externalStatusLabel!=null and DatasetPage.canPublishDataset()}"/>
<o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
<h:outputText value="#{DatasetUtil:getLocaleExternalStatus(DatasetPage.workingVersion.externalStatusLabel)}" styleClass="label label-info" rendered="#{DatasetPage.workingVersion.externalStatusLabel!=null and DatasetPage.canPublishDataset()}"/>
<!-- DATASET VERSION NUMBER -->
<h:outputText styleClass="label label-default" rendered="#{DatasetPage.workingVersion.released and !(DatasetPage.workingVersion.draft or DatasetPage.workingVersion.inReview or DatasetPage.workingVersion.deaccessioned)}"
value="#{bundle['file.DatasetVersion']} #{DatasetPage.workingVersion.versionNumber}.#{DatasetPage.workingVersion.minorVersionNumber}"/>
Expand Down Expand Up @@ -340,8 +341,9 @@
<ul class="dropdown-menu">
<ui:repeat value="#{DatasetPage.allowedExternalStatuses}" var="status">
<li>
<o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
<p:commandLink action="#{DatasetPage.setExternalStatus(status)}" update=":datasetForm:topDatasetBlockFragment,:messagePanel">
#{status}
#{DatasetUtil:getLocaleExternalStatus(status)}
</p:commandLink>
</li>
</ui:repeat>
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/search-include-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@
<!--DATASET CARDS-->
<div class="datasetResult clearfix" jsf:rendered="#{result.type == 'datasets'}">
<div class="card-title-icon-block">
<o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
<span class="glyphicon glyphicon-link text-info pull-right" title="#{bundle.linked}" jsf:rendered="#{!SearchIncludeFragment.rootDv and !result.isInTree}"/>
<span class="glyphicon glyphicon-new-window text-info pull-right" title="#{bundle.harvested}" jsf:rendered="#{result.harvested}"/>
<span class="icon-dataset text-info pull-right" title="#{bundle.dataset}"/>
Expand All @@ -548,7 +549,7 @@
<h:outputText value="#{bundle['dataset.versionUI.unpublished']}" styleClass="label label-warning" rendered="#{result.unpublishedState}"/>
<h:outputText value="#{bundle['dataset.versionUI.deaccessioned']}" styleClass="label label-danger" rendered="#{result.deaccessionedState}"/>
<h:outputText value="#{bundle['embargoed']}" styleClass="label label-primary" rendered="#{SearchIncludeFragment.isActivelyEmbargoed(result)}"/>
<h:outputText value="#{result.externalStatus}" styleClass="label label-info" rendered="#{!empty result.externalStatus and SearchIncludeFragment.canPublishDataset(result.entityId)}"/>
<h:outputText value="#{DatasetUtil:getLocaleExternalStatus(result.externalStatus)}" styleClass="label label-info" rendered="#{!empty result.externalStatus and SearchIncludeFragment.canPublishDataset(result.entityId)}"/>
<h:outputText value="#{result.userRole}" styleClass="label label-primary" rendered="#{!empty result.userRole}"/>
</div>
<div class="card-preview-icon-block text-center">
Expand Down