laravel-achievements icon indicating copy to clipboard operation
laravel-achievements copied to clipboard

Multilingual Support

Open HDVinnie opened this issue 3 years ago • 5 comments

class UserMadeComment extends Achievement
{
    /*
     * The achievement name
     */
    public $name = trans('achievements.made-first-comment-name');

    /*
     * A small description for the achievement
     */
    public $description = trans('achievements.made-first-comment-description');
}

results in

[2021-03-14 16:26:54] prod.ERROR: Constant expression contains invalid operations {"userId":4,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Constant expression contains invalid operations at /var/www/html/app/Achievements/UserMadeComment.php:23)

because trans won't work on constants

HDVinnie avatar Mar 14 '21 17:03 HDVinnie

@assada Therefore I propose the usage of methods like getName() and getDescription(). I am going to open a PR for this (hopefully) today.

Wulfheart avatar Mar 24 '22 12:03 Wulfheart

@Wulfheart It would be great!

assada avatar Sep 06 '22 10:09 assada

@assada could you please assign me that issue so I don’t lose track?

Wulfheart avatar Sep 06 '22 11:09 Wulfheart

If there is no active contribution, Can I take care of this issue? @assada

ebihimself avatar Oct 20 '22 18:10 ebihimself

Sure. It is quite easy to implement. Haven’t had the time yet. Go for it!

Wulfheart avatar Oct 20 '22 19:10 Wulfheart