In inc/Wpml2mlp_Helper.php the function get_language_info() retrieves the language for the given post. The SQL retrieves the first entry it gets by the post ID from the database. However, in the wp_icl_translations table there can be more than one entry for the post ID, with a different element_type, on grown WPML installations:
As you can see in the above screenshot, the row with the element_typecomment has a different language_code as the second entry, which is the one we need. As in the get_language_info() function the SQL only gets the first row, the exported XLIFF files are completely mixed up with wrong entries on each language file.
To do: The SQL does not only need to check on the correct post ID, but also on the correct post type. In the function get_all_posts() of the inc/Wpml2mlp_Helper.php file, the post types are selected and used to retrieve the posts needed for the export. The same get_post_types() function can be used to check on all possible post types within the wp_icl_translations table for retrieving the correct language of each post.
In
inc/Wpml2mlp_Helper.php
the functionget_language_info()
retrieves the language for the given post. The SQL retrieves the first entry it gets by the post ID from the database. However, in thewp_icl_translations
table there can be more than one entry for the post ID, with a differentelement_type
, on grown WPML installations:As you can see in the above screenshot, the row with the
element_type
comment
has a differentlanguage_code
as the second entry, which is the one we need. As in theget_language_info()
function the SQL only gets the first row, the exported XLIFF files are completely mixed up with wrong entries on each language file.To do: The SQL does not only need to check on the correct post ID, but also on the correct post type. In the function
get_all_posts()
of theinc/Wpml2mlp_Helper.php
file, the post types are selected and used to retrieve the posts needed for the export. The sameget_post_types()
function can be used to check on all possible post types within thewp_icl_translations
table for retrieving the correct language of each post.