Download the PHP package mfn/phpstan-lost-in-translation without Composer
On this page you can find all versions of the php package mfn/phpstan-lost-in-translation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mfn/phpstan-lost-in-translation
More information about mfn/phpstan-lost-in-translation
Files in mfn/phpstan-lost-in-translation
Package phpstan-lost-in-translation
Short Description Helps find missing translation strings in Laravel applications
License AGPL-3.0+
Homepage https://github.com/mfn/phpstan-lost-in-translation
Informations about the package phpstan-lost-in-translation
phpstan-lost-in-translation
Note: this is a fork of https://github.com/jbboehr/phpstan-lost-in-translation
Installation
To use this extension, require it in Composer:
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:
Additional Requirements
While there is not a strict requirement, this extension will likely not function as expected without the following extra PHPStan extensions installed:
- Larastan - Provides better type inference for Laravel applications
- Bladestan - Provides static analysis of Blade templates
Features
Type inference
Note that for most of the features below, we can only analyze any potential constant strings in the type of the variable passed into the translation function. This takes advantage of PHPStan's type inference. For example, these should all be able to be analyzed correctly:
Find missing translation strings
Your application's source files will be scanned for calls to the Laravel translator and checked for undefined translation strings. Enabled by default.
If Larastan is installed, there will be better type inference. If Bladestan is installed, it will be possible to inspect blade templates (you probably really want this).
Find unused translations
We can attempt to detect unused translation strings. Disabled by default.
Disallow dynamic translations strings
We can disallow using translations strings that are not statically known. Disabled by default.
Find strings untranslated in the base locale
Missing translation strings in the base locale are not reported as missing. However, some translation
strings may still need to be specified even in the base locale. Currently, this check reports untranslated
strings in the base locale where the group and translation key are identifiers, where an identifier matches
[\w][\w\d]*(?:[_-][\w][\w\d]*)*. For example: group-name.translation-key. Enabled by default
Analyze replacements
Replacements will be analyzed for undesirable behavior. Enabled by default.
Analyze choices
Choices will be analyzed for potentially invalid options. Enabled by default.
Errors in translation files
Errors in translation lines will be logged as well, including parse errors. Enabled by default.
Analyze locales
If an invalid locale is given to a translation function, an error will be emitted. Enabled by default.
If strictLocale is set, it must match, for example, pt_BR.
Otherwise, it can also match any of PT_br, pt-br, etc. Disabled by default.
Invalid character encoding
If a translation string is not valid UTF-8, an error will be issued. Enabled by default.
Configuration
References
This project is based on and inspired by coding-socks/lost-in-translation.
License
This project is licensed under the AGPL v3+ License - see the LICENSE.md file for details.
All versions of phpstan-lost-in-translation with dependencies
ext-mbstring Version *
phpstan/phpstan Version ^2.0
salsify/json-streaming-parser Version ^8.3
symfony/finder Version ^7
symfony/intl Version ^7