coffreo / jms-translation-js-extractor-bundle Goto Github PK
View Code? Open in Web Editor NEWAdd javascript translation extractor for jms/translation-bundle package
License: MIT License
Add javascript translation extractor for jms/translation-bundle package
License: MIT License
I tried to decorate service Coffreo\JMSTranslationJsExtractorBundle\Extractor\JsFileExtractor
but Symfony gives me information that not such service exists.
Then I overrided service declaration in config to point out my custom service
coffreo.jms_translation.js_extractor.js:
class: App\Service\Decorators\JsFileExtractor <---- my class
arguments:
- '@jms_translation.file_source_factory'
- ['js', 'jsx']
tags:
- { name: 'jms_translation.file_visitor' }
I tried to extend your class to only override visitTwigFile
method, but I'm not able to extend final
class.
Finally I created a following constructor:
public function __construct(FileSourceFactory $fileSourceFactory, $extensions = null, JsTranslationExtractorInterface $extractor = null)
{
$this->fileSourceFactory = $fileSourceFactory;
$this->jsFileExtractor = new \Coffreo\JMSTranslationJsExtractorBundle\Extractor\JsFileExtractor($fileSourceFactory, $extensions, $extractor);
}
and "extended" your methods like that
public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue)
{
$this->jsFileExtractor->visitFile($file, $catalogue);
}
public function visitTwigFile(\SplFileInfo $file, MessageCatalogue $catalogue, Node $ast)
{
$translations = $this->jsFileExtractor->findTranslations($file);
foreach ($translations as $translation) {
/** @var $translation TranslationString */
$message = new Message($translation->getMessage(), $translation->getContext('domain') ?: 'messages');
$message->setDesc($translation->getContext('desc'));
$message->setDesc($translation->getContext('meaning'));
$message->addSource($this->fileSourceFactory->create($file, $translation->getLine()));
$catalogue->add($message);
}
$this->jsFileExtractor->visitTwigFile($file, $catalogue, $ast);
}
However it's not the best option. How it should be done?
To add PHP 8.0 support, the jms/translation-bundle must be upgraded to 1.6 which does not support PHP5.6 to PHP7.1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.