charlieBrown's avatar

How to translate instances of Carbon?

I would like to translate the default display from $model->created_at to Portuguese. Is that possible?

In my config/app.php I have:

'locale' => 'pt',

In my pt lang folder I have these three files:

auth.php
pagination.php
passwords.php
validation.php

Where do I place the translation to Carbon instances?

0 likes
2 replies
Cronix's avatar
Cronix
Best Answer
Level 67

@ouhare that doesn't change the language used, only the format of the date. Like it will still output "Sunday" for the day of the week instead of "Domingo".

@brunofrancisco In your AppServiceProvider's register() method, you can add:

Carbon::setLocale(config('app.locale'));

Then everything should be in Portuguese globally when outputting carbon dates.

1 like

Please or to participate in this conversation.