{"id":21662547,"url":"https://github.com/php-gettext/twig-scanner","last_synced_at":"2026-03-07T02:02:49.804Z","repository":{"id":46175158,"uuid":"259098461","full_name":"php-gettext/Twig-Scanner","owner":"php-gettext","description":" Twig code scanner for gettext ","archived":false,"fork":false,"pushed_at":"2022-07-18T17:33:20.000Z","size":49,"stargazers_count":4,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T10:27:59.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-gettext.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T18:01:42.000Z","updated_at":"2023-11-12T13:11:15.000Z","dependencies_parsed_at":"2022-09-19T11:41:49.279Z","dependency_job_id":null,"html_url":"https://github.com/php-gettext/Twig-Scanner","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-gettext%2FTwig-Scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-gettext%2FTwig-Scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-gettext%2FTwig-Scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-gettext%2FTwig-Scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-gettext","download_url":"https://codeload.github.com/php-gettext/Twig-Scanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497890,"owners_count":21113984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T10:16:54.208Z","updated_at":"2026-03-07T02:02:49.788Z","avatar_url":"https://github.com/php-gettext.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twig Scanner\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE)\n[![Total Downloads][ico-downloads]][link-downloads]\n\nCreated by Raphaël Droz \u003craphael.droz@gmail.com\u003e (GPL-3 License)\n\nTwig code scanner to use with [gettext/gettext](https://github.com/php-gettext/Gettext)\n\n## Warning\n\nIn order to be usable, upstream ParsedFunction class at php-gettext/Gettext must be slightly modified to ease inheritance.\n\n## Installation\n\n```\ncomposer require gettext/twig-scanner\n```\n\n## About dependencies\n\nWe do not require a **specific** version of Twig.\n\nToDo: Support symfony/twig-bridge `trans` filter.\n\n## Usage example\n\n```php\nuse Gettext\\Scanner\\TwigScanner;\nuse Gettext\\Generator\\PoGenerator;\nuse Gettext\\Translations;\n\n//Create a new scanner, adding a translation for each domain we want to get:\n$twigScanner = new TwigScanner(\n    Translations::create('domain1'),\n    Translations::create('domain2'),\n    Translations::create('domain3')\n);\n\n//Set a default domain, so any translations with no domain specified, will be added to that domain\n$twigScanner-\u003esetDefaultDomain('domain1');\n\n//Extract all comments starting with 'notes:'\n$twigScanner-\u003eextractCommentsStartingWith('notes:');\n\n//Scan files\nforeach (glob('*.twig') as $file) {\n    $twigScanner-\u003escanFile($file);\n}\n\n//Save the translations in .po files\n$generator = new PoGenerator();\n\nforeach ($twigScanner-\u003egetTranslations() as $domain =\u003e $translations) {\n    $generator-\u003egenerateFile($translations, \"locales/{$domain}.po\");\n}\n```\n\n---\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about recent changes.\n\nThe GPL-3 License (GPL-3). Please see [LICENSE](LICENSE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/gettext/twig-scanner.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/gettext/twig-scanner.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/gettext/twig-scanner\n[link-downloads]: https://packagist.org/packages/gettext/twig-scanner\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-gettext%2Ftwig-scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-gettext%2Ftwig-scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-gettext%2Ftwig-scanner/lists"}