Este es el foro de soporte técnico de WPML, el plugin multilingüe de WordPress.

Todas las personas pueden leerlo pero solo los clientes de WPML pueden ingresar comentarios. El equipo de WPML responde en el foro 6 días a la semana, durante 22 horas por día.

This topic contains 4 respuestas, has 2 mensajes.

Last updated by rsbA hace 1 año, 1 mes.

Assigned support staff: Yvette.

Autor Publicaciones
septiembre 27, 2018 a las 10:12 am

rsbA

Hi WPML Team,

We have some issues regarding .mo files and translations on a wordpress site.

Our site is in 3 languages, the main one (default) being Spanish.
We have setup WPML to read exclusively .mo files and avoid string translations (image hcadmbneiffccnkp.png attached)

We have developed a custom theme and made .po & .mo translations with PoEdit

on theme's functions.php file we have the following code:

-- load_theme_textdomain( 'esci', get_template_directory() .'/languages' );

And inside our partials and templates we have the following type of code to render translations:

-- <?php _e('Mes sobre', 'esci'); ?>

Our main issue is that sometimes WPML picks translations and other times it skips it showing templates half translated.

We tried removing .mo files from server, and regenerating them with PoEdit and uploading again without success.

Also seen that WPML saves the strings on DB and tried to translate from WPML panel itself but without success.

We have been trying to solve this issue by ourselves but can't understand this weird behaviour.

We would like to have support on this issue as we can't spend more time fighting it.

Thanks a lot!

septiembre 28, 2018 a las 7:10 am #2772721

Yvette
Supporter

Languages: Inglés (English ) Español (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

I´ll be helping you with this.

Could you please provide concrete examples that I can troubleshoot? If you could give a link where the text appears on the frontend and also provide the line of code where the text has been localized..that would be a dream.

Thanks

septiembre 28, 2018 a las 10:55 am #2773308

rsbA

Please find here an example:

hidden link

Under the news image and excerpt you see 2 bold text:

MES SOBRE and COMPARTIR/SHARE IT

This are found inside the partials:

/wp-content/themes/esci/single/single-tags.php and single-share.php respectively.

Here are the code for the keys inside the .po File

---------
<?php _e('Share
it', 'esci'); ?>

<?php _e('Mes
sobre', 'esci'); ?>
-----------

You will find inside each .po a different string for each translations.
On the frontend, when you change language, these strings are not shown translated.

When we update the .po and .mo files on server, nothing changes.

Thanks a lot!

septiembre 28, 2018 a las 1:37 pm #2774083

Yvette
Supporter

Languages: Inglés (English ) Español (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

There were two primary problems

1. CA
The name of the language file must match the local name of the language in WPML. For catalá, in wordpress, the language locale is simply "ca".

So, I renamed your ca_ES language file to be only "ca" for both the .mo and .po files. This fixed the CA language for Share It.

2. Mes sobre
The template files were using "Mes sobre" but the .po/.mo files had registered the string "Mes sobre:"

I added the missing ":" to the template file and this allowed the string matching and subsequent translation to happen.

I hope this resolves your issues.

octubre 3, 2018 a las 9:59 am #2784115

rsbA

My issue is resolved now. Thank you!