mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
refactoring
This commit is contained in:
@@ -115,7 +115,7 @@ public final class CreateAdministrator {
|
|||||||
String lastName = null;
|
String lastName = null;
|
||||||
char[] password1 = null;
|
char[] password1 = null;
|
||||||
char[] password2 = null;
|
char[] password2 = null;
|
||||||
String language = I18nUtil.DEFAULTLOCALE.getLanguage();
|
String language = I18nUtil.getDefaultLocale().getLanguage();
|
||||||
|
|
||||||
while (!dataOK) {
|
while (!dataOK) {
|
||||||
System.out.print("E-mail address: ");
|
System.out.print("E-mail address: ");
|
||||||
|
@@ -179,7 +179,7 @@ public class Context implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentUser = null;
|
currentUser = null;
|
||||||
currentLocale = I18nUtil.DEFAULTLOCALE;
|
currentLocale = I18nUtil.getDefaultLocale();
|
||||||
extraLogInfo = "";
|
extraLogInfo = "";
|
||||||
ignoreAuth = false;
|
ignoreAuth = false;
|
||||||
|
|
||||||
|
@@ -37,9 +37,6 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
public class I18nUtil {
|
public class I18nUtil {
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(I18nUtil.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(I18nUtil.class);
|
||||||
|
|
||||||
// the default Locale of this DSpace Instance
|
|
||||||
public static final Locale DEFAULTLOCALE = getDefaultLocale();
|
|
||||||
|
|
||||||
// delimiters between elements of UNIX/POSIX locale spec, e.g. en_US.UTF-8
|
// delimiters between elements of UNIX/POSIX locale spec, e.g. en_US.UTF-8
|
||||||
private static final String LOCALE_DELIMITERS = " _.";
|
private static final String LOCALE_DELIMITERS = " _.";
|
||||||
|
|
||||||
@@ -127,7 +124,7 @@ public class I18nUtil {
|
|||||||
return parseLocales(locales);
|
return parseLocales(locales);
|
||||||
} else {
|
} else {
|
||||||
Locale[] availableLocales = new Locale[1];
|
Locale[] availableLocales = new Locale[1];
|
||||||
availableLocales[0] = DEFAULTLOCALE;
|
availableLocales[0] = getDefaultLocale();
|
||||||
return availableLocales;
|
return availableLocales;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +145,7 @@ public class I18nUtil {
|
|||||||
Locale supportedLocale = null;
|
Locale supportedLocale = null;
|
||||||
String testLocale = "";
|
String testLocale = "";
|
||||||
if (availableLocales == null) {
|
if (availableLocales == null) {
|
||||||
supportedLocale = DEFAULTLOCALE;
|
supportedLocale = getDefaultLocale();
|
||||||
} else {
|
} else {
|
||||||
if (!locale.getVariant().equals("")) {
|
if (!locale.getVariant().equals("")) {
|
||||||
testLocale = locale.toString();
|
testLocale = locale.toString();
|
||||||
@@ -188,7 +185,7 @@ public class I18nUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isSupported) {
|
if (!isSupported) {
|
||||||
supportedLocale = DEFAULTLOCALE;
|
supportedLocale = getDefaultLocale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return supportedLocale;
|
return supportedLocale;
|
||||||
@@ -220,7 +217,7 @@ public class I18nUtil {
|
|||||||
* String of the message
|
* String of the message
|
||||||
*/
|
*/
|
||||||
public static String getMessage(String key) {
|
public static String getMessage(String key) {
|
||||||
return getMessage(key.trim(), DEFAULTLOCALE);
|
return getMessage(key.trim(), getDefaultLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,7 +230,7 @@ public class I18nUtil {
|
|||||||
*/
|
*/
|
||||||
public static String getMessage(String key, Locale locale) {
|
public static String getMessage(String key, Locale locale) {
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
locale = DEFAULTLOCALE;
|
locale = getDefaultLocale();
|
||||||
}
|
}
|
||||||
ResourceBundle.Control control =
|
ResourceBundle.Control control =
|
||||||
ResourceBundle.Control.getNoFallbackControl(
|
ResourceBundle.Control.getNoFallbackControl(
|
||||||
|
@@ -130,7 +130,7 @@ public class ContextTest extends AbstractUnitTest {
|
|||||||
public void testGetCurrentLocale() {
|
public void testGetCurrentLocale() {
|
||||||
//NOTE: CurrentLocale is not initialized in AbstractUnitTest. So it should be DEFAULTLOCALE
|
//NOTE: CurrentLocale is not initialized in AbstractUnitTest. So it should be DEFAULTLOCALE
|
||||||
assertThat("testGetCurrentLocale 0", context.getCurrentLocale(), notNullValue());
|
assertThat("testGetCurrentLocale 0", context.getCurrentLocale(), notNullValue());
|
||||||
assertThat("testGetCurrentLocale 1", context.getCurrentLocale(), equalTo(I18nUtil.DEFAULTLOCALE));
|
assertThat("testGetCurrentLocale 1", context.getCurrentLocale(), equalTo(I18nUtil.getDefaultLocale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user