In symfony2, with JMSTranslationBundle, when running
php app/console translation:extract fr --config=app
I get the issue
[JMS\TranslationBundle\Exception\InvalidArgumentException]
The format "yml~" does not exist.
my config being
jms_translation:
configs:
app:
dirs: [%kernel.root_dir%, %kernel.root_dir%/../src]
output_dir: %kernel.root_dir%/Resources/translations
ignored_domains: [routes]
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]
# extractors: [jms_i18n_routing]
Any idea as how to solve this ?
The solution is to remove all *.yml~ files from your project.
Related
I'm using Symfony 6 and don't understand how I should enable translation for dependency messages.
For example: I just installed SymfonyCasts/verify-email-bundle which provides translations in its directory (src/Resources/translations)
To enable them, I have:
installed the translation bundle with: composer require symfony/translation
set the default_locale to fr in my config/packages/translation.yaml
cleared the cache with bin/console cache:clear
also tried to manually clear translation cache as stated in other related posts : rm -rf var/log/translations
Then, all messages that should be handled by the provided translations are still in English.
I have also tried to force translation by calling myself the $translator->trans() method on the string returned by the bundle. The profiler then says the translation is missing and fallbacks to en as configured.
I have tried to copy the bundle VerifyEmailBundle.fr.xlf file into my own /translations directory but got the same error. bin/console debug:translation fr shows me the needed translations but all are marked as unused.
I encounter the same issue with multiple bundles and don't see anything in the offical documentation about this.
What am I missing?
To set default language you must set #config/packages/translation.yaml like this:
framework:
default_locale: fr
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- fr
and you can add translations at #translations/messages.fr.yml
Hello: 'Bonjour'
This friendly message is coming from: 'Ce message amical vient de'
Welcome to my new App: 'Bienvenue sur ma nouvelle application'
user:
profile:
admin: 'administrateur'
I am trying to begin my education of symfony 2 and started with it's tutorial. One of first things I tried was to install symfony 2 and configure it.
When I try to access http://127.0.0.1:8000/, I am getting an incomplete site with the following error:
ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /"" at /home/spectator/webprojects/cls/app/cache/dev/classes.php line 2059
Things I have tried so far:
clearing cache (php app/console cache:clear --env=prod --no-debug)
recursively changing permissions to folder cls (symfony 2 folder) to
775 and even 777 (for diagnostics purposes)
adding "/" route to routing.yml and routing_dev.yml
reinstalling and
re-chmod symfony 2.
Try http://localhost:8000/app/example
Fresh installation has no routes for the root path "/"
first you need to set a default route
edit the routing.yml
app/config/routing.yml
app:
resource: #AppBundle/Controller/ # bundle name / Controller name
type: annotation # type of routing or
# app/config/routing.yml # file routing
app:
resource: #AppBundle/Controller/
prefix: /
you can learn more in http://symfony.com/doc/current/book/routing.html
The default installation does not come with a default route for "/".
The example controller only defines a route of
#Route("/app/example", name="homepage")
In the past, a fresh Symfony installation also included some simple demo code to learn how does the framework work. A few months ago we decided to change this behavior by the following:
A fresh Symfony installation no longer contains any demo code.
A new "Symfony Demo Application" has been published for people learning the framework (read more about this demo application).
If you use the Symfony Installer, you should do the following:
When learning Symfony, execute the symfony demo command
When creating a new Symfony project, execute the symfony new my_project command
I had the same problem. Just add <?php in the top of the file. Looks like if we don't specify it s
When i run the command
php app/console translation:extract en --enable-extractor=jms_i18n_routing
i get the following error:
[JMS\TranslationBundle\Exception\InvalidArgumentException]
The directory where translations are must be set.
this is the bundle configuration:
jms_i18n_routing:
default_locale: it
locales: [it, en]
strategy: prefix
cookie:
enabled: false
What is wrong with that?
You can fix this by using the --dir option to define the directory where your translations are when running your translation:extractcommand.
From the documentation,
For dumping, the bundle provides you with a console command which you
can use to update your translation files, or also just to preview all
changes that have been made.
Updating Files:
php app/console translation:extract de --dir=./src/ --output-dir=./app/Resources/translations
i had to use the following command
php app/console translation:extract en --enable-extractor=jms_i18n_routing --bundle="AcmeFooBundle" --domain="routes"
I installed behat with mink and selenium2-driver for my Symfony2 project.
Is it possible to use the /app/config/behat.yml instead of the /behat.yml file?
I searched on google but I can't find anything else this command.
php bin/behat --config app/config/behat.yml
But the command isn't working either.
I think there must be a config-path in composer.json.
Yes, you can configure which config file you want to use. Look at this part of the doc.
http://docs.behat.org/guides/7.config.html#paths
What error do you get when running your command?
php bin/behat --config app/config/behat.yml
This error?
[RuntimeException]
Context class not found.
Maybe you have provided a wrong or no `bootstrap` path in your behat.yml:
http://docs.behat.org/guides/7.config.html#paths
If that's the case, I think if might be because you need to specify where to find the features in your behat.yml file.
Now you moved the file to /app/config/behat.yml, the related path from behat.yml to the feature directory has changed, so you should add the following to the file:
default:
paths:
features: ../features/
bootstrap: ../features/bootstrap
Here is what I'm stuck on.
I'm working on Symfony2 and trying to make the translations working. But somehow, I can't make it work as it should. Here's what I got.
In the config.yml
translator: { fallback: de }
session:
default_locale: en
In messages.en.yml I have this structure:
Please log in: Bitte melden Sie sich an
I also have similar files for messages.en_US.yml, messages.ru.yml, etc.
In the code I use $this->get('session')->setLocale('ru_RU'); to change the locale.
But the translation works only when the locale is set to "en_US" or "de_DE". In any other case it returns the key, not the value. I try the translation with this code
return new Response($this->get('translator')->trans('Please log in').' '.$this->get('session')->getLocale()); and it returns the locale I have set.
So what can cause this problem?
you should clear the cache by using the symfony comand
app/console cache:clear --no-debug
then eventually restore write permission on cache/ and log/ folders as described here
I found the answer myself. Just needed to clean up the cache for Symfony. Used console to do so. Changed directory to myProject/app and used this commands to clean the cache and logs:
sudo rm -R cache/
sudo rm -R logs/