Skip to content

Commit 855aae8

Browse files
committed
Fixed the locale to match the list available in the UI dropdown
1 parent d5f2795 commit 855aae8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

orcid-web/src/main/java/org/orcid/frontend/email/RecordEmailSender.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.orcid.core.manager.v3.read_only.EmailManagerReadOnly;
1919
import org.orcid.core.utils.SourceEntityUtils;
2020
import org.orcid.core.utils.VerifyEmailUtils;
21+
import org.orcid.jaxb.model.common.AvailableLocales;
2122
import org.orcid.jaxb.model.v3.release.record.Email;
2223
import org.orcid.jaxb.model.v3.release.record.Emails;
2324
import org.orcid.persistence.dao.GenericDao;
@@ -424,11 +425,14 @@ private void processVerificationEmail(String userOrcid, String email, boolean is
424425

425426
private Locale getUserLocaleFromProfileEntity(ProfileEntity profile) {
426427
String locale = profile.getLocale();
427-
if (locale != null) {
428-
org.orcid.jaxb.model.common_v2.Locale loc = org.orcid.jaxb.model.common_v2.Locale.valueOf(locale);
429-
return LocaleUtils.toLocale(loc.value());
428+
try {
429+
if (locale != null) {
430+
return LocaleUtils.toLocale(AvailableLocales.valueOf(locale).value());
431+
}
432+
}
433+
catch(Exception ex) {
434+
LOGGER.error("Locale is not supported in the available locales, defaulting to en", ex);
430435
}
431-
432436
return LocaleUtils.toLocale("en");
433437
}
434438
}

0 commit comments

Comments
 (0)