/**
* Returns a XliffModel instance representing desired XLIFF file.
*
* Will return existing instance if a model for given $sourceName was already
* requested before. Returns FALSE when $sourceName doesn't point to existing
* file.
*
* @param string $packageKey Key of the package containing the source file
* @param string $sourceName Relative path to existing CLDR file
* @param I18n\Locale $locale Locale object
* @return XliffModel New or existing instance
* @throws I18n\Exception
*/
protected function getModel($packageKey, $sourceName, I18n\Locale $locale)
{
$sourcePath = Files::concatenatePaths(['resource://' . $packageKey, $this->xliffBasePath]);
list($sourcePath, $foundLocale) = $this->localizationService->getXliffFilenameAndPath($sourcePath, $sourceName, $locale);
if ($sourcePath === false) {
throw new I18n\Exception('No XLIFF file is available for ' . $packageKey . '::' . $sourceName . '::' . $locale . ' in the locale chain.', 1334759591);
}
if (isset($this->models[$sourcePath])) {
return $this->models[$sourcePath];
}
return $this->models[$sourcePath] = new XliffModel($sourcePath, $foundLocale);
}