Laravel-Lang / publisher

Publisher provides functionality for working with application localization
https://laravel-lang.com/packages-publisher.html
MIT License
212 stars 25 forks source link

Missing keys after lang:add XX #332

Closed misog closed 1 year ago

misog commented 1 year ago

Environment

Issue description

When I add php artisan lang:add de or php artisan lang:add es or any other language then validation.php is created however keys are missing. There are no translations of validation errors etc... Here is the file:

<?php

declare(strict_types=1);

return [
    'attributes' => [
        'address'                  => 'Adresse',
        'age'                      => 'Alter',
        'amount'                   => 'Höhe',
        'area'                     => 'Gebiet',
        'available'                => 'Verfügbar',
        'birthday'                 => 'Geburtstag',
        'body'                     => 'Körper',
        'city'                     => 'Stadt',
        'content'                  => 'Inhalt',
        'country'                  => 'Land',
        'created_at'               => 'Erstellt am',
        'creator'                  => 'Ersteller',
        'current_password'         => 'Derzeitiges Passwort',
        'date'                     => 'Datum',
        'date_of_birth'            => 'Geburtsdatum',
        'day'                      => 'Tag',
        'deleted_at'               => 'Gelöscht am',
        'description'              => 'Beschreibung',
        'district'                 => 'Bezirk',
        'duration'                 => 'Dauer',
        'email'                    => 'E-Mail-Adresse',
        'excerpt'                  => 'Auszug',
        'filter'                   => 'Filter',
        'first_name'               => 'Vorname',
        'gender'                   => 'Geschlecht',
        'group'                    => 'Gruppe',
        'hour'                     => 'Stunde',
        'image'                    => 'Bild',
        'last_name'                => 'Nachname',
        'lesson'                   => 'Lektion',
        'line_address_1'           => 'Adresszeile 1',
        'line_address_2'           => 'Adresszeile 2',
        'message'                  => 'Nachricht',
        'middle_name'              => 'Zweitname',
        'minute'                   => 'Minute',
        'mobile'                   => 'Handynummer',
        'month'                    => 'Monat',
        'name'                     => 'Name',
        'national_code'            => 'Länderkennung',
        'number'                   => 'Nummer',
        'password'                 => 'Passwort',
        'password_confirmation'    => 'Passwortbestätigung',
        'phone'                    => 'Telefonnummer',
        'photo'                    => 'Foto',
        'postal_code'              => 'Postleitzahl',
        'price'                    => 'Preis',
        'province'                 => 'Provinz',
        'recaptcha_response_field' => 'Captcha-Feld',
        'remember'                 => 'Erinnern',
        'restored_at'              => 'Wiederhergestellt am',
        'result_text_under_image'  => 'Ergebnistext unter Bild',
        'role'                     => 'Rolle',
        'second'                   => 'Sekunde',
        'sex'                      => 'Geschlecht',
        'short_text'               => 'Kurzer Text',
        'size'                     => 'Größe',
        'state'                    => 'Bundesland',
        'street'                   => 'Straße',
        'student'                  => 'Schüler/Student',
        'subject'                  => 'Gegenstand',
        'teacher'                  => 'Lehrer',
        'terms'                    => 'Bedingungen',
        'test_description'         => 'Test Beschreibung',
        'test_locale'              => 'Test Region',
        'test_name'                => 'Testname',
        'text'                     => 'Text',
        'time'                     => 'Uhrzeit',
        'title'                    => 'Titel',
        'updated_at'               => 'Aktualisiert am',
        'username'                 => 'Benutzername',
        'year'                     => 'Jahr',
    ],
];

Steps to reproduce

  1. php artisan lang:add es
  2. validation.php is created with missing keys
andrey-helldar commented 1 year ago

What version of the laravel-lang/lang package is installed in the project? Or are you using the laravel-lang/common package?

Apparently, you installed new versions of packages without checking them against the compatibility table.

Write your versions and I can tell you exactly what needs to be done to solve the problem.

misog commented 1 year ago

I installed it like this:

composer require laravel-lang/common --dev

In composer.lock I have laravel-lang/lang of version 13.2.2

Also

Laravel-Lang Publisher Version: v14.7.0
Laravel Version: v9.52.14
PHP Version: 8.2.1

Also we are using non-standard architecture of Laravel. So if Pubisher automatically detects needed translations maybe this could be the problem.

andrey-helldar commented 1 year ago

I see what the problem is. The "laravel-lang/common" package is not strictly tied to the version of the framework, so you installed it without any problems.

Thus, the "laravel-lang/lang" package version 13.2.2 was installed, and it does not contain translations for Laravel 9 (you can check the compatibility table).

To solve this problem, run the console commands:

composer remove laravel-lang/common --dev
composer require laravel-lang/common:^3.0 --dev
misog commented 1 year ago

Thank you, it is working now. This could be documented for other people.

andrey-helldar commented 1 year ago

This problem is encountered when installing older versions. I have released a fix that will install the correct version and get rid of the error.