Copy link to clipboard
Copied
Thanks to this lovely community, I have a document that automatically predicts and populates a date in the future. Now it's time to translate that into Spanish, and I've run into some hiccups.
First- I am not a Spanish speaker. I have someone else check my work. I need the program to remain in English; I only need to change the document language. I already have it set to Spanish for this document.
PLEASE help me fix this. It's driving me nuts.
Copy link to clipboard
Copied
My best guess is that I'm missing a language pack or something, because it just absolutely refuses to work. A friend of mine sent me this code that finally worked. It's not elegant, but it works!
var d = new Date(); d.setDate(d.getDate() + 33);
var daysES = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
var monthsES = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubure", "Noviembre", "Diciembre"];
this.getField("FutureDate").value =
daysES[d.getDay()] + ", " +
d.getDate() + " " +
monthsES[d.getMonth()] + ", " +
d.getFullYear();
Copy link to clipboard
Copied
There are a couple of ways of doing it. You can use the built-in locale option of the printd method, but it doesn't support day names. You will need to add those manually, which is not too difficult to do.
Here's the basic code:
util.printd("date(es){DD MMMM, YYYY}", new Date(), true)
This will print out:
03 enero, 2025
If you want to add the day name before it you can use this:
var daysES = ["domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"];
daysES[new Date().getDay()] + ", " + util.printd("date(es){DD MMMM, YYYY}", new Date(), true);
This will print out:
viernes, 03 enero, 2025
Copy link to clipboard
Copied
Okay, I'm going to need you to dumb it down for me. Here's what I have currently:
What am I doing wrong?
Copy link to clipboard
Copied
- Move the setDate command before the command that applies the value to the field.
- Change new Date() to d in the line that applies the code to the field.
NB. In the future, post your code as text, not as an image!
Copy link to clipboard
Copied
My best guess is that I'm missing a language pack or something, because it just absolutely refuses to work. A friend of mine sent me this code that finally worked. It's not elegant, but it works!
var d = new Date(); d.setDate(d.getDate() + 33);
var daysES = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
var monthsES = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubure", "Noviembre", "Diciembre"];
this.getField("FutureDate").value =
daysES[d.getDay()] + ", " +
d.getDate() + " " +
monthsES[d.getMonth()] + ", " +
d.getFullYear();
Copy link to clipboard
Copied
No language pack is needed for this to work. What version of Acrobat or Reader are you running it in?
But anyway, that code should work as well.
Copy link to clipboard
Copied
I'm running Acrobat 24.005.20320.
Copy link to clipboard
Copied
Same here, and it works fine...
Copy link to clipboard
Copied
Very weird. The code you gave me last time for predicting the date worked beautifully, but this one was a real pain.
Copy link to clipboard
Copied
Very weird, indeed...