Month translation in portuguese (BR)

Hi! I just upgraded my journal from 2.4.6 version to 3.2.0-1.
After hours of dedication to correct various errors and data problems, I got it!

Now, I’m trying to put everything on the right place and one thing is driving me crazy: every time it has a month on text, like “September”, the text is always in english, besides the translation of every else on the page, the month is never translated. In my language, It needs to be “Setembro”.

Sorry about my english. It’s not my first language.
Thanks in advance. Can you help me?

Observation: to correct many errors in locales, I manage to copy the folders “locale” and “registry” from a blank install of OJS 3.2.0-1 on top of my upgraded journal. This solved a lot of problems I had before it, like JqueryUI, MCE editor, buggy views, and a various number of warnings and notices in PHP. Now, everything is fine on journal, except these months, that is never translated.

A print follows to contextualize:
image

Hi @Roger_Santos_Ferreir,

OJS uses (via the Smarty date_format modifier) PHP’s strftime function. We’re using PHP’s setlocale function to properly tell PHP what language you’re using, so I suspect it’s the underlying server environment that doesn’t have the Portuguese language installed/built. See stackoverflow.com: setlocale and strftime not translating month for details. For example, on my Ubuntu-based system, I have to use the locale-gen command as documented in the StackOverflow thread.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec! Thank you for your suggestion.
I already tried to set the correct values in setLocale. See:

image

I tried to change to only “pt_BR” too, see:
image

This is the response from command locale in my server.
What can I do more to solve this problem?

locale -a show me this:
image

One more thing: I tried a blank php page on my server and the response from this code:

setlocale(LC_TIME, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
echo strftime('%A, %d de %B de %Y', strtotime('today'));

is: Friday, 10 de April de 2020! The day and the month isn’t translated!

The output from command date is:
image
That is correct! Sexta-feira, abril, 10!

I will try to search things about Smarty (I don’t know this technology yet)
Thanks in advance.

Hi @Roger_Santos_Ferreir,

I think everything is fine in the code, but your server doesn’t have the pt_BR locale files generated, so it falls back on English. That’s the role of the locale-gen command in the link above.

Regards,
Alec Smecher
Public Knowledge Project Team

Alec,
I’ve tried a lot o things to solve this. But without success.
There is my final situation:

image

I’m using a Debian 9 server and the command dpkg-reconfigure locales call the locale-gen after it finishes.

I don’t know what can we do more!
Thanks, anyway.

Hi @Roger_Santos_Ferreir,

I’d suggest continuing to work with a bare PHP test script, to keep things simple. Don’t forget that you’ll probably need to restart your Apache service after changing the locale configuration on your server.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec and everyone!
Anyway, I managed to solve my problem.
I tried everything you can find on the internet and on forums spread around.
For those who are still struggling with their server with this problem, I followed the tips from: Configure System Locale on Debian 9 - RoseHosting (since my server is a Debian 9).

Finally, I understood that restarting the Apache server was not enough.
The final solution was: restart php-fpm!

My test script is below, to help those who still have problems:
image

The last echo command needs to show something different from false.
This is it!

Thanks Alec for yout time and help!
Hope it can help enyone.

1 Like