This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 16 replies, has 2 voices.

Last updated by Carlos Rojas 2 months, 3 weeks ago.

Assigned support staff: Carlos Rojas.

Author Posts
July 24, 2019 at 2:32 pm #4275641

tomM-24

Hello – sorry for duplicating this support ticket, but my previous thread was closed before I had a chance to reply and I need further assistance.

This is my original question:

I'm trying to display dates in different languages and was under the impression that this would happen automatically as WPML would use the translation files for wordpress itself.

However this is not working.

Something like this always returns the default language (english).

<?php echo date('l \t\h\e jS');?>

Your colleague suggested I use
https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

But I'm not really sure how this applies to dates... can you expand on this please?

July 24, 2019 at 3:09 pm #4276023

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hello,
Let's continue in this way with the issue.

1.- Could you provide an example on where do you want to show the dates? This will give me a context and it should be easier to determine the best way to show the translated date.

2.- Please increase the PHP Memory Limit. Minimum requirements are 128Mb: https://wpml.org/home/minimum-requirements/
You can add this to wp-config.php to increase WP memory:

/** Memory Limit */
define('WP_MEMORY_LIMIT', '128M');
define( 'WP_MAX_MEMORY_LIMIT', '128M' );

- Add it above the line /* That's all, stop editing! Happy blogging. */

Kind regards,
Carlos

July 24, 2019 at 3:15 pm #4276063

tomM-24

Hi Carlos,

Thanks. In response:

1. I need to display the start date of events using this plugin:

hidden link

and the following code:

<?php echo eo_get_the_start('l') . ' ' . eo_get_the_start('d/m/Y');?>

Basically I just need the week day to be translated into the current language . At the moment it still outputs in English.

2. Sure will do

July 24, 2019 at 3:21 pm #4276075

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,
Thank you very much for your feedback.

I have visited our Multilingual-Ready Plugins list (https://wpml.org/documentation/plugins-compatibility/) and I couldn't find this plugin, which means that our compatibility team hasn't validated it yet.

I recommend you to contact the plugin's authors and let them know about this issue, because I can see that they use their on functions (eo_get_the_start) to retrieve the dates. Maybe in the code of the function "eo_get_the_start" they will be able to add the localization support and will solve your issue.

Regards,
Carlos

July 24, 2019 at 3:25 pm #4276089

tomM-24

But even when I test out just getting the post date:

<?php echo get_the_date('l d/m/Y')?> 

it outputs in English NOT the selected language.

Could you help with that?

I was using the free version of one of your competitor's plugins and it worked without any configuration.... but I decided I would pay for this one as it seemed to have better functionality overall.

July 24, 2019 at 3:33 pm #4276143

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,

Could you confirm that you followed the steps described in this link: https://wpml.org/documentation/getting-started-guide/translating-your-sites-date-format-using-wpml/

Regards,
Carlos

July 24, 2019 at 3:37 pm #4276153

tomM-24

In my WPML menu there is no option for 'String Translation'

July 24, 2019 at 3:39 pm #4276157

tomM-24

But also I don't want to change the format – the format will stay the same.

I want to TRANSLATE the days from one language to another e.g.:

'Monday' would become 'Lunes' etc...

July 24, 2019 at 3:47 pm #4276249

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,

You need to install the String Translation plugin to be able to translate the strings in the site, including the dates. Could you install String Translation and follow the steps to translate the dates?

Note: If you don't desire to change the format of the dates then skip that step and only search and translate the name of the days of the weeks and months.

Regards,
Carlos

July 24, 2019 at 3:50 pm #4276257

tomM-24

So I have to upgrade just to do that?

Can I make an .mo file myself?

July 24, 2019 at 3:54 pm #4276271

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,

If you have the Multilingual Blog account then you can update to Multilingual CMS account and have all the options of WPML available or you can create the .mo/.po file too.

Regards,
Carlos

July 24, 2019 at 3:57 pm #4276277

tomM-24

Sorry – I still don't think you're answering my question.

If I upgrade will this code:

<?php echo get_the_date('l d/m/Y')?> 

Automatically output 'Monday' or 'Lunes' depending on the language selection?

July 24, 2019 at 3:58 pm #4276285

tomM-24

Can you test that out?

July 24, 2019 at 4:09 pm #4276321

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,

I created a test site with WPML plugins installed and English as default language and Spanish as the secondary language. You can access the backend of the test site using this link: hidden link

I added this code in page.php file:

echo '<h1>This is the date test:</h1><br>';
echo get_the_date('l d/m/Y');

The dates are automatically translated, you can see the test in this links:
- hidden link (English)
- hidden link (Spanish)

Regards,
Carlos

July 24, 2019 at 4:11 pm #4276325

tomM-24

Great thanks – I will buy the upgrade then.

Thanks for running the test for me.

Best,

Tom