symfony/translation · error · InvalidResourceException
This is not a local file
Error message
This is not a local file "%s".
What it means
IcuResFileLoader::load() checks stream_is_local($resource) and throws InvalidResourceException if the resource directory is not local. This loader loads ICU .res bundles from a local directory via ResourceBundle.
Solutions
- Pass a local directory path containing the .res bundle files.
- Sync remote bundle directories to a local temp dir before loading.
- Audit config for stream-wrapper prefixes in the resource directory setting.
- Create a wrapper loader that stages remote resources locally, then delegates to IcuResFileLoader.
Example fix
// before
$loader->load('s3://bundles/translations', 'en');
// after
$dir = '/tmp/icu-bundles';
foreach (glob('s3://bundles/translations/*.res') as $f) { copy($f, $dir.'/'.basename($f)); }
$loader->load($dir, 'en'); Defensive patterns
Strategy: validation
Validate before calling
if (!stream_is_local($dir)) {
throw new \InvalidArgumentException("ICU .res bundle dir must be local: $dir");
} Type guard
function isLocalDir(mixed $r): bool { return is_string($r) && stream_is_local($r); } Try / catch
try {
$catalogue = $loader->load($dir, $locale);
} catch (Symfony\Component\Translation\Exception\InvalidResourceException $e) {
// sync remote bundles to local dir and retry
} Prevention
- Store .res bundles in a local directory.
- Reject remote wrappers in your resource-path config validation.
- Stage remote resources to a local cache dir before loading.
When it happens
Trigger: Calling IcuResFileLoader::load($resource, $locale, $domain) with a non-local resource such as a URL or remote stream wrapper path.
Common situations: Configured bundle directory uses a remote wrapper (s3://, http://), or a path constant points off the local filesystem.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- This is not a local file
- File " " not found.
- Cannot load resource
- $rb->getErrorMessage()
- File " " not found.
AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15).
Data as JSON: /api/errors/04ea09de40b16abe.
Report an issue: GitHub.
Appendix: source
Thrown at Loader/IcuResFileLoader.php:29
namespace Symfony\Component\Translation\Loader;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\MessageCatalogue;
/**
* IcuResFileLoader loads translations from a resource bundle.
*
* @author stealth35
*/
class IcuResFileLoader implements LoaderInterface
{
public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
{
if (!stream_is_local($resource)) {
throw new InvalidResourceException(\sprintf('This is not a local file "%s".', $resource));
}
if (!is_dir($resource)) {
throw new NotFoundResourceException(\sprintf('File "%s" not found.', $resource));
}
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception) {
$rb = null;
}
if (!$rb) {
throw new InvalidResourceException(\sprintf('Cannot load resource "%s".', $resource));
} elseif (intl_is_failure($rb->getErrorCode())) {
throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());
}
View on GitHub (pinned to ae9e8a51bc)