1

The problem:

When I use org-capture to write on my journal, it writes the month as April and the day as Friday. But everything in my system is in Portuguese, so it should be "abril" for the month, and "sexta-feira" for the day.

Org-agenda uses the names in Portuguese correctly.

format-time-string outputs in English instead of Portuguese.

Worse, this behavior started yesterday when I rebooted my computer. It did work fine before.

My OS: Windows 10, with the latest updates.

What I've tried:

1) Setting calendar variables like calendar-day-name-array and others have already been set and the buffer re-evaluated. I checked that those are the current values of those variables. NOTHING CHANGED.

2) I looked at Display months/days or timestamps in another language than English and checked if I had any LANG environment variable on Windows. I do not. NOTHING TO DO HERE.

3) I called set-language-environment and set it to Brazilian Portuguese. It was already portuguese before, but I did it again. NOTHING CHANGED.

I don't know what else to try. Tips?

Edit:

The weird thing is that THIS is what shows up when I use org-capture with a datetree:

enter image description here

The calendar itself is in portuguese, but the bottom line shows the date I picked in English. And it's captured in English.

  • I don't know if this is what I want. I don't want a custom time format, I want default time format... in Portuguese. As I already had up to a few days ago. – Leonardo Bighi Lourenço Apr 4 at 11:48
  • the key is here: "Org mode uses the standard ISO notation for dates and times as it is defined in ISO 8601" AND "Org mode needs the default format for scanning, so the custom date/time format does not replace the default format. Instead, it is put over the default format using text properties." So looks like what you want to achieve isn't possible "as is". – Muihlinn Apr 4 at 12:15
  • You're still mistunderstanding what I want. I don't want a custom format at all. I want the default format in Portuguese. And I've been using the default format in portuguese since I started using Emacs in 2013. People can use it in other languages, and they do. It stopped working a few days ago. I don't know if it was because of an Emacs update, package update, or Windows update. Or maybe I changed anything in my config, or in an environment variable. But if it worked for years, it can work again. – Leonardo Bighi Lourenço Apr 4 at 18:21
  • I'm afraid not, I do understand what you want, but what I do understand from the manual is that the date should be ISO 8601 and cannot be changed in order to keep the functionality, only masked by a custom format. Can't tell you more, I never felt the need to change the date format. – Muihlinn Apr 4 at 18:35
1

The culprit is the calendar code: it needs special treatment. See Calendar Localization in the Emacs Wiki. You need to add this code

(setq calendar-week-start-day 0
          calendar-day-name-array ["Domingo" "Segunda" "Terça" "Quarta" 
                                   "Quinta" "Sexta" "Sábado"]
          calendar-month-name-array ["Janeiro" "Fevereiro" "Março" "Abril"
                                     "Maio" "Junho" "Julho" "Agosto"
                                     "Setembro" "Outubro" "Novembro" "Dezembro"])

to your init file before calendar and org-mode are loaded.

EDIT: as the OP points out, he's already done the above. I also missed another point which may be crucial: format-time-string formats things in English.

I have two machines (both running Fedora 31): in one, I had to do two things to get it to do what the OP wanted:

  • set the LANG environment variable and the LC_ALL environment variable (I set them to fr_FR.utf8 but Portuguese should not be any different).
  • I started emacs with the above initialization and a minimal org file: emacs -q -l calendar.fr.el -l minimal.org.el to make sure that no other initialization was messing things up

With that, I can get dates in French in my org files.

But when I tried the same thing on my other machine, and tried to set LC_ALL=fr_FR.utf8 I got an error that the locale is not supported and trying to start emacs as above gave me this error:

(process:214680): Gtk-WARNING **: 12:35:52.749: Locale not supported by C library. Using the fallback 'C' locale.

The fallback 'C' locale does everything in English, so maybe that's what's causing format-time-string to speak English in the OP's case also. I installed the French langpack on this Fedora system with:

dnf install langpacks-fr

and now after restarting emacs as above, format-time-string does French:

(format-time-string "%B %A" (current-time))
"avril samedi"

Unfortunately, I don't do Windows, so I cannot help any further. And it may be that the OP's problem is all together different, but the telltale sign of format-time-string doing English strongly suggests to me that emacs is falling back to the C locale for some reason.

| improve this answer | |
  • Look at my number 1 in the "What I've tried" part. I've already set these variables. – Leonardo Bighi Lourenço Apr 4 at 11:45
  • Apologies for not reading a bit more carefully. I edited the answer to add some observations and thoughts. They still might not solve your problem, but the format-time-string behavior suggests to me that something is missing (as in my case, the French langpack was missing from the C library), and emacs is falling back to the C locale. I hope this helps somebody figure out what to do on Windows, so I'll leave it up for now. If it turns out that I'm completely off the mark, I'll eventually delete this answer. – NickD Apr 4 at 17:12
  • Wow, that's a very thoughtful answer. I'll read it carefully and reply later. – Leonardo Bighi Lourenço Apr 4 at 18:19
  • For some reason, I had an environment variable LC_ALL with the value "C", in Windows. I deleted it and set a variable LANG to "pt_BR.UTF-8". I had to close and reopen Emacs TWICE for it to work (don't know why), but now it's fixed. Thank you! – Leonardo Bighi Lourenço Apr 5 at 15:03
  • Glad you got it fixed! – NickD Apr 5 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.