Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
03c242b
license internationalization - first commit
JayanthyChengan Aug 8, 2022
47f7b05
Merge branch 'IQSS:develop' into licenseInternationalizataion
JayanthyChengan Aug 10, 2022
4af332c
Merge remote-tracking branch 'origin/develop' into licenseInternation…
JayanthyChengan Sep 26, 2022
b7ea430
license internationalization
JayanthyChengan Sep 26, 2022
eefbc86
Merge remote-tracking branch 'SP/licenseInternationalizataion' into l…
JayanthyChengan Sep 26, 2022
4b519bf
Merge remote-tracking branch 'SP/develop' into licenseInternationaliz…
JayanthyChengan Oct 12, 2022
c2f9c58
license name translation
JayanthyChengan Oct 14, 2022
6ce35f4
Merge remote-tracking branch 'SP/develop' into licenseInternationaliz…
JayanthyChengan Oct 14, 2022
240f5a5
Merge branch 'IQSS:develop' into licenseInternationalizataion
JayanthyChengan Oct 20, 2022
6011d52
Merge remote-tracking branch 'SP/develop' into licenseInternationaliz…
JayanthyChengan Nov 2, 2022
1447075
Merge branch 'licenseInternationalizataion' of https://github.com/sch…
JayanthyChengan Nov 2, 2022
aa321f3
handled class cast exception
JayanthyChengan Nov 2, 2022
e068cab
correction
JayanthyChengan Nov 3, 2022
57dd54a
added additional doc
JayanthyChengan Nov 3, 2022
b9b192e
Merge branch 'IQSS:develop' into licenseInternationalizataion
JayanthyChengan Nov 3, 2022
7dce7d7
refactored
JayanthyChengan Nov 8, 2022
00c9627
Merge remote-tracking branch 'IQSS/develop' into licenseInternational…
JayanthyChengan Nov 8, 2022
c59f30b
Merge branch 'licenseInternationalizataion' of https://github.com/sch…
JayanthyChengan Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1044,6 +1044,14 @@ On a new Dataverse installation, users may select from the following licenses or

(Note that existing Dataverse installations which are upgraded from 5.9 or previous will only offer CC0 1.0, added automatically during the upgrade to version 5.10.)

If the Dataverse Installation supports multiple languages, the license name/description translations should be added to the ``License`` properties files. (See :ref:`i18n` for more on properties files and internationalization in general.)
To create the key, the license name has to be converted to lowercase, replace space with underscore.

Example::

license.cc0_1.0.description=Creative Commons CC0 1.0 Universal Public Domain Dedication.
license.cc0_1.0.name=CC0 1.0

You have a lot of control over which licenses and terms are available. You can remove licenses and add new ones. You can decide which license is the default. You can remove "Custom Dataset Terms" as a option. You can remove all licenses and make "Custom Dataset Terms" the only option.

Before making changes, you are encouraged to read the :ref:`license-terms` section of the User Guide about why CC0 is the default and what the "Custom Dataset Terms" option allows.
Expand Down
36 changes: 28 additions & 8 deletions src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.logging.Logger;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import org.apache.commons.io.IOUtils;
import static edu.harvard.iq.dataverse.dataaccess.DataAccess.getStorageIO;
Expand All @@ -43,6 +39,7 @@
import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.EnumUtils;

public class DatasetUtil {

Expand Down Expand Up @@ -459,7 +456,7 @@ public static List<DatasetField> getDatasetSummaryFields(DatasetVersion datasetV
}

public static boolean isRsyncAppropriateStorageDriver(Dataset dataset){
// ToDo - rsync was written before multiple store support and currently is hardcoded to use the DataAccess.S3 store.
// ToDo - rsync was written before multiple store support and currently is hardcoded to use the DataAccess.S3 store.
// When those restrictions are lifted/rsync can be configured per store, this test should check that setting
// instead of testing for the 's3" store,
//This method is used by both the dataset and edit files page so one change here
Expand Down Expand Up @@ -551,7 +548,7 @@ public static License getLicense(DatasetVersion dsv) {

public static String getLicenseName(DatasetVersion dsv) {
License license = DatasetUtil.getLicense(dsv);
return license != null ? license.getName()
return license != null ? getLocalizedLicenseDetails(license,"NAME")
: BundleUtil.getStringFromBundle("license.custom");
}

Expand All @@ -577,7 +574,30 @@ public static String getLicenseIcon(DatasetVersion dsv) {

public static String getLicenseDescription(DatasetVersion dsv) {
License license = DatasetUtil.getLicense(dsv);
return license != null ? license.getShortDescription() : BundleUtil.getStringFromBundle("license.custom.description");
return license != null ? getLocalizedLicenseDetails(license,"DESCRIPTION") : BundleUtil.getStringFromBundle("license.custom.description");
}

public enum LicenseOption {
NAME, DESCRIPTION
};

public static String getLocalizedLicenseDetails(License license,String keyPart) {
String licenseName = license.getName();
String localizedLicenseValue = "" ;
try {
if (EnumUtils.isValidEnum(LicenseOption.class, keyPart ) ){
String key = "license." + licenseName.toLowerCase().replace(" ", "_") + "." + keyPart.toLowerCase();
localizedLicenseValue = BundleUtil.getStringFromPropertyFile(key, "License");
}
}
catch (Exception e) {
localizedLicenseValue = licenseName;
}

if (localizedLicenseValue == null) {
localizedLicenseValue = licenseName ;
}
return localizedLicenseValue;
}

public static String getLocaleExternalStatus(String status) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/propertyFiles/License.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
license.cc0_1.0.description=Creative Commons CC0 1.0 Universal Public Domain Dedication.
license.cc_by_4.0.description=Creative Commons Attribution 4.0 International License.
license.cc0_1.0.name=CC0 1.0
license.cc_by_4.0.name=CC-BY 4.0
6 changes: 3 additions & 3 deletions src/main/webapp/dataset-license-terms.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<p class="help-block"><h:outputText value="#{bundle['file.dataFilesTab.terms.list.license.edit.description']}" escape="false"/></p>
<p:selectOneMenu id="licenses" value="#{termsOfUseAndAccess.license}" style="width: 40%" converter="licenseConverter">
<f:selectItems value="#{licenseServiceBean.listAllActive()}"
var="license" itemLabel="#{license.name}" itemValue="#{license}"/>
var="license" itemLabel="#{DatasetUtil:getLocalizedLicenseDetails(license, 'NAME')}" itemValue="#{license}"/>
<c:if test="#{settingsWrapper.customLicenseAllowed}">
<f:selectItem itemLabel="#{bundle['license.custom']}" itemValue="#{null}"/>
</c:if>
Expand All @@ -55,8 +55,8 @@
</ui:fragment>
<ui:fragment rendered="#{!empty termsOfUseAndAccess.license}">
<p>
<img src="#{termsOfUseAndAccess.license.iconUrl}" title="#{termsOfUseAndAccess.license.shortDescription}" style="display:none" onload="this.style.display='inline'" />
<a href="#{termsOfUseAndAccess.license.uri}" title="#{termsOfUseAndAccess.license.shortDescription}" target="_blank">#{termsOfUseAndAccess.license.name}</a>
<img src="#{termsOfUseAndAccess.license.iconUrl}" title="#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license, 'DESCRIPTION')}" style="display:none" onload="this.style.display='inline'" />
<a href="#{termsOfUseAndAccess.license.uri}" title="#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license,'DESCRIPTION')}" target="_blank">#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license,'NAME')}</a>
</p>
</ui:fragment>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/datasetLicenseInfoFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ xmlns:jsf="http://xmlns.jcp.org/jsf">
</div>
<ui:fragment rendered="#{!empty DatasetPage.workingVersion.termsOfUseAndAccess.license}">
<div class="form-group"
jsf:rendered="#{!empty DatasetPage.workingVersion.termsOfUseAndAccess.license.shortDescription}">
jsf:rendered="#{!empty DatasetUtil:getLocalizedLicenseDetails(DatasetPage.workingVersion.termsOfUseAndAccess.license,'DESCRIPTION')} }">
<label for="metadata_Terms" class="col-sm-3 control-label">
#{bundle['dataset.publish.terms.description']}
</label>
<div class="col-sm-9">
<h:outputText value="#{DatasetPage.workingVersion.termsOfUseAndAccess.license.shortDescription}" />
<h:outputText value="#{DatasetUtil:getLocalizedLicenseDetails(DatasetPage.workingVersion.termsOfUseAndAccess.license,'DESCRIPTION')}" />
</div>
</div>
</ui:fragment>
Expand Down Expand Up @@ -121,4 +121,4 @@ xmlns:jsf="http://xmlns.jcp.org/jsf">
</ui:fragment>
</div>
<!-- END license info -->
</ui:composition>
</ui:composition>