amiranagram / localizator

Scan your Laravel project and generate language files ready to translate in language(s) of choosing.
Other
226 stars 28 forks source link

Vuejs and $t #62

Open piep14 opened 4 months ago

piep14 commented 4 months ago

Hello,

I'm using the laravel-vue-i18n package.

I put my configuration file like this :

'search' => [
        /**
         * Directories which should be looked inside.
         */
        'dirs' => [
            'app',
            'resources',
            'routes',
        ],

        /**
         * Subdirectories which will be excluded.
         * The values must be relative to the included directory paths.
         */
        'exclude' => [
            'vendor/cookie-consent',
        ],

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

        /**
         * 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', 'trans_choice', '$t']
    ],

And yet, it doesn't bring out the values in me, such as: <label for="new-message" class="form-label">{{ $t('Add a new message for this travel') }} :</label>

I also had to ignore the spatie/laravel-cookie-consent package because it crashes due to the following strings: {!! trans('cookie-consent::texts.message') !!}

Thank you for your help

maicol07 commented 3 days ago

@piep14 since the functions array will be used in a regex you have to escape the dollar.

This worked for me: \$t