Javascript code scanner to use with gettext/gettext

Overview

JS Scanner

Latest Version on Packagist Software License Build Status Quality Score Total Downloads

Created by Oscar Otero http://oscarotero.com [email protected] (MIT License)

Javascript code scanner to use with gettext/gettext

Installation

composer require gettext/js-scanner

Usage example

use Gettext\Scanner\JsScanner;
use Gettext\Generator\PoGenerator;
use Gettext\Translations;

//Create a new scanner, adding a translation for each domain we want to get:
$jsScanner = new JsScanner(
    Translations::create('domain1'),
    Translations::create('domain2'),
    Translations::create('domain3')
);

//Scan files
foreach (glob('*.js') as $file) {
    $jsScanner->scanFile($file);
}

//Save the translations in .po files
$generator = new PoGenerator();

foreach ($jsScanner->getTranslations() as $translations) {
    $domain = $translations->getDomain();
    $generator->generateFile($translations, "locales/{$domain}.po");
}

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.

You might also like...
[OUTDATED] Two-factor authentication for Symfony applications 🔐 (bunde version ≤ 4). Please use version 5 from https://github.com/scheb/2fa.

scheb/two-factor-bundle ⚠ Outdated version. Please use versions ≥ 5 from scheb/2fa. This bundle provides two-factor authentication for your Symfony ap

A modern, portable, easy to use crypto library.
A modern, portable, easy to use crypto library.

Sodium is a new, easy-to-use software library for encryption, decryption, signatures, password hashing and more. It is a portable, cross-compilable, i

A PHP library for counting short DNA sequences for use in Bioinformatics

Helix A PHP library for counting short DNA sequences for use in Bioinformatics. Helix consists of tools for data extraction as well as an ultra-low me

PHP code scanner to use with gettext/gettext

PHP code scanner to use with gettext/gettext

Gettext is a PHP (^7.2) library to import/export/edit gettext from PO, MO, PHP, JS files, etc.

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

A php.ini scanner for best security practices

Scanner for PHP.ini The Iniscan is a tool designed to scan the given php.ini file for common security practices and report back results. Currently it

Laravel Automated Vulnerability Scanner

Todo Laravel Fingerprint Laravel Leak .env Laravel Debug Mode Laravel CVE-2018-15133 Laravel Ignition CVE-2021-3129 Insecure Deserialization with APP_

Parse: A Static Security Scanner

Parse: A PHP Security Scanner PLEASE NOTE: This tool is still in a very early stage. The work continues... The Parse scanner is a static scanning tool

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

Enlightn Security Checker The Enlightn Security Checker is a command line tool that checks if your application uses dependencies with known security v

Scanner, signatures and the largest collection of Magento malware
Scanner, signatures and the largest collection of Magento malware

Improved malware scanner now available Good news: our opensource malware scanner "mwscan" has been succeeded by a much better one called eComscan. It

sqlscan is quick web scanner for find an sql inject point
sqlscan is quick web scanner for find an sql inject point

sqlscan sqlscan is quick web scanner for find an sql inject point. not for educational, this is for hacking. use sitemap for best result Simple to use

WPHunter A Wordpress Vulnerability Scanner

WPHunter Tool ☣ WPHunter A Wordpress Vulnerability Scanner You can use this tool on your wordpress website to check the security of your website by fi

WebVulScan - a web application vulnerability scanner
WebVulScan - a web application vulnerability scanner

WebVulScan is a web application vulnerability scanner. It is a web application itself written in PHP and can be used to test remote, or local, web applications for security vulnerabilities.

PHP class to generate bookmarklets from Javascript code

Bookmarklet Gen Convert readable Javascript code into bookmarklet links Features removes comments compresses code by removing extraneous spaces, but n

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

An effort to make testing PHP code as easy and fun as its JavaScript equivalent

An effort to make testing PHP code as easy and fun as its JavaScript equivalent when using the excellent Jasmine, from which syntax and general usage is shamelessly borrowed.

Use your Laravel named routes in JavaScript
Use your Laravel named routes in JavaScript

Ziggy – Use your Laravel routes in JavaScript Ziggy provides a JavaScript route() helper function that works like Laravel's, making it easy to use you

Use your Laravel named routes in JavaScript
Use your Laravel named routes in JavaScript

Ziggy – Use your Laravel routes in JavaScript Ziggy provides a JavaScript route() helper function that works like Laravel's, making it easy to use you

Comments
  • Wrong logic to get function name from js on difficult expressions.

    Wrong logic to get function name from js on difficult expressions.

    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 https://github.com/php-gettext/JS-Scanner/blob/0ad8516db4279b1be6f0f3ea9c1a4b8da3e8aa3e/src/JsNodeVisitor.php#L90

    Some broken examples
    // 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;
    }
    
    opened by DmitryKorol 1
  • [suggestion] add setFunctions like in phpScaner

    [suggestion] add setFunctions like in phpScaner

    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

    opened by jarodium 1
  • PHP 8 compatibility

    PHP 8 compatibility

    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

    opened by enricoantonini84 1
  • Add

    Add "_" to gettext functions list

    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

    opened by epi-JRD 2
Releases(v1.1.2)
Owner
Gettext
PHP implementation of gettext
Gettext
Laravel Automated Vulnerability Scanner

Todo Laravel Fingerprint Laravel Leak .env Laravel Debug Mode Laravel CVE-2018-15133 Laravel Ignition CVE-2021-3129 Insecure Deserialization with APP_

Carlos Vieira 52 Dec 4, 2022
sqlscan is quick web scanner for find an sql inject point

sqlscan sqlscan is quick web scanner for find an sql inject point. not for educational, this is for hacking. use sitemap for best result Simple to use

Bellatrix Lugosi 133 Dec 29, 2022
WPHunter A Wordpress Vulnerability Scanner

WPHunter Tool ☣ WPHunter A Wordpress Vulnerability Scanner You can use this tool on your wordpress website to check the security of your website by fi

Jamal Eddine 140 Dec 24, 2022
WebVulScan - a web application vulnerability scanner

WebVulScan is a web application vulnerability scanner. It is a web application itself written in PHP and can be used to test remote, or local, web applications for security vulnerabilities.

Dermot Blair 145 Nov 20, 2022
A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.

A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.

Alex Bouma 239 Dec 14, 2022
JObfuscator — Java Source Code Obfuscation & Protection

JObfuscator is a source code obfuscator for the Java programming language. It can protect your Java source code and algorithms from hacking, cracking, reverse engineering, decompilation, and technology theft.

Bartosz Wójcik 8 Nov 6, 2022
Laravel and Lumen Source Code Encrypter

Laravel Source Encrypter This package encrypts your php code with phpBolt For Laravel and Lumen 6, 7, 8 Installation Usage Installation Step 1 At the

Siavash Bamshadnia 363 Jan 1, 2023
phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code

phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code.

Floe design + technologies 654 Dec 28, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Jan 6, 2023
PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

PHPIDS PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web ap

null 752 Jan 3, 2023