Parse an element tree and return the module found in it.
<p>

@param dcRoot the root element containing the module elements.
@param locale for date/time parsing
@return the module parsed from the element tree, <i>null</i> if none.
779457
@Override
    public Module parse(final Element dcRoot, final Locale locale) {

        boolean foundSomething = false;
        final DCModule dcm = new DCModuleImpl();

        final List<Element> titles = dcRoot.getChildren("title", getDCNamespace());
        if (!titles.isEmpty()) {
            foundSomething = true;
            dcm.setTitles(parseElementList(titles));
        }

        final List<Element> creators = dcRoot.getChildren("creator", getDCNamespace());
        if (!creators.isEmpty()) {
            foundSomething = true;
            dcm.setCreators(parseElementList(creators));
        }

        final List<Element> subjects = dcRoot.getChildren("subject", getDCNamespace());
        if (!subjects.isEmpty()) {
            foundSomething = true;
            dcm.setSubjects(parseSubjects(subjects));
        }

        final List<Element> descriptions = dcRoot.getChildren("description", getDCNamespace());
        if (!descriptions.isEmpty()) {
            foundSomething = true;
            dcm.setDescriptions(parseElementList(descriptions));
        }

        final List<Element> publishers = dcRoot.getChildren("publisher", getDCNamespace());
        if (!publishers.isEmpty()) {
            foundSomething = true;
            dcm.setPublishers(parseElementList(publishers));
        }

        final List<Element> contributors = dcRoot.getChildren("contributor", getDCNamespace());
        if (!contributors.isEmpty()) {
            foundSomething = true;
            dcm.setContributors(parseElementList(contributors));
        }

        final List<Element> dates = dcRoot.getChildren("date", getDCNamespace());
        if (!dates.isEmpty()) {
            foundSomething = true;
            dcm.setDates(parseElementListDate(dates, locale));
        }

        final List<Element> types = dcRoot.getChildren("type", getDCNamespace());
        if (!types.isEmpty()) {
            foundSomething = true;
            dcm.setTypes(parseElementList(types));
        }

        final List<Element> formats = dcRoot.getChildren("format", getDCNamespace());
        if (!formats.isEmpty()) {
            foundSomething = true;
            dcm.setFormats(parseElementList(formats));
        }

        final List<Element> identifiers = dcRoot.getChildren("identifier", getDCNamespace());
        if (!identifiers.isEmpty()) {
            foundSomething = true;
            dcm.setIdentifiers(parseElementList(identifiers));
        }

        final List<Element> sources = dcRoot.getChildren("source", getDCNamespace());
        if (!sources.isEmpty()) {
            foundSomething = true;
            dcm.setSources(parseElementList(sources));
        }

        final List<Element> languages = dcRoot.getChildren("language", getDCNamespace());
        if (!languages.isEmpty()) {
            foundSomething = true;
            dcm.setLanguages(parseElementList(languages));
        }

        final List<Element> relations = dcRoot.getChildren("relation", getDCNamespace());
        if (!relations.isEmpty()) {
            foundSomething = true;
            dcm.setRelations(parseElementList(relations));
        }

        final List<Element> coverages = dcRoot.getChildren("coverage", getDCNamespace());
        if (!coverages.isEmpty()) {
            foundSomething = true;
            dcm.setCoverages(parseElementList(coverages));
        }

        final List<Element> rights = dcRoot.getChildren("rights", getDCNamespace());
        if (!rights.isEmpty()) {
            foundSomething = true;
            dcm.setRightsList(parseElementList(rights));
        }

        if (foundSomething) {
            return dcm;
        } else {
            return null;
        }

    }
300033
@Override
    public String getContextRoot() {
        if (delegate == null) {
            return this.contextRoot;
        } else {
            return this.contextRoot == null ? delegate.getContextRoot() : this.contextRoot;
        }
    }
716221
@SuppressWarnings("unchecked")
  public <T> T getField(String key, String locale) {
    if (fields == null) {
      return null;
    }

    LinkedHashMap<String, Object> field = fields.get(key);
    if (field == null) {
      return null;
    } else {
      return (T) field.get(locale);
    }
  }
987816
public XMLNode parseXML(String root) {
        if (xmlElementsMap.containsKey(root)) {
            return xmlElementsMap.get(root);
        }
        try {
            currentRoot = root;
            isParsing = false;
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
            InputStream in = configuration.getBuilderXML();
            saxParser.parse(in, this);
            return xmlElementsMap.get(root);
        } catch (Throwable t) {
            t.printStackTrace();
            throw new DocletAbortException(t);
        }
    }
504528
function findLocaleData(locale) {
    var normalizedLocale = locale.toLowerCase().replace(/_/g, '-');
    var match = LOCALE_DATA[normalizedLocale];
    if (match) {
        return match;
    }
    // let's try to find a parent locale
    var parentLocale = normalizedLocale.split('-')[0];
    match = LOCALE_DATA[parentLocale];
    if (match) {
        return match;
    }
    if (parentLocale === 'en') {
        return localeEn;
    }
    throw new Error("Missing locale data for the locale \"" + locale + "\".");
}
401075
@Override
	public Locale getFallbackLocale(String baseName, Locale locale) {
		if (baseName == null) {
			throw new NullPointerException();
		}
		Locale defaultLocale = Locale.getDefault();

		if (!fallbackToSystemLocale) {
			defaultLocale = new Locale("", "");
		}

		return locale.equals(defaultLocale) ? null : defaultLocale;
	}
816473
public static Locale getLocale() {
		String tag = Configuration.get("locale");
		if (tag == null) {
			return Locale.ROOT;
		} else {
			String[] splittedTag = tag.split("_", MAX_LOCALE_ARGUMENTS);
			if (splittedTag.length == 1) {
				return new Locale(splittedTag[0]);
			} else if (splittedTag.length == 2) {
				return new Locale(splittedTag[0], splittedTag[1]);
			} else {
				return new Locale(splittedTag[0], splittedTag[1], splittedTag[2]);
			}
		}
	}
182272
public function getLocaleChain(Locale $locale)
    {
        $fallbackRule = $this->configuration->getFallbackRule();
        $localeChain = [(string)$locale => $locale];

        if ($fallbackRule['strict'] === true) {
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
            }
        } else {
            $locale = $this->findBestMatchingLocale($locale);
            while ($locale !== null) {
                $localeChain[(string)$locale] = $locale;
                $locale = $this->getParentLocaleOf($locale);
            }
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $locale = new Locale($localeIdentifier);
                $locale = $this->findBestMatchingLocale($locale);
                while ($locale !== null) {
                    $localeChain[(string)$locale] = $locale;
                    $locale = $this->getParentLocaleOf($locale);
                }
            }
        }
        $locale = $this->configuration->getDefaultLocale();
        $localeChain[(string)$locale] = $locale;

        return $localeChain;
    }
287907
public String importMessage(String key, Locale locale) {

        key = key.trim();
        String[] tokens = key.split("#");
        if (tokens.length != 2) {
            return null;
        }
        String className = tokens[0];
        String messageName = tokens[1];
        try {
            Method messagesGet = Class.forName(className).getMethod("get");
            I_CmsMessageBundle bundle = (I_CmsMessageBundle)(messagesGet.invoke(null));
            return bundle.getBundle(locale).key(messageName);
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return null;
        }
    }
699340
public static Locale toLocale(String strLocale, Locale defaultValue) {
	return LocaleFactory.getLocale(strLocale, defaultValue);
    }
1143809
public Node getRoot(Node node)
  {

    Node root = null;

    while (node != null)
    {
      root = node;
      node = getParentOfNode(node);
    }

    return root;
  }
458130
public List<I_CmsXmlContentValue> getValuesByPath(String elementPath, Locale locale) {

        String[] pathElements = elementPath.split("/");
        List<I_CmsXmlContentValue> values = getValues(pathElements[0], locale);
        for (int i = 1; i < pathElements.length; i++) {
            List<I_CmsXmlContentValue> subValues = new ArrayList<I_CmsXmlContentValue>();
            for (I_CmsXmlContentValue value : values) {
                subValues.addAll(getValues(CmsXmlUtils.concatXpath(value.getPath(), pathElements[i]), locale));
            }
            if (subValues.isEmpty()) {
                values = Collections.emptyList();
                break;
            }
            values = subValues;
        }
        return values;
    }
1143713
protected function parse($locale, $returnType = null)
    {
        if (extension_loaded('intl')) {
            $info = \Locale::parseLocale($locale);
        } else {
            $info = array();

            if (!preg_match('~^(?<language>[a-z]{2,4})([_-](?<region>[a-z]{2,4}))?$~i', $locale, $info)) {
                return null;
            }

            if (isset($info['region'])) {
                $info['region'] = strtoupper($info['region']);
            }
        }

        if ($returnType !== null) {
            $value = ($info && isset($info[$returnType]))? $info[$returnType] : null;
            return $value;
        }

        return $info;
    }
1189292
private void loadLocalizationFromXmlBundle(Locale locale) {

        CmsXmlContentValueSequence messages = m_xmlBundle.getValueSequence("Message", locale);
        SortedProperties props = new SortedProperties();
        if (null != messages) {
            for (I_CmsXmlContentValue msg : messages.getValues()) {
                String msgpath = msg.getPath();
                props.put(
                    m_xmlBundle.getStringValue(m_cms, msgpath + "/Key", locale),
                    m_xmlBundle.getStringValue(m_cms, msgpath + "/Value", locale));
            }
        }
        m_localizations.put(locale, props);
    }
542806
public CalendarFormatter getCalendarFormatter(CLDR.Locale locale) {
    locale = bundleMatch(locale);
    CalendarFormatter formatter = CALENDAR_FORMATTERS.get(locale);
    return formatter == null ? CALENDAR_FORMATTERS.get(CLDR.Locale.en_US) : formatter;
  }
542822
public static Document createDocument(Locale locale) {

        Document doc = DocumentHelper.createDocument();
        Element pages = doc.addElement(CmsXmlPage.NODE_PAGES);
        pages.add(I_CmsXmlSchemaType.XSI_NAMESPACE);
        pages.addAttribute(
            I_CmsXmlSchemaType.XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION,
            CmsXmlPage.XMLPAGE_XSD_SYSTEM_ID);

        Element page = pages.addElement(CmsXmlPage.NODE_PAGE);
        page.addAttribute(CmsXmlPage.ATTRIBUTE_LANGUAGE, locale.toString());

        return doc;
    }
901958
private static FairyModule getFairyModuleForLocale(DataMaster dataMaster, Locale locale, RandomGenerator randomGenerator) {

		LanguageCode code;
		try {
			code = LanguageCode.valueOf(locale.getLanguage().toUpperCase());
		} catch (IllegalArgumentException e) {
			LOG.warn("Uknown locale " + locale);
			code = LanguageCode.EN;
		}

		switch (code) {
			case PL:
				return new PlFairyModule(dataMaster, randomGenerator);
			case EN:
				return new EnFairyModule(dataMaster, randomGenerator);
			case ES:
				return new EsFairyModule(dataMaster, randomGenerator);
			case FR:
				return new EsFairyModule(dataMaster, randomGenerator);
			case SV:
				return new SvFairyModule(dataMaster, randomGenerator);
			case ZH:
				return new ZhFairyModule(dataMaster, randomGenerator);
			case DE:
				return new DeFairyModule(dataMaster, randomGenerator);
			case KA:
				return new KaFairyModule(dataMaster, randomGenerator);
			default:
				LOG.info("No data for your language - using EN");
				return new EnFairyModule(dataMaster, randomGenerator);
		}
	}