The format "yml" does not exist
Closed this issue ยท 7 comments
Q | A |
---|---|
Bundle version | |
Symfony version | 3.4 |
PHP version | 7.1 |
Hi,
Having 100% of .xliff
files in Resources/translations
adding one example.fr.yml
inside Resources/translations
and the bundle stops working:
The format "yml" does not exist.
jms_translation:
configs:
app:
dirs: ["%kernel.root_dir%", "%kernel.root_dir%/../src/AppBundle"]
output_dir: "%kernel.root_dir%/Resources/translations"
ignored_domains: [routes, example]
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]
the problem is not related to .yml
or .xliff
format. but I don't understand the problem what related
backup your translation data and delete app/Resources/translations
folder. fixed for me
I don't understand the process.
I moved all files from translations/ to another folder,
run the command, which did fine, then replace my files and re-run the command and I got the same error.
The only way I found is to move the .yml files outside the translations
folder just the time to run the command, and move them back, but it's ANNOYING. :-)
absolutely...
@schmittjoh must be interested in this issue
Try to rename your translations to .yaml
instead of .yml
, it helped me to get rid of this message
@bocharsky-bw actually it helped me. :)
Please see #479.
Waiting the merge and release, you can make a workaround by creating a compiler pass like this:
namespace AppBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class TranslationLoaderPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$loaderManagerDefinition = $container->getDefinition('jms_translation.loader_manager');
$loaders = $loaderManagerDefinition->getArgument(0);
$loaders['yml'] = $loaders['yaml'];
$loaderManagerDefinition->replaceArgument(0, $loaders);
}
}
And then register it:
namespace AppBundle;
use AppBundle\DependencyInjection\Compiler\TranslationLoaderPass;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
final class AppBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container
->addCompilerPass(new TranslationLoaderPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1)
;
}
}
The -1
priority is important! This pass must be called after the vendor one to have the loaders list.
@soullivaneuh your compiler pass seems to work for me. Thanks!