public function updateLocale($localePath, $locale, $domain)
{
$data = [$localePath, "LC_MESSAGES", $domain . ".po"];
if ($this->configuration->getCustomLocale()) {
$customLocale = array('C');
array_splice($data, 1, 0, $customLocale);
}
$localePOPath = implode($data, DIRECTORY_SEPARATOR);
if (!file_exists($localePOPath) || !($localeContents = file_get_contents($localePOPath))) {
throw new LocaleFileNotFoundException(sprintf('Can\'t read %s verify your locale structure', $localePOPath));
}
$newHeader = $this->createPOFile($localePOPath, $locale, $domain, false);
// Header replacement
$localeContents = preg_replace('/^([^#])+:?/', $newHeader, $localeContents);
if (!file_put_contents($localePOPath, $localeContents)) {
throw new LocaleFileNotFoundException(sprintf('Can\'t write on %s', $localePOPath));
}
return true;
}