assada / laravel-achievements

Laravel 6+ User Achievements system.
https://assada.github.io/laravel-achievements/
MIT License
65 stars 28 forks source link

Multilingual Support #11

Open HDVinnie opened 3 years ago

HDVinnie commented 3 years ago
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

Wulfheart commented 2 years ago

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

assada commented 2 years ago

@Wulfheart It would be great!

Wulfheart commented 2 years ago

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

ebihimself commented 1 year ago

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

Wulfheart commented 1 year ago

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