Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multilingual? #30

Closed
jespersgaard opened this issue Jul 25, 2016 · 4 comments
Closed

multilingual? #30

jespersgaard opened this issue Jul 25, 2016 · 4 comments

Comments

@jespersgaard
Copy link

hello

it is possible to use multilingual so that users see the activities in their own language?

best regards Martin

@freekmurze
Copy link
Member

Not out the box. But here's an idea: instead of logging the descriptions of the events, you could store a key that points to a translation you keep in a db or file.

@dct24
Copy link

dct24 commented Jul 26, 2017

@jespersgaard

You can make a service provider and translate those 3 hard coded descriptions (updated, created, deleted) there in a boot() method.

for example using language file and trans()

use Spatie\Activitylog\Models\Activity;

public function boot()
 {
        Activity::saving(function (Activity $activity) {
            $desc = $activity->description;
            if( $desc == 'updated' || $desc == 'created' || $desc == 'deleted'){
                $activity->description = trans('logs.'.$desc);
            }
        });
    }

@kikoseijo
Copy link

And if you do it on the model customise the description for an event, you can use this one:

...on Model

public function getDescriptionForEvent(string $eventName): string
    {
        return "Se ha " .trans('logs.'.$eventName) . " la exportación  #:subject.id";
    }

Happy coding!

@Gummibeer
Copy link
Collaborator

#336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants