NodeList nodes = document.getElementsByTagName("locale-config");
for (int i = 0; i < nodes.getLength(); i++)
{
Node node = nodes.item(i);
NodeList children = node.getChildNodes();
LocaleConfig config = new LocaleConfigImpl();
for (int j = 0; j < children.getLength(); j++)
{
Node element = children.item(j);
if ("locale".equals(element.getNodeName()))
{
config.setLocale(element.getFirstChild().getNodeValue());
}
else if ("output-encoding".equals(element.getNodeName()))
{
config.setOutputEncoding(element.getFirstChild().getNodeValue());
}
else if ("input-encoding".equals(element.getNodeName()))
{
config.setInputEncoding(element.getFirstChild().getNodeValue());
}
else if ("description".equals(element.getNodeName()))
{
config.setDescription(element.getFirstChild().getNodeValue());
}
else if ("orientation".equals(element.getNodeName()))
{
String s = element.getFirstChild().getNodeValue();
Orientation orientation = orientations.get(s);
if (orientation == null)
{
log.error("Wrong orientation value " + s);
}
else
{
config.setOrientation(orientation);
}
}
}
//
if (config.getOrientation() == null)
{
log.debug("No orientation found on the locale config, use the LT default");
config.setOrientation(Orientation.LT);
}
//
log.debug("Added locale config " + config + " to the set of locale configs");
//
String country = config.getLocale().getCountry();
if (country != null && country.length() > 0)
{
configs_.put(config.getLanguage() + "_" + country, config);
}
else
{
configs_.put(config.getLanguage(), config);
}
if (i == 0)
defaultConfig_ = config;
}
//
if (PropertyManager.isDevelopping())
{
LocaleConfig magicConfig = new LocaleConfigImpl();
magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
magicConfig.setDescription("Magic locale");
magicConfig.setInputEncoding("UTF-8");
magicConfig.setOutputEncoding("UTF-8");
magicConfig.setDescription("Default configuration for the debugging locale");
magicConfig.setOrientation(Orientation.LT);
configs_.put(magicConfig.getLanguage(), magicConfig);
log.debug("Added magic locale for debugging bundle usage at runtime");
}
}