Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Predicted Form Field Displays Incorrect Language

Explorer ,
Jan 02, 2025 Jan 02, 2025

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.

 

Kattoinette_0-1735837858637.png

 

PLEASE help me fix this. It's driving me nuts.

TOPICS
How to , PDF forms
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Explorer ,
Jan 07, 2025 Jan 07, 2025

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

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2025 Jan 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 03, 2025 Jan 03, 2025

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

Kattoinette_0-1735917748051.png

What am I doing wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2025 Jan 03, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2025 Jan 07, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2025 Jan 07, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2025 Jan 07, 2025

I'm running Acrobat 24.005.20320.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2025 Jan 07, 2025

Same here, and it works fine...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2025 Jan 07, 2025

Very weird. The code you gave me last time for predicting the date worked beautifully, but this one was a real pain.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2025 Jan 07, 2025
LATEST

Very weird, indeed...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines