I actually trying to create my own reusable bundle. I created a Demo project that include my custom bundle as dependency using symlink composer config.
Actually, I tried to extract some translation keys from my custom bundle into the demo project.
But when I launch the command bin/console translation:update fr --dump-messages there is no entry from my bundle.
What I want to extract is some constant keys that I want to translate.
For example, in MyCustomClass there is some status in an array. So I don't know if there is an Interface that I can implement to auto extract my translation keys.
I'm using:
Symfony Framework 5.3.8
Symfony Translation 5.3.9
Thanks
Related
I have upgraded my cloud Artifactory to "7.52.0".
Prior to the upgrade I was using System Templates to deploy my pipelines.
Although after the upgrade there is still backward compatibility, The new way to deploy and use System Templates for creating new pipelines is not working for me.
From the release notes I got to this link to configure System Templates in the new way.
https://www.jfrog.com/confluence/display/JFROG/System+Templates
So in my repository A I have 2 files 'pipelines.yml' and 'values.yml'
pipelines.yml is configured as follows:
valuesFilePath: ./values.yml
Include:
template: myTemplates/TestTemplate/1.0.0
My values file contains values for the TestTemplate.
Then I go to https://example.jfrog.io/ui/admin/pipelines/pipelineSources and I try to create a new pipeline from repository A.
Looking at https://example.jfrog.io/ui/pipelines/myPipelines/myPipelines I don't see any pipeline created from the template.
Is that the right way to implement the new System Template?
I have also made sure that the templates are in the Artifactory by checking:
https://example.jfrog.io/ui/pipelines/templates
and also in the Artifactory directory tree.
Currently I am using the REST API in order to CRUD my Template Sources(https://example.jfrog.io/ui/pipelines/sources) and also use the REST API to create a new pipelines sources from a system template (apparently this is the old way).
As after the upgrade creating a source pipeline doesn't sync the old/new templates nor does it create a new pipeline from a system template that is located in the Artifactory.
You need to use the syntax documented in the Global template link.
Using the "jfrog/PublishTemplate" global template documentation
https://www.jfrog.com/confluence/display/JFROG/Global+Templates . I have noticed that in order to create and upload a system template you need to use the following syntax:
valuesFilePath: ./values.yml
include:
template: jfrog/<global_template_name>/<template_version>
According to the system template documentation this is the syntax that got me confused:
valuesFilePath: ./values.yml
Include:
template: jfrog/PublishTemplate/1.0.0
So I have used capital "I" instead of small "i" and bad indentation in order to create a new pipeline from my system template, which failed.
You use the Global template "PublishTemplate" for uploading your system template into your artifactory.
And then use the uploaded templates in order to create your new pipelines.
Is there any tool (method )to generate code documentation for Symfony 3.x? For example, the tool should generate classes methods, fields etc.
Run Sami in your symfony path or clone symfony repository and run sami on src folder. Every time symfony is updated must run sami in order to re-generate the API documenation.
https://github.com/FriendsOfPHP/sami
In my symfony2 application, i have set up what's necessary to change the locale.
Now I can use the trans features of the bundle and generate the language files under app/resources/translations
That works fine but I feel it's not efficient to edit yml files by hand, and it's advised to use xliff which is absolutely not user friendly.
Plus, in a collaborative environment, I don't see how this could properly work. I'm not sure translators would like git commands.
To those who have already implemented a translation process : how did you do ? how do you organize it ?
Thanks a lot
I used JMSTranslationBundle https://github.com/schmittjoh/JMSTranslationBundle to manage my translations on a project. You use the usual |trans on the variables you want to translate. And then you use a command with app/console for this bundle, and it builds your yml files for you (you have the option to pick the output file type). It also has a translation UI. And if you add new words, no problem, you just rerun the command, it adds the new words to your existing words without losing the original translation.
I'm using only YAML files, but they are located in each bundle, not in the app folder. This is the better way if you want to get clean code. If your translation files are in the app folder, you need to extract the content for a bundle you want to use in another project.
If you use a good IDE like PhpStorm, YAML is no problem and the easiest way to edit YAML. Don't forget the symfony plugin for PhpStorm!
EDIT:
You can also use this bundle. It provides a web interface for translations: http://jmsyst.com/bundles/JMSTranslationBundle#documentation
I have implemented manageable translations for one of my project you can refer to My answer similar to this topic what i have done i have created a service which loads all the translations from my repository.I have 2 entities for this
Language
Language entity holds all the languages which has 2 properties locale and name
locale (en,fr,ar ...)
name (english,french ...)
LanguageTranslation
LanguageTranslation entity holds all the translations with properties
catalogue
translation
language (translation language )
languageToken (key for translation)
Now all your translations are cached by symfony in prod/dev folder so each time when user updates or adds new translation i have cleared translations cache programmatically i was using sonata admin so i added a call to this function in prePersist and preUpdate you can also use doctrine event listeners prePersist/preUpdate for this
private function clearLanguageCache(){
$cacheDir = __DIR__ . "cache folder path"; /** path to app/cache*/
$finder = new \Symfony\Component\Finder\Finder();
$finder->in(array($cacheDir . "/dev/translations", $cacheDir . "/prod/translations"))->files();
foreach($finder as $file){
unlink($file->getRealpath());
}
}
This part is missing in my previous answer for clearing cache
I'm developing a web site with Symfony. I'm new on this framework. Before i used Laravel 5.0 and I need to have a database with rows.
I create my db with command prompt but now I don't find how to seed it.
There is a equivalent of Laravel seeders on Symfony?
No. Seeding was a feature added by Laravel. You’ll need to use a third-party package to load seeds/fixtures into your application: http://www.sitepoint.com/data-fixtures-symfony2/
All the answers here are a bit outdated and this question is the first result on google so for future readers:
Since Symfony 3 there is an official bundle for this very purpose
Installation: composer require --dev doctrine/doctrine-fixtures-bundle
Then write your fixtures in src/DataFixtures and run php bin/console doctrine:fixtures:load
Try this package https://packagist.org/packages/evotodi/seed-bundle. Looks like it's what you need.
Their readme
Symfony/Doctrine Seed Bundle
Used to load/unload seed data from the database. Example would be to load a table with a list of states and abbreviations, or populate the users table with initial admin user(s). Unlike the DoctrineFixturesBundle which is mainly for development this bundle is for seeding the database before the initial push to production.
I am trying to create a bundle in vendors in Symfony2.
MyBundle(MineUserBundle) needs to inherit other two bundle in vendors FOSUserBundle and HWIOAuthBundle.
How to get inherit both bundles properties, templates etc in Mybundle?
vendors
FOSUserBundle
HWIOAuthBundle
MineUserBundle
Here MineUserBundle needs to have all features of other two bundle.
How to get the process work?
Since you are using namespaces it does not mater into which folder you are going to deploy your Bundle. Just include use statements in your bundle with ones you need:
use Path\To\FOS\UserBundle;
use Path\ToHWIO\AuthBundle;
And you can extend whatever you need.
But if you really want to install your bundle to vendor directory, then you have to configure define it in your deps file.
[YourVendorYouBundle]
git=git#github.com:yourRepository/YourVendorYouBundle.git
target=/bundles/YourVendor/YouBundle