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

5623 facets translation #5624

Closed
4 changes: 3 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetFieldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@ public int compareTo(DatasetFieldType o) {

public String getDisplayName() {
if (isHasParent() && !parentDatasetFieldType.getTitle().equals(title)) {
return parentDatasetFieldType.getLocaleTitle() + " " + getLocaleTitle();
return parentDatasetFieldType.getLocaleTitle() + ": " + getLocaleTitle();
// The ": " is a solution to French and Spanish translation. Another solution is return only the parent title:
// return parentDatasetFieldType.getLocaleTitle()
} else {
return getLocaleTitle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -682,7 +683,8 @@ public SolrQueryResponse search(DataverseRequest dataverseRequest, List<Datavers
stringBuilder.append(getCapitalizedName(part.toLowerCase()) + " ");
}
String friendlyNameWithTrailingSpace = stringBuilder.toString();
String friendlyName = friendlyNameWithTrailingSpace.replaceAll(" $", "");
String originalFrienlyName = friendlyNameWithTrailingSpace.replaceAll(" $", "");
String friendlyName= getLocaleTitle(staticSearchField, originalFrienlyName);
facetCategory.setFriendlyName(friendlyName);
// logger.info("adding <<<" + staticSearchField + ":" + friendlyName + ">>>");
staticSolrFieldFriendlyNamesBySolrField.put(staticSearchField, friendlyName);
Expand Down Expand Up @@ -930,4 +932,11 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ

}

public String getLocaleTitle(String title, String originalTitle) {
try {
return BundleUtil.getStringFromPropertyFile("datasetfieldtype." + title + ".title", "citation");
} catch (MissingResourceException e) {
return originalTitle;
}
}
}