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

Predicted Form Field Displays Incorrect Language

Community Beginner ,
Jan 02, 2025 Jan 02, 2025

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.

 

Kattoinette_0-1735837858637.png

 

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

TOPICS
How to , PDF forms

Views

144

Translate

Translate

Report

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
Community Beginner ,
Jan 07, 2025 Jan 07, 2025

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

View solution in original post

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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 Beginner ,
Jan 03, 2025 Jan 03, 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: 

Kattoinette_0-1735917748051.png

What am I doing wrong?

Votes

Translate

Translate

Report

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

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!

Votes

Translate

Translate

Report

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 Beginner ,
Jan 07, 2025 Jan 07, 2025

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

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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 Beginner ,
Jan 07, 2025 Jan 07, 2025

Copy link to clipboard

Copied

I'm running Acrobat 24.005.20320.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Same here, and it works fine...

Votes

Translate

Translate

Report

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 Beginner ,
Jan 07, 2025 Jan 07, 2025

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Very weird, indeed...

Votes

Translate

Translate

Report

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