Get template.

@param name   - template name
@param locale - template locale
@return template instance
@throws IOException    - If an I/O error occurs
@throws ParseException - If the template cannot be parsed
@see #getEngine()
348704
public Template getTemplate(String name, Locale locale, Object args) throws IOException, ParseException {
        if (args instanceof String)
            return getTemplate(name, locale, (String) args);
        return getTemplate(name, locale, null, args);
    }
1076412
protected function getTemplateDataForLocale($template,$locale) {
		// path to document with subjects
		$metafile = $this->templatespath.'/'.$locale.'/subjects.xml';
		
		if (!file_exists($metafile)) {
			// file with subjects not found
			return null;
		}
		
		// load and parse document with subjects
		$xml = @file_get_contents($metafile);
		
		if (!$xml || $xml == '') {
			return null;
		}
		
		$array = \LSS\XML2Array::createArray($xml);
		
		// our template is not found in this document so it is not there
		if (!isset($array['templates'][$template])) {
			return null;
		}
		
		$templatefile = $this->templatespath.'/'.$locale.'/'.$template.'.htm';
		
		// check if template file exists for this locale
		if (!file_exists($templatefile)) {
			return null;
		}
		
		$tmpl = ($locale != '') ? $locale.'/':'';
		
		$tmpl .= $template;
		
		// all was fine. return found template
		return array('subject'=>$array['templates'][$template]['subject'],
			'file'=>$tmpl);
	}
662475
private Resource loadResource(String name, Locale locale, String encoding) throws IOException {
        Resource resource;
        if (stringLoader.exists(name, locale)) {
            resource = stringLoader.load(name, locale, encoding);
        } else {
            resource = loader.load(name, locale, encoding);
        }
        if (resource == null) {
            throw new FileNotFoundException("Not found resource " + name);
        }
        return resource;
    }
1132182
@SuppressWarnings({"unchecked"})
    public static <T extends LocalizableResource> T get(Class<T> cls, String locale) {
        Map<String, LocalizableResource> localeCache = getLocaleCache(cls);
        T m = (T) localeCache.get(locale);
        if (m != null) {
            return m;
        }
        synchronized (cache) {
            m = (T) localeCache.get(locale);
            if (m != null) {
                return m;
            }
            m = provider.create(cls, locale);
            put(cls, locale, m);
            return m;
        }
    }
323944
def get_template(self, template_name, **parameters):
        """"""
        template_path = pathlib.Path(self.template_dir).joinpath(template_name)
        return get_template(template_path, **parameters)
722157
public static ListFormatter getInstance(Locale locale) {
        return getInstance(ULocale.forLocale(locale), Style.STANDARD);
    }
518536
public JsonResponse getTemplate(String template) throws IOException {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(Template.PARAM_TEMPLATE, template);
        return apiGet(ApiAction.template, data);
    }
518342
def get_email_template(name, language=''):
    
    use_cache = getattr(settings, 'POST_OFFICE_CACHE', True)
    if use_cache:
        use_cache = getattr(settings, 'POST_OFFICE_TEMPLATE_CACHE', True)
    if not use_cache:
        return EmailTemplate.objects.get(name=name, language=language)
    else:
        composite_name = '%s:%s' % (name, language)
        email_template = cache.get(composite_name)
        if email_template is not None:
            return email_template
        else:
            email_template = EmailTemplate.objects.get(name=name,
                                                       language=language)
            cache.set(composite_name, email_template)
            return email_template
254497
public Model findOrCreateTemplate(String name, InputStream modelJson) throws IOException {
        try {
            Model m = getTemplateByName(name);
            return m;
        } catch (IllegalArgumentException ignore) {
        }

        String modelStr = IOUtils.toString(modelJson, "UTF-8");
        return modelService.createModel(new TypedString(modelStr));
    }
1098982
public static ResourceBundle getCurrentResourceBundle(String locale) {
		try {
			if (null != locale && !locale.isEmpty()) {
				return getCurrentResourceBundle(LocaleUtils.toLocale(locale));
			}
		} catch (IllegalArgumentException ex) {
			// do nothing
		}
		return getCurrentResourceBundle((Locale) null);
	}
991624
public static final LocaleData getInstance(ULocale locale) {
        LocaleData ld = new LocaleData();
        ld.bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, locale);
        ld.langBundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_LANG_BASE_NAME, locale);
        ld.noSubstitute = false;
        return ld;
    }
191760
public static String getEncodingFromLocale(Locale locale) {
    	init();
        if (locale == cachedLocale) {
            return cachedEncoding;
        }

        String encoding = null;
        /*(String) _localeMap.get(locale.toString());

        if (encoding == null) {
            encoding = (String) _localeMap.get(locale.getLanguage() + "_" + locale.getCountry());

            if (encoding == null) {
                encoding = (String) _localeMap.get(locale.getLanguage());
            }            
        }*/
        if (encoding == null) {
            //check the com.ibm.wsspi.http.EncodingUtils
            com.ibm.wsspi.http.EncodingUtils encodingUtils = com.ibm.ws.webcontainer.osgi.WebContainer.getEncodingUtils();
            if (encodingUtils!=null) {
                encoding = encodingUtils.getEncodingFromLocale(locale);
            }
        }

        cachedEncoding = encoding;
        cachedLocale = locale;

        return encoding;
    }
758188
private Locale getLocale(String localeName) throws ToolException {
        Locale userlocale = null;
        if (localeName == null || localeName.isEmpty()) {
            return Locale.getDefault();
        }
        int firstuscore = localeName.indexOf('_');
        int seconduscore = -1;
        String language = null;
        String country = null;
        String variant = null;
        if (firstuscore == 2) {
            language = localeName.substring(0, firstuscore);
            seconduscore = localeName.indexOf('_', firstuscore + 1);
            if (seconduscore > 0) {
                if (seconduscore != firstuscore + 3
                        || localeName.length() <= seconduscore + 1) {
                    String text = messager.getText("main.malformed_locale_name", localeName);
                    throw new ToolException(CMDERR, text);
                }
                country = localeName.substring(firstuscore + 1,
                        seconduscore);
                variant = localeName.substring(seconduscore + 1);
            } else if (localeName.length() == firstuscore + 3) {
                country = localeName.substring(firstuscore + 1);
            } else {
                String text = messager.getText("main.malformed_locale_name", localeName);
                throw new ToolException(CMDERR, text);
            }
        } else if (firstuscore == -1 && localeName.length() == 2) {
            language = localeName;
        } else {
            String text = messager.getText("main.malformed_locale_name", localeName);
            throw new ToolException(CMDERR, text);
        }
        userlocale = searchLocale(language, country, variant);
        if (userlocale == null) {
            String text = messager.getText("main.illegal_locale_name", localeName);
            throw new ToolException(CMDERR, text);
        } else {
            return userlocale;
        }
    }
160501
public CompilationUnit getCompilationUnit(String name,
            CompilationUnit from) {
        String fqName = determineQualifiedName(name, from);

        // Templates with source will always override compiled templates
        boolean compiled = false;
        if (fqName == null && (compiled = CompiledTemplate.exists(this, name, from))) {
            fqName = CompiledTemplate.getFullyQualifiedName(name);
        }
        if (fqName == null)
            return null;

        CompilationUnit unit = mCompilationUnitMap.get(fqName);
        if (unit == null) {
            if (!compiled) {
                unit = createCompilationUnit(fqName);
                if (unit != null)
                    mCompilationUnitMap.put(fqName, unit);
            } else {
                unit = new CompiledTemplate(name, this, from);
                // if the CompiledTemplate class was precompiled (is valid) return the unit, otherwise return null to signify 'not found'
                if( ((CompiledTemplate)unit).isValid() ) {
                    mCompilationUnitMap.put(fqName, unit);
                } else {
                    // TODO:  flag the template class for removal
                    unit = null;
                }
            }
        }

        return unit;
    }
548288
@Override
	public Template getTemplate(String resource) {
		return ThymeleafTemplate.wrap(this.engine, resource, (null == this.config) ? null : this.config.getCharset());
	}
170328
public CLDR.Locale fromJavaLocale(java.util.Locale javaLocale) {
    return MetaLocale.fromJavaLocale(javaLocale);
  }
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);
    }
  }