2

This is my first time deploying a site in Netlify. I'm using Jigsaw in order to achieve this.

Everything is ok, besides the date language that is exported in production.

When I generate my production site locally it works fine displaying the date in Spanish:

Kenny Horna's blog: Date displaying in Spanish

I'm not uploading the same exact files to netlify but using the netlify.toml to run the same command in order to generate the same files:

# netlify.toml

[build]

command = "npm run production"
publish = "build_production"
environment = { PHP_VERSION = "7.2" }

But in production, the site is displaying the month in English:

Kenny Horna's blog: Date displaying in English

You can check it live here.

Note

To display the date I'm doing this:

@php(setlocale(LC_ALL, 'es_ES'))

<p class="text-gray-700 text-md md:mt-0">
{{ $page->author }}  • {{ strftime("%d de %B, %Y", $page->getDate()->getTimestamp()) }}
</p>

Have you ever experienced something like this?

Thanks in advance for the help.


Update

Modified the netlify.toml to this but still without any luck:

[build]

command = "npm run production"
publish = "build_production"

[context.production.environment]
PHP_VERSION = "7.2"
LC_ALL = "es_ES"
Kenny Horna
  • 13,485
  • 4
  • 44
  • 71

2 Answers2

4

Probably setlocale is not working. Since the same code works on your machine it is possible that Spanish locale is not installed on hosting machine. See this question: https://stackoverflow.com/a/10910009/529024.

Also, setlocale returns the new current locale, or FALSE if the locale functionality is not implemented on your platform, the specified locale does not exist or the category name is invalid. setlocale

So in this case you could check the return value and see if the local has changed.

Kalimah
  • 11,217
  • 11
  • 43
  • 80
0

The way that worked (thanks to the link provided by Kalimah Apps) was to change this:

@php(setlocale(LC_ALL, 'es_ES'))

To this:

@php(setlocale(LC_ALL, 'es_ES.UTF-8'))

Now is working as it should.

Kenny Horna
  • 13,485
  • 4
  • 44
  • 71