LaravelDaily / laravel-invoices

Laravel package to generate PDF invoices from various customizable parameters
GNU General Public License v3.0
1.39k stars 303 forks source link

Translate Carbon Date Format #224

Open dragonfly4 opened 9 months ago

dragonfly4 commented 9 months ago

This package has been translated to multiple languages. When displaying dates using the API functions it's always in English and not following the active language.

Example https://github.com/LaravelDaily/laravel-invoices/blob/a54ae4fb2bf1b8c12c9d7032612b355fb4261611/src/Traits/DateFormatter.php#L63-L66

->format follows the PHP Date Format options which always returns English.

Example with 26/02/2024

26 Feb 2024

In Carbon you can use translatedFormat to display the date in the correct language. https://carbon.nesbot.com/docs/#api-localization

 public function getDate() 
 { 
     return $this->date->translatedFormat($this->date_format); 
 } 

26 févr. 2024

Instead of using CustomData it could be useful to support this in the package.

mc0de commented 9 months ago

@dragonfly4 well pointed, I will review this at some point