October: Date in French (day and month)

Created on 15 Nov 2018  路  12Comments  路  Source: octobercms/october

Expected behavior

Date in french : Jeudi 15 Novembre 2018, 12:09

Actual behavior

Thursday 15 November 2018, 12:09

Reproduce steps

fresh install
app.config timezone="Europe/Paris"

 setlocale(LC_TIME, 'fr_FR');
 echo strftime('%A %d %B %Y, %H:%M');

the time is working, but not the translation of day and month
i have try lot of solution, but no one working (with DateTime, strfotime, etc)

October build

443

Question

Most helpful comment

@Dreanad add use October\Rain\Argon\Argon;

All 12 comments

@Dreanad could you also post the way you try to use it? Or example (image)?

@Dreanad first thing:

DO NOT set app.timezone to anything other than UTC. Doing this is just asking for headaches. Instead, use cms.backendTimezone to set the default timezone in the backend.

Second thing: Use the backend preferences to set your locale (or the config file), don't set the locale in code directly like that, that bypasses all of the tools October has for dates / times.

@w20k http://www.noelshack.com/2018-46-4-1542311840-capture.jpg
http://www.noelshack.com/2018-46-4-1542312015-capture2.jpg

I think i use DateTime in the wrong way

@LukeTowers Ok, i put in back in UTC, for the setLocale, that was just for test, i use Config to get the values otherwise, and i have set backend timezone, thank you for your advice !

@Dreanad if you want to interact with dates directly in PHP then use the Argon class which indirectly extends Carbon: https://github.com/octobercms/library/blob/master/src/Argon/Argon.php

@LukeTowers I'll look at Argon, thank you, Carbon cant do the job ?
I need french in view, not in PHP

Carbon can, Argon just automatically sets the locale defined by OctoberCMS for you.

Thank you, im trying, but i have a class not found on Argon ( i try to use it in plugin.php)
Argon::setArgonLocale(\Config::get('app.locale'));

so i have tested with just Jenssegers\Date\Date; and seems to be ok ! i have date in french when i use the Date class, its ok to used that class rather than carbon or argon ?

by the way, what is an umbrella class ? I've never heard of it, maybe different name in french ..

@Dreanad You don't need to call the setLocale method, Argon does it itself when constructed. Umbrella class just refers to it extending the actual classes doing the work so that if the behind the scenes classes ever needed to be changed out, references to Argon would still work fine, mixed with a bit of initialization / configuration logic based on the application (i.e. setting the locale)

@Dreanad ping me, if you still haven an issue, might look at it on weekends! ;) But I guess, should be fine by now!

@LukeTowers So how to call Argon construct, i still have the class not found
thanks for your explanation, It's already clearer to me

@w20k Yeah, i finally see the end of it ! Thanks you for your help here and on Slack !

@Dreanad add use October\Rain\Argon\Argon;

@LukeTowers ok Argon twice, thats working ! thank you a lot for your help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atrauzzi picture atrauzzi  路  3Comments

lukaszbanas-extremecoding picture lukaszbanas-extremecoding  路  3Comments

jvanremoortere picture jvanremoortere  路  3Comments

m49n picture m49n  路  3Comments

axomat picture axomat  路  3Comments