Skip to main content
Inspiring
January 2, 2025
Answered

Predicted Form Field Displays Incorrect Language

  • January 2, 2025
  • 1 reply
  • 1065 views

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.

Correct answer Kattoinette

- 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!


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();

1 reply

try67
Community Expert
Community Expert
January 3, 2025

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

Inspiring
January 3, 2025

Okay, I'm going to need you to dumb it down for me. Here's what I have currently: 

What am I doing wrong?

try67
Community Expert
Community Expert
January 3, 2025

- 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!