php-gettext / js-scanner Goto Github PK
View Code? Open in Web Editor NEWJavascript code scanner for gettext
License: MIT License
Javascript code scanner for gettext
License: MIT License
Hello,
Would it be possible to add "_" to the list of functions handled by JsScanner, same way as in PHPScanner?
I opened a PR including the addition in case you agree.
Best,
Juliette
Hello,
we are trying to install the package via composer, however it seems not compatible with php8. Is there a new compatible version on the way?
Regards
Enrico
Hello, trying to parse big legacy mess of code for extracting translations.
But while this process getting errors on some difficult expressions, by example:
Fatal error: Uncaught Error: Call to undefined method Peast\Syntax\Node\MemberExpression::getName() in ./vendor/gettext/js-scanner/src/JsNodeVisitor.php:90
JS-Scanner/src/JsNodeVisitor.php
Line 90 in 0ad8516
// occured: Peast\Syntax\Node\StringLiteral::getName()
// source: var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
// problem: Symbol['for']('react.element');
// occured: Peast\Syntax\Node\BinaryExpression::getName()
// source: reset: function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this}
// problem: reset = $element[e!==null?"addClass":"removeClass"]("collapse")
// occured: Peast\Syntax\Node\ConditionalExpression::getName()
// source: reset: function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this}
// problem: this.$element[e!==null?"addClass":"removeClass"]("collapse")
That problem looks like global , because can be reproduced many times with many of code variations.
FYI: For fast fix i'm used this hack:
switch ($callee->getType()) {
case 'Identifier':
return $callee->getName();
case 'MemberExpression':
if (!method_exists($callee->getProperty(), 'getName')) {
return null;
}
return $callee->getProperty()->getName();
default:
return null;
}
Hello,
I'm using https://github.com/guillaumepotier/gettext.js/ as a library for my translations.
I have wrapped it's gettext function into a _() like function ( for convenience and familiarity with php ), but this scanner can't seem to find it.
I think adding phpScanner's setFunctions method would solve this, helping to get translations to get scanned in every other js based translation library.
Thank you
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.