From 39913ff7d0376484f6cd3ebcfe787528f7749706 Mon Sep 17 00:00:00 2001 From: chenganj Date: Mon, 7 Mar 2022 15:18:41 -0500 Subject: [PATCH 1/6] Internationalization of curation labels --- .../java/edu/harvard/iq/dataverse/DatasetPage.java | 13 ++++++++++++- .../edu/harvard/iq/dataverse/DatasetVersion.java | 9 +++++++++ .../edu/harvard/iq/dataverse/DataversePage.java | 9 ++++++++- src/main/webapp/dataset.xhtml | 4 ++-- src/main/webapp/search-include-fragment.xhtml | 2 +- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 61720efafb2..061b9de88af 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -5640,7 +5640,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(getLocaleExternalStatus(status)) + )); } } catch (CommandException ex) { @@ -5649,6 +5652,14 @@ public void setExternalStatus(String status) { JsfHelper.addErrorMessage(msg); } } + + public String getLocaleExternalStatus(String status) { + String localizedName = BundleUtil.getStringFromBundle(status.toLowerCase().replace(" ", "_")); + if (localizedName == null) { + localizedName = status ; + } + return localizedName; + } public List getAllowedExternalStatuses() { return settingsWrapper.getAllowedExternalStatuses(dataset); diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java index b766e5d7b58..da9c04ef6c1 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java @@ -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; @@ -1953,6 +1954,14 @@ public String getExternalStatusLabel() { return externalStatusLabel; } + public String getLocaleExternalStatusLabel() { + String localizedName = BundleUtil.getStringFromBundle(externalStatusLabel.toLowerCase().replace(" ", "_")); + if (localizedName == null) { + localizedName = externalStatusLabel ; + } + return localizedName; + } + public void setExternalStatusLabel(String externalStatusLabel) { this.externalStatusLabel = externalStatusLabel; } diff --git a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java index 664658818e3..2525adf231e 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java @@ -1249,8 +1249,15 @@ public Set> getCurationLabelSetOptions() { } // Add an entry for disabled setNames.put(BundleUtil.getStringFromBundle("dataverse.curationLabels.disabled"), SystemConfig.CURATIONLABELSDISABLED); + allowedSetNames.forEach(name -> { - setNames.put(name, name); + String localizedName = BundleUtil.getStringFromBundle( name.toLowerCase().replace(" ","_")) ; + if (localizedName != null) { + setNames.put(localizedName,name); + } + else { + setNames.put(name, name); + } }); } curationLabelSetOptions = setNames.entrySet(); diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index e42b61ef88f..06dac5a42df 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -125,7 +125,7 @@ - + @@ -341,7 +341,7 @@
  • - #{status} + #{DatasetPage.getLocaleExternalStatus(status)}
  • diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index 2d03349acf1..3b1526cba0c 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -548,7 +548,7 @@ - +
    From 546f93e8b95f2d55a30b3395bc1a17305021d34d Mon Sep 17 00:00:00 2001 From: chenganj Date: Mon, 7 Mar 2022 15:59:19 -0500 Subject: [PATCH 2/6] Curation label doc --- doc/sphinx-guides/source/installation/config.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index 36fb7d018ac..d549227847f 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -2517,6 +2517,12 @@ 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 Bundle property files. + +Example: +standard_process=Standard Process +author_contacted=Author contacted + .. _:AllowCustomTermsOfUse: :AllowCustomTermsOfUse From 4e14e61c345111a63ca8bd3fa1f9db36bf4a92e3 Mon Sep 17 00:00:00 2001 From: chenganj Date: Wed, 9 Mar 2022 11:27:24 -0500 Subject: [PATCH 3/6] moved function to DatasetUtil.java --- doc/sphinx-guides/source/installation/config.rst | 1 + .../java/edu/harvard/iq/dataverse/DatasetPage.java | 10 +--------- .../java/edu/harvard/iq/dataverse/DatasetVersion.java | 8 -------- .../java/edu/harvard/iq/dataverse/DataversePage.java | 10 +++------- .../edu/harvard/iq/dataverse/dataset/DatasetUtil.java | 8 ++++++++ src/main/webapp/dataset.xhtml | 6 ++++-- src/main/webapp/search-include-fragment.xhtml | 3 ++- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index d549227847f..0a49d7a5980 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -2518,6 +2518,7 @@ 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 Bundle property files. +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 diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index c8fb77d1776..2499642e5b4 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -5649,7 +5649,7 @@ public void setExternalStatus(String status) { } else { JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), BundleUtil.getStringFromBundle("dataset.externalstatus.info", - Arrays.asList(getLocaleExternalStatus(status)) + Arrays.asList(DatasetUtil.getLocaleExternalStatus(status)) )); } @@ -5660,14 +5660,6 @@ public void setExternalStatus(String status) { } } - public String getLocaleExternalStatus(String status) { - String localizedName = BundleUtil.getStringFromBundle(status.toLowerCase().replace(" ", "_")); - if (localizedName == null) { - localizedName = status ; - } - return localizedName; - } - public List getAllowedExternalStatuses() { return settingsWrapper.getAllowedExternalStatuses(dataset); } diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java index da9c04ef6c1..f211ccd0410 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java @@ -1954,14 +1954,6 @@ public String getExternalStatusLabel() { return externalStatusLabel; } - public String getLocaleExternalStatusLabel() { - String localizedName = BundleUtil.getStringFromBundle(externalStatusLabel.toLowerCase().replace(" ", "_")); - if (localizedName == null) { - localizedName = externalStatusLabel ; - } - return localizedName; - } - public void setExternalStatusLabel(String externalStatusLabel) { this.externalStatusLabel = externalStatusLabel; } diff --git a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java index 2525adf231e..b48ff725e1e 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java @@ -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; @@ -1251,13 +1252,8 @@ public Set> getCurationLabelSetOptions() { setNames.put(BundleUtil.getStringFromBundle("dataverse.curationLabels.disabled"), SystemConfig.CURATIONLABELSDISABLED); allowedSetNames.forEach(name -> { - String localizedName = BundleUtil.getStringFromBundle( name.toLowerCase().replace(" ","_")) ; - if (localizedName != null) { - setNames.put(localizedName,name); - } - else { - setNames.put(name, name); - } + String localizedName = DatasetUtil.getLocaleExternalStatus(name) ; + setNames.put(localizedName,name); }); } curationLabelSetOptions = setNames.entrySet(); diff --git a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java index a33caa9f890..a4617c24b86 100644 --- a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java @@ -568,4 +568,12 @@ 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 = BundleUtil.getStringFromBundle(status.toLowerCase().replace(" ", "_")); + if (localizedName == null) { + localizedName = status ; + } + return localizedName; + } } diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 6a0b1033958..3a56b254c41 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -125,7 +125,8 @@ - + + @@ -340,8 +341,9 @@