Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ivanhalen's avatar

Date localization in Homestead: "xx_XX" vs a simple "xx"

Hello, I just installed Homestead and was playing around with date localization. Since I need Italian dates, I installed the Italian language pack: sudo apt-get install language-pack-it

Laravel docs talk about a two letters locale configuration like en or es but when I type locale -ain the Homestead Ubuntu machine I get languages as xx_XX (with or without .utf8 extension) and, in the case of Italian language, I get both it_IT.utf8 and it_CH.utf8(the Switzerland flavor): but no itlanguage, as Laravel doc state.

Of course, if I use APP_LOCALE=itin my .env file, I have no Italian dates, but English ones; I am forced to use APP_LOCALE=it_IT.utf8 that is less than ideal (especially if I have to use it in the URLs)

I read around some sort of workaround like setlocale(LC_ALL, strtolower(config('app.locale')) . "_" . strtoupper(config('app.locale')) . ".utf8");: is this the correct way to handle the whole situation? Seems a little odd, am I missing something?

0 likes
0 replies

Please or to participate in this conversation.