Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 9 replies, has 2 voices.

Last updated by Eduardas 2 years, 2 months ago.

Assigned support staff: Francesco Di Candia.

Author Posts
September 15, 2017 at 6:22 am

Eduardas

Trying to import custom taxonomies and then translations using this doc:
https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/

I managed to import original and translated taxonomies into the right languages well, but the field of the translated taxonomy "this is a translation of" is always empty - translations do not connect with original language.
If I look into wp_icl_translations table, column source_language_code of translated taxonomies is NULL and trid's do not match trid's of original taxonomies.

Tried both ways for translations import - as new and as existing items.

What I am doing wrong?

Given website is for testing. Original (default) language is Lithuania (Lt).
Custom post type is Companies. Custom taxonomy is Themes.

September 15, 2017 at 9:24 am #1373025

Francesco Di Candia

Hi,
keep in mind that, when you've to import taxonomies, you've to translate and connect them, before the import job.
In our documentation
https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/
you can found a section called Importing posts with taxonomies where there is an advice about the requirement that youmust create the exact same taxonomies before the import and then, keep reading, another advice
Terms should not have the exact same name in the original and translated languages, otherwise, the import of the translated terms will not function properly. If terms have the same name in multiple languages, it is recommended that you change the name of the terms in the translated terms before import. After successful import, you could change the name of the translated term to be the same as the original term.
Furthermore in addition, at this link
hidden link
you can see a video with a how-to import correctly products using WP All Import Plugin.
With this video, you've to use these two files as an example of how to create the .xls file:
hidden link
hidden link
Please let me know if this resolves your issue or if you still need help.
Thank you, Francesco

September 20, 2017 at 5:10 pm #1378232

Eduardas

Unfortunely, your instructions demonstrates how to import posts with taxonomies, but I want to import ONLY taxonomies. It seems, that in this case something is not working - I tried all the options and formats.

September 21, 2017 at 9:24 am #1378910

Francesco Di Candia

Hi Eduardas,
I was trying to access to your site but seems that the credentials aren't working.
Can you please check it and send me information?
Thank you, Francesco

September 21, 2017 at 1:32 pm
September 22, 2017 at 8:39 am #1380076

Francesco Di Candia

Hi Eduardas,
as you can read in our documentation here
https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/
with our WPML All Import plugin, you can't import taxonomies alone but you've to import posts with taxonomies.
And, as you can read here Importing posts with taxonomies,

you must create the exact same taxonomies before the import.

Please, keep in mind also that

Terms should not have the exact same name in the original and translated languages, otherwise, the import of the translated terms will not function properly.

Please let me know if this resolves your issue or if you still need help.
Thank you, Francesco

September 22, 2017 at 9:55 am #1380161

Eduardas

Thanks for quick reply.
"you can't import taxonomies alone" - I think you must agree, that this is not logical and something that you have to improve. In my project I have over 300 terms in 5 languages and I am able to import them alone now, just missing the "connector" with default language.

If I create import file for posts with only one post having all terms assigned, will it do the job?
Could you please advice the right file format for that?

"you must create the exact same taxonomies before the import" - do you mean, that the steps should be as:

1.
create taxonomies in default language (or actually, import them alone as I did before so that they are created in default language)

2.
create file for posts in default language with one post assigned to all taxonomies + connector field.

3.
import posts to default language.
expected result:
one post in default language will be created and assigned to all terms created before.
no new terms will be created (if term names will match).

4.
create file for posts in second language with one post assigned to all taxonomies + connector field. post title and taxonomy terms should all be translated.

5.
import posts to second language using previous import file and connector field.
expected result:
new post in second language will be created and connected to default language post.
new terms in second language will be created and connected to default language terms

September 22, 2017 at 5:09 pm #1380635

Francesco Di Candia

Hi Eduardas,
we are actually working with the plugin author to have this issue solved as soon as possible, but actually isn't yet possible, I'm really sorry.
The only way to do that is connecting the translation as shown in the documentation and on attached image.
However, please, waiting for the update with the plugin author, can you check this forum thread with some workaround https://wpml.org/forums/topic/wpml-all-import-will-not-import-fr-taxonomies-when-they-exist-in-en/page/2/#post-858020.
Thank you, Francesco

September 23, 2017 at 11:19 am #1380997

Eduardas

Thanks for understanding and waiting for updates.

For now, I have managed to connect translations using this script, maybe it will be useful:

// Import taxonomy terms for each language one by one
// WPML - set language, but DO NOT define parent import
// Term Meta - set name / value as connector / {your_connector_field}
// After all terms are imported, connect translations to default language
// using this script with query params set as action=translate&taxonomy={taxonomy name}

if ($_REQUEST['action'] == 'translate') {
$taxonomy = $_REQUEST['taxonomy'];
if (!$taxonomy) return false;

$wpmlOptions = get_option('icl_sitepress_settings');
if (!$wpmlOptions) return false;

$languages = $wpmlOptions['active_languages'];
$defaultLanguage = $wpmlOptions['default_language'];
if (!$languages || !$defaultLanguage) return false;

$elementType = 'tax_' . $taxonomy;

$defaultTerms = getTermsByElementType($elementType, $defaultLanguage);
if (!count($defaultTerms)) return false;

foreach ($languages as $language) {
if ($language == $defaultLanguage) continue;
$translatedTerms = getTermsByElementType($elementType, $language);

if ($language == 'pl') pre($translatedTerms);

if (!count($translatedTerms)) continue;
foreach ($translatedTerms as $term) {
if ($defaultTerm = filterTermByConnector($defaultTerms, $term->connector)) {
updateTermTranslations($term, $defaultTerm);
}
}
}
}

function getTermsByElementType($elementType, $language) {
if (!$elementType || !$language) return false;
global $wpdb;
return $wpdb->get_results("
SELECT
translations.*,
terms.*,
tax.*,
meta.meta_value AS connector
FROM
wp_icl_translations AS translations
JOIN wp_terms AS terms ON (terms.term_id = translations.element_id)
JOIN wp_term_taxonomy AS tax ON (tax.term_id = terms.term_id)
JOIN wp_termmeta AS meta ON (meta.term_id = terms.term_id AND meta.meta_key = 'connector')
WHERE
translations.element_type = '{$elementType}' AND
translations.language_code = '{$language}'
");
}

function filterTermByConnector($terms, $connector) {
if (!$terms || !$connector) return false;
foreach ($terms as $term) {
if ($term->connector == $connector) return $term;
}
}

function updateTermTranslations($term, $defaultTerm) {
if (!$term || !$defaultTerm) return false;
global $wpdb;
return $wpdb->update(
'wp_icl_translations',
array(
'trid' => $defaultTerm->trid,
'source_language_code' => $defaultTerm->language_code
),
array(
'translation_id' => $term->translation_id,
)
);
}

I have also noticed, that even when term names are translated (at least one character is different), sometimes their slugs are the same (ą=a, e=ę=ė, etc.). In this case, when slug is already in use by the same taxonomy term IN OTHER language, that term is not created during the import, EVEN if ALL Import log shows, that all terms have been created. It took for me hours to find out why in some languages some terms were missing after import.

I had to create and connect to default language those terms manually. Also I could use the same slugs, even if they were in use in other language.

So this is something you could check and improve as well. At least to create term with slug like 'slug-1'.

September 25, 2017 at 7:40 am #1381682

Francesco Di Candia

Hi Eduardas,
thank you for your hints and understanding.
I will check your code locally and I'll report it to our developers.
Also thank you for your hint about the slug, I'll report it too together with the snippet you created.
Thank you, Francesco

September 25, 2017 at 7:46 am #1381696

Eduardas

OK.
When testing, please remove line from my code:
if ($language == 'pl') pre($translatedTerms);

it was used for debug.