Extract Untranslated Strings from Laravel Projects

Extract Untranslated Strings from Laravel Projects

Localizator is a small tool for Laravel that gives you the ability to extract untranslated strings from project files. It works using the artisan command line and the provided localize command:

php artisan localize de,fr

The above command will create a de.json and fr.json file in the resources/lang folder or add missing keys if these files already exist.

You can also use the configuration value in app.locale by running the command without arguments:

# Use the `config('app.locale')` value
php artisan localize

The package also provides configurable values to suit your project’s needs, along with sensible defaults:

return [

    /**
     * Search criteria for files.
     */
    'search' => [
        /**
         * Directories which should be looked inside.
         */
        'dirs' => ['resources/views'],

        /**
         * Patterns by which files should be queried.
         * The values can be a regular expresion, glob, or just a string.
         */
        'patterns' => ['*.php'],

        /**
         * Functions that the strings will be extracted from.
         * Add here any custom defined functions.
         * NOTE: The translation string should always be the first argument.
         */
        'functions' => ['__', 'trans', '@lang']
    ],

    /**
     * Should the localize command sort extracted strings alphabetically?
     */
    'sort' => true,

];

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in: Laravel Packages / packages

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Software Developer
Remote (US & Canada)
Alley
😎 Laravel Developer
Remote
Jogg, Inc
Junior, Mid, and Senior Software Engineers. Laravel / Vue. Saint Petersburg, FL
Saint Petersburg, FL and Remote
ShineOn
Senior PHP Developer (Laravel)
Remote
The Interaction Design Foundation
Fullstack Laravel Engineer (Munich/Remote) 💻
Munich, Germany or Remote
AirLST GmbH