*/
private String populateProperties(String prefix, Properties properties,
Locale locale)
throws RepositoryException {
ZipArchive zipArchive;
try {
zipArchive = getZipArchive();
} catch (IOException e) {
throw new RepositoryException(
EXCEPTION_LOCALIZER.format("device-repository-access-failure"));
}
// the language will be either a 2 character identifier or an empty
// string
String language = locale.getLanguage();
// the country will be either a 2 character identifier or an empty
// string
String country = locale.getCountry();
// the country will be an empty string or some other identifier
String variant = locale.getVariant();
String localeFound = null;
String propertiesFile = null;
// see if we have a properites file with the following suffix
// _LANGUAGE_COUNTRY_VARIANT.properties
if (language.length() != 0 &&
country.length() != 0 &&
variant.length() != 0) {
String checkPath =
getPropertiesPath(prefix, language, country, variant);
if (zipArchive.exists(checkPath)) {
localeFound = language + "_" + country + "_" + variant;
propertiesFile = checkPath;
}
}
// If we haven't found the properties file then we try the less
// specific suffix _LANGUAGE_COUNTRY.properites
if (propertiesFile == null &&
language.length() != 0 &&
country.length() != 0) {
String checkPath =
getPropertiesPath(prefix, language, country, null);
if (zipArchive.exists(checkPath)) {
localeFound = language + "_" + country + "_";
propertiesFile = checkPath;
}
}
// If we haven't found the properties file then we try the less
// specific suffix _LANGUAGE.properites
if (propertiesFile == null && language.length() != 0) {
String checkPath = getPropertiesPath(prefix, language, null, null);
if (zipArchive.exists(checkPath)) {
localeFound = language + "__";
propertiesFile = checkPath;
}
}
// If we haven't found the properties file then we try the
// .properties
if (propertiesFile == null) {
String checkPath = getPropertiesPath(prefix, null, null, null);
if (zipArchive.exists(checkPath)) {
localeFound = "__";
propertiesFile = checkPath;
}
}
if (propertiesFile != null) {
// if we found a properties file the load its contents into the
// properties instance
try {
properties.load(zipArchive.getInputFrom(propertiesFile));
} catch (IOException e) {
throw new RepositoryException(EXCEPTION_LOCALIZER.format(
"device-repository-file-missing", propertiesFile));
}
} else if (logger.isDebugEnabled()) {