code: protected Locale getLocaleToUse(CmsObject cms, CmsXmlContent xmlContent) {
  
          Locale contextLocale = cms.getRequestContext().getLocale();
          if (xmlContent.hasLocale(contextLocale)) {
              return contextLocale;
          }
          Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
          if (xmlContent.hasLocale(defaultLocale)) {
              return defaultLocale;
          }
          if (!xmlContent.getLocales().isEmpty()) {
              return xmlContent.getLocales().get(0);
          } else {
              return defaultLocale;
          }
      }
docs: Gets the locale to use for parsing the dynamic function.<p>
  
  @param cms the current CMS context
  @param xmlContent the xml content from which the dynamic function should be read
  
  @return the locale from which the dynamic function should be read