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

I18n redesign #355

Merged
merged 45 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c79f381
fixed new individual form
litvinovg Oct 6, 2022
7857968
remove terms of use controller
litvinovg Oct 12, 2022
874409d
Use language-neutral selectAnExistingOrCreateNewOne translation key
litvinovg Oct 19, 2022
f1a730d
Merge pull request #332 from litvinovg/ftl_fixes
chenejac Oct 27, 2022
1511e00
Merge pull request #338 from litvinovg/autocomplete_form
chenejac Oct 27, 2022
7bb3fb9
Merge pull request #335 from litvinovg/terms_of_use
chenejac Oct 27, 2022
403cd65
[ i18n sprint ] Decouple email templates and translations (#334)
litvinovg Nov 8, 2022
a6a4809
[ i18n sprint ] Move search help page translations to properties (#333)
chenejac Nov 8, 2022
0b99cab
[ i18n sprint ] autoCompleteObjectPropForm and lib-properties fixes f…
litvinovg Nov 15, 2022
57d9328
fix: removed 'other' hack from forms (#328)
litvinovg Nov 15, 2022
4acb10f
remove only langtag literals (#349)
litvinovg Nov 23, 2022
8ddbc8f
merging language specific home artifacts from Vitro-languages into th…
chenejac Nov 24, 2022
9e3a3f7
[i18b sprint] 3760 translations loading (#341)
litvinovg Nov 25, 2022
5a48b7d
moving UI labels translations from Vitro-languages into the Vitro rep…
chenejac Nov 23, 2022
1b3df68
adding one ttl file
chenejac Nov 23, 2022
242f851
adding the UI labels ontology
chenejac Nov 24, 2022
d27560b
correction of a typo
chenejac Nov 24, 2022
b8ddb05
property files not mandatory anymore, message kept as info instead of…
chenejac Nov 24, 2022
7340b7f
fix in the startup_listeners.txt
chenejac Nov 28, 2022
4863f4c
Cleaning up dependency on languages repository
chenejac Nov 28, 2022
61feb77
fix of build git action
chenejac Nov 28, 2022
1608079
fixing an issue with '\n' in the label translations
chenejac Nov 29, 2022
1cab6cf
changing of format of the vocabulary (from n3 to ttl)
Nov 29, 2022
bc35958
correction - changing of format of the vocabulary (from n3 to ttl)
Nov 29, 2022
026d316
adding new line at the end of UILabelsVocabulary.ttl
Nov 29, 2022
a1d1f7f
adding new line at the end of UILabelsVocabulary.ttl
Nov 29, 2022
8bbc751
Merge pull request #350 from chenejac/movingUILabelsTranslationsIntoV…
litvinovg Dec 6, 2022
3f03ddf
adding English as default language
chenejac Dec 6, 2022
3b08832
renaming files, removing language suffixes for rdf files
chenejac Dec 9, 2022
63567b9
Merge pull request #353 from chenejac/defaultLanguage
litvinovg Dec 12, 2022
62cbcca
support for private subtag (x)
chenejac Nov 29, 2022
6312b96
adding support for private subtags in the language tags, replacement …
chenejac Dec 8, 2022
ae25098
adding curly braces for all if statements
chenejac Dec 13, 2022
f548908
Merge pull request #351 from chenejac/supportingPrivateTags
litvinovg Dec 13, 2022
c885162
Merge pull request #354 from chenejac/renamingi18nFiles
litvinovg Dec 13, 2022
311744e
support for combining parameters and apostrophe
chenejac Dec 16, 2022
fce6dc6
reorganization of the code - extraction of a method for preprocessing…
chenejac Dec 16, 2022
a0a1a66
Faux data properties and fixes for current faux properties view (#352)
litvinovg Dec 16, 2022
7d84e61
Merge pull request #356 from chenejac/3393_parametersWithApostrophie
litvinovg Dec 22, 2022
a7215cc
fix for faux data property ranges (#357)
litvinovg Jan 24, 2023
7dabc6b
fixed check for redundant possible object properties (#358)
litvinovg Jan 24, 2023
2873bba
fixed faux property display order (#359)
litvinovg Jan 24, 2023
8b2e150
use qualified by root in faux property to provide into FauxObjectProp…
litvinovg Feb 2, 2023
1976185
Fix for Russian translation of email temlate (#362)
litvinovg Feb 6, 2023
4ce6dc2
fix creation of faux property with xml literal range value (#363)
litvinovg Feb 9, 2023
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
10 changes: 1 addition & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ jobs:
with:
path: Vitro

- name: Checkout vitro languages
uses: actions/checkout@v3
with:
repository: vivo-project/Vitro-languages
path: Vitro-languages

- name: Maven Cache
uses: actions/cache@v2
with:
Expand All @@ -34,7 +28,5 @@ jobs:

- name: Maven Build
run: |
cd ./Vitro-languages
mvn clean install
cd ../Vitro
cd ./Vitro
mvn clean install
34 changes: 32 additions & 2 deletions api/src/main/java/edu/cornell/mannlib/vedit/util/FormUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -17,6 +15,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -272,6 +271,37 @@ public static List<Option> makeOptionListOfSubVClasses(
return options;
}

public static List<Option> makeOptionListOfNotDisjointClasses(WebappDaoFactory wadf, String baseVclassUri, String selectedUri) {
VClassDao vClassDao = wadf.getVClassDao();
Set<String> uris = getNotDisjointClassUris(wadf, baseVclassUri, vClassDao);
uris.add(baseVclassUri);

List<Option> options = new LinkedList<>();
for (String vclassUri : uris) {
VClass vclass = vClassDao.getVClassByURI(vclassUri);
Option option = new Option();
option.setValue(vclass.getURI());
option.setBody(vclass.getPickListName());
options.add(option);
if (Objects.equals(selectedUri, vclass.getURI())) {
option.setSelected(true);
}
}
options.sort((o1, o2) -> o1.getBody().compareTo(o2.getBody()));
return options;
}

private static Set<String> getNotDisjointClassUris(WebappDaoFactory wadf, String classUri, VClassDao vClassDao) {
Set<String> allClasses = wadf.getVClassDao()
.getAllVclasses()
.stream()
.map(vclass -> vclass.getURI())
.collect(Collectors.toSet());
Set<String> disjointClasses = new HashSet<>(vClassDao.getDisjointWithClassURIs(classUri));
allClasses.removeAll(disjointClasses);
return allClasses;
}

public static void beanSet(Object newObj, String field, String value) {
beanSet (newObj, field, value, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public void setDomainClassURI(String domainClassURI) {
public String getRangeDatatypeURI() {
return rangeDatatypeURI;
}

@Override
public String getRangeVClassURI() {
return rangeDatatypeURI;
}

public void setRangeDatatypeURI(String rangeDatatypeURI) {
this.rangeDatatypeURI = rangeDatatypeURI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.RoleRestrictedProperty;

/**
Expand All @@ -20,7 +22,9 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
private String configUri;

// Must not be null on insert or update. Partial identifier on delete.
private String rangeURI;
private String rangeURI = "";

private String rootRangeURI;
// May be null. Partial identifier on delete.
private String domainURI;

Expand Down Expand Up @@ -55,7 +59,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
*/
public FauxProperty(String domainURI, String baseURI, String rangeURI) {
super(Objects.requireNonNull(baseURI, "baseURI may not be null"));
this.rangeURI = rangeURI;
this.setRangeURI(rangeURI);
this.domainURI = domainURI;
}

Expand Down Expand Up @@ -93,7 +97,11 @@ public String getRangeURI() {
}

public void setRangeURI(String rangeURI) {
this.rangeURI = rangeURI;
if (StringUtils.isEmpty(rangeURI)) {
this.rangeURI = "";
} else {
this.rangeURI = rangeURI;
}
}

public String getBaseLabel() {
Expand All @@ -105,7 +113,14 @@ public void setBaseLabel(String baseLabel) {
}

public String getRangeLabel() {
return (rangeLabel == null) ? localName(rangeURI) : rangeLabel;
if (StringUtils.isEmpty(rangeLabel)) {
if (StringUtils.isEmpty(rangeURI)) {
return "untyped";
}
return localName(rangeURI);
} else {
return rangeLabel;
}
}

public void setRangeLabel(String rangeLabel) {
Expand Down Expand Up @@ -247,4 +262,12 @@ public String getDomainVClassURI() {
public String getRangeVClassURI() {
return getRangeURI();
}

public void setRootRangeUri(String rootRangeUri) {
this.rootRangeURI = rootRangeUri;
}

public String getRootRangeUri() {
return rootRangeURI;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.beans.XMLEncoder;
import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void checkLanguages(ServletContext ctx, ConfigurationProperties props, S
String vivoBundle = VIVO_BUNDLE_PREFIX + language + ".properties";
String vitroBundle = VITRO_BUNDLE_PREFIX + language + ".properties";
if (!i18nNames.contains(vivoBundle) && !i18nNames.contains(vitroBundle)) {
ss.warning(this, language + " was found in the value for "
ss.info(this, language + " was found in the value for "
+ PROPERTY_LANGUAGE_SELECTABLE + " but no corresponding "
+ "language file was found.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class RevisionInfoBean {
new Date(0), Collections.singleton(LevelRevisionInfo.DUMMY_LEVEL));

/** The bean is attached to the session by this name. */
static final String ATTRIBUTE_NAME = RevisionInfoBean.class.getName();
public static final String ATTRIBUTE_NAME = RevisionInfoBean.class.getName();

// ----------------------------------------------------------------------
// static methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class Controllers {

public static final String ABOUT = "/about";
public static final String CONTACT_URL = "/comments";
public static final String TERMS_OF_USE_URL = "/termsOfUse";
public static final String SEARCH_URL = "/search";
public static final String ENTITY = "/entity";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public UserAccountsAddPageStrategy(VitroRequest vreq,

private static class EmailStrategy extends UserAccountsAddPageStrategy {
public static final String CREATE_PASSWORD_URL = "/accounts/createPassword";
private static final String EMAIL_TEMPLATE_WITH_PASSWORD = "userAccounts-acctCreatedEmail.ftl";
private static final String EMAIL_TEMPLATE_NO_PASSWORD = "userAccounts-acctCreatedExternalOnlyEmail.ftl";

private boolean sentEmail;

Expand Down Expand Up @@ -100,15 +98,19 @@ protected void notifyUser() {
body.put("userAccount", page.getAddedAccount());
body.put("passwordLink", buildCreatePasswordLink());
body.put("siteName", getSiteName());

FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
email.addRecipient(TO, page.getAddedAccount().getEmailAddress());
email.setSubject(i18n.text("account_created_subject", getSiteName()));
String subject = i18n.text("account_created_subject", getSiteName());
email.setSubject(subject);
if (page.isExternalAuthOnly()) {
email.setTemplate(EMAIL_TEMPLATE_NO_PASSWORD);
body.put("subject", subject);
body.put("textMessage", i18n.text("acct_created_external_only_email_plain_text"));
body.put("htmlMessage", i18n.text("acct_created_external_only_email_html_text"));
} else {
email.setTemplate(EMAIL_TEMPLATE_WITH_PASSWORD);
body.put("subject", subject);
body.put("textMessage", i18n.text("acct_created_email_plain_text"));
body.put("htmlMessage", i18n.text("acct_created_email_html_text"));
}
email.setBodyMap(body);
email.processTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public UserAccountsEditPageStrategy(VitroRequest vreq,

private static class EmailStrategy extends UserAccountsEditPageStrategy {
private static final String PARAMETER_RESET_PASSWORD = "resetPassword";
private static final String EMAIL_TEMPLATE = "userAccounts-passwordResetPendingEmail.ftl";

public static final String RESET_PASSWORD_URL = "/accounts/resetPassword";

private boolean resetPassword;
Expand Down Expand Up @@ -107,11 +105,13 @@ protected void notifyUser() {
body.put("userAccount", page.getUpdatedAccount());
body.put("passwordLink", buildResetPasswordLink());
body.put("siteName", getSiteName());
body.put("subject", i18n.text("password_reset_pending_email_subject"));
body.put("textMessage",i18n.text("password_reset_pending_email_plain_text"));
body.put("htmlMessage", i18n.text("password_reset_pending_email_html_text"));

FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
email.addRecipient(TO, page.getUpdatedAccount().getEmailAddress());
email.setTemplate(EMAIL_TEMPLATE);
email.setBodyMap(body);
email.processTemplate();
email.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class UserAccountsCreatePasswordPage extends
.getLog(UserAccountsCreatePasswordPage.class);

private static final String TEMPLATE_NAME = "userAccounts-createPassword.ftl";
private static final String EMAIL_TEMPLATE = "userAccounts-passwordCreatedEmail.ftl";

public UserAccountsCreatePasswordPage(VitroRequest vreq) {
super(vreq);
}
Expand Down Expand Up @@ -73,8 +71,11 @@ private void notifyUser() {
FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
email.addRecipient(TO, userAccount.getEmailAddress());
email.setSubject(i18n.text("password_created_subject", getSiteName()));
email.setTemplate(EMAIL_TEMPLATE);
final String subject = i18n.text("password_created_subject", getSiteName());
email.setSubject(subject);
body.put("subject", subject);
body.put("textMessage", i18n.text("password_created_email_plain_text"));
body.put("htmlMessage", i18n.text("password_created_email_html_text"));
email.setBodyMap(body);
email.processTemplate();
email.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public UserAccountsFirstTimeExternalPageStrategy(VitroRequest vreq,
public static class EmailStrategy extends
UserAccountsFirstTimeExternalPageStrategy {

private static final String EMAIL_TEMPLATE = "userAccounts-firstTimeExternalEmail.ftl";

public EmailStrategy(VitroRequest vreq,
UserAccountsFirstTimeExternalPage page) {
super(vreq, page);
Expand All @@ -73,8 +71,11 @@ public void notifyUser(UserAccount ua) {
FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
email.addRecipient(TO, ua.getEmailAddress());
email.setSubject(i18n.text("account_created_subject", getSiteName()));
email.setTemplate(EMAIL_TEMPLATE);
final String subject = i18n.text("account_created_subject", getSiteName());
email.setSubject(subject);
body.put("subject", subject);
body.put("textMessage", i18n.text("first_time_external_email_plain_text"));
body.put("htmlMessage", i18n.text("first_time_external_email_html_text"));
email.setBodyMap(body);
email.processTemplate();
email.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ private static class InternalAuthStrategy extends
private static final String ERROR_WRONG_PASSWORD_LENGTH = "errorPasswordIsWrongLength";
private static final String ERROR_PASSWORDS_DONT_MATCH = "errorPasswordsDontMatch";

private static final String EMAIL_TEMPLATE = "userAccounts-confirmEmailChangedEmail.ftl";

private final String originalEmail;

private String newPassword;
Expand Down Expand Up @@ -179,8 +177,11 @@ public void notifyUser() {
FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
email.addRecipient(TO, page.getUserAccount().getEmailAddress());
email.setSubject(i18n.text("email_changed_subject", getSiteName()));
email.setTemplate(EMAIL_TEMPLATE);
final String subject = i18n.text("email_changed_subject", getSiteName());
email.setSubject(subject);
body.put("subject", subject);
body.put("textMessage", i18n.text("confirm_email_changed_email_plain_text"));
body.put("htmlMessage", i18n.text("confirm_email_changed_email_html_text"));
email.setBodyMap(body);
email.processTemplate();
email.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class UserAccountsResetPasswordPage extends UserAccountsPasswordBasePage

private static final String TEMPLATE_NAME = "userAccounts-resetPassword.ftl";

private static final String EMAIL_TEMPLATE = "userAccounts-passwordResetCompleteEmail.ftl";

protected UserAccountsResetPasswordPage(VitroRequest vreq) {
super(vreq);
}
Expand Down Expand Up @@ -68,14 +66,16 @@ protected String templateName() {

private void notifyUser() {
Map<String, Object> body = new HashMap<String, Object>();
FreemarkerEmailMessage email = FreemarkerEmailFactory.createNewMessage(vreq);
final String subject = i18n.text("password_changed_subject");
email.setSubject(subject);

body.put("userAccount", userAccount);
body.put("siteName", getSiteName());

FreemarkerEmailMessage email = FreemarkerEmailFactory
.createNewMessage(vreq);
body.put("subject", subject);
body.put("textMessage", i18n.text("password_reset_complete_email_plain_text"));
body.put("htmlMessage", i18n.text("password_reset_complete_email_html_text"));
email.addRecipient(TO, userAccount.getEmailAddress());
email.setSubject(i18n.text("password_changed_subject"));
email.setTemplate(EMAIL_TEMPLATE);
email.setBodyMap(body);
email.processTemplate();
email.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
Expand Down Expand Up @@ -176,6 +177,11 @@ public void doPost (HttpServletRequest request, HttpServletResponse response) {
assertionsDpDao.getEquivalentPropertyURIs(dp.getURI()), assertionsDpDao);
sortForPickList(eqProps, vreq);
request.setAttribute("equivalentProperties", eqProps);

List<FauxProperty> fauxProps = vreq.getUnfilteredAssertionsWebappDaoFactory().getFauxPropertyDao().
getFauxPropertiesForBaseUri(dp.getURI());
sortForPickList(fauxProps, vreq);
request.setAttribute("fauxproperties", fauxProps);

ApplicationBean appBean = vreq.getAppBean();

Expand Down
Loading