adhik13th's avatar

How to set locale location on laravel

i browsing how to add and set locale global on laravel . i add this line on app/Providers/AppSserviceProvider.php

public function boot()
{
    config(['app.locale' => 'id']);
    \Carbon\Carbon::setLocale('id');
}

i want to change datetime 'F' to indonesian language ( January to Januari .. etc)

but this line on function boot didnt work , anyone have solution ?

0 likes
7 replies
adhik13th's avatar

my timezone is update to my local area , but this month . like January its not changes . how ?

adhik13th's avatar

on config . i set all on id like this this time on my input is change ( true on my time location) but this month not changes to indonesian language

 'timezone' => 'Asia/Jakarta',

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/

'locale' => 'id',

/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/

'fallback_locale' => 'id',

/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/

'faker_locale' => 'id_ID',
tisuchi's avatar

@adhik13th

What do you mean by this?

my timezone is update to my local area , but this month . like January its not changes . how ?

adhik13th's avatar

if i input some data , if i not change this config , this data on created_at field will be follow date on en , but i change to id , id_ID its follow my true date now .

fylzero's avatar

@adhik13th

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Localization Carbon

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

Also when you format dates... use...

\Carbon::parse('2019-03-01')->formatLocalized('d F Y');
24 likes

Please or to participate in this conversation.