Language specific term has been provided by i18n_taxonomy
module which is completely independent of entity_translation
module in D7. Now in Drupal 8 d7_taxonomy_term
source plugin generating term language from entity_translation and reseting the language to site default language.
How to reproduce the issue.
You should have more than one language(D7)
In D7 install i18n_taxonomy
module. Dont install entity_translation
module.
Then edit the vocabulary and in MULTILINGUAL OPTIONS select "Translate. Different terms will be allowed for each language and they can be translated." and save.
Add term
Select any language other than site's default language
Test migrate taxonomy to D8
Check term language
Solution
We should check if taxonomy_term_data
table already has language column(added by i18n_taxonomy
) or not, if it has then we should avoid checking entity_translation table.
Please note: This is not related to translation of a taxonomy term. This is related to term that is added for a specific language in a multi language site.
Comment | File | Size | Author |
---|---|---|---|
#16 | drupal-8.9.x-term-localized-missing-source-3072784-16.patch | 1.11 KB | firewaller |
#6 | 3072784.patch | 1.35 KB | bappa.sarkar |
Comments
Comment #2
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedComment #3
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedComment #4
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedAdding a patch
Comment #5
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedComment #6
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedLatest patch
Comment #7
bappa.sarkar CreditAttribution: bappa.sarkar at Weight Watchers commentedfound a related issue https://www.drupal.org/project/drupal/issues/2979966
Comment #8
quietone CreditAttribution: quietone at Acro Commerce commented@bappa.sarkar thanks for the patch.
Is this extra check needed? The $source_language will be FALSE if entity_translation is not in use and the default language set in the source db will be used.
Moving to migration system.
Comment #9
quietone CreditAttribution: quietone at Acro Commerce commentedComment #10
Gábor HojtsyGood find! This would need test coverage.
Comment #11
Gábor HojtsyComment #13
quietone CreditAttribution: quietone commentedI believe this has been fixed in 8.9.x and 9.0.x by #3073050: Migrate D7 i18n taxonomy term field translations which now has a check to determine if entity translation is in use before using the source_language variable. So, this is probably outdated now.
@bappa.sarkar, Do you still get this problem with 8.9.x?
Comment #15
firewaller CreditAttribution: firewaller commented@quietone I am getting this problem in 8.9.x as well:
You can see the issue in \Drupal\taxonomy\Plugin\migrate\source\d7\Term::prepareRow here (comments removed for readability):
Our migrated term translations are i18n_mode = 1, which uses the default language when entity_translation isn't present. However, this should be using the ltlanguage value from d7_term_localized_translation, which I believe this issue is trying to solve.
Comment #16
firewaller CreditAttribution: firewaller commentedTo elaborate further, we migrated the term translations, but in the mapping only the "zh" mappings were present since all the sourceid2 values were "en" and "zh" destid2 was overwriting the other languages. Carrying over the correct source language resolved this for us.
Patch for 8.9.x attached.
Comment #17
mikelutzNot sure if quietone is right on this being fixed or not, but we need a failing test to prove we have a bug and a fix.
Comment #19
quietone CreditAttribution: quietone commentedI have tried again and I am still not able to reproduce. I am testing with the source test fixture, it has content for every i18n mode available for taxonomy and there are migration tests that cover all the cases, at least as far as I can tell.
The IS states
And along with the steps to reproduce this would be an i18n mode of 4. That corresponds to the vocabulary,
vocabtranslate
in the source fixture. That vocab has three terms, one in each language (en, fr, and is). Those terms are migrated correctly, the language matches the language on the source. I checked the row as well, and the language is correct.Furthermore, the fix for this, patch #6, has logic is in an if block,
!$row->hasSourceProperty('language')
, that will never be executed for the D7 source fixture because the Term table has a language column. So, what if the source doesn't have a language column? In that case the logic is, if entity translation use that language, if localized then use that language, else use the source site default language or 'en' if not set.Then in comment #15
This changes the problem to a type of translation, using the Localized translation. Currently there are two localized vocabularies is the source fixture, each with a term that is translated. The migration of the translated values is tested. The comment states the the migration should be using the ltlanguage. The migration for localized terms does use ltlangugae. The language property is changed in the prepareRow of \Drupal\taxonomy\Plugin\migrate\source\d7\TermLocalizedTranslation which is executed after parent::prepareRow($row) so the process will have the correct language.
Now, looking at git blame for parent::prepareRow($row) I see that the line setting the language was added in #3143676: Missing condition in d7_term_localized_translation source plugin causing invalid migration committed on Date: Thu Oct 8 16:26:15 2020, which is two months after #15. The relevant change is here, the setting of $language.
So, the change is in but not in Term it is in TermLocalizedTranslation source plugin.
Based on the above it looks like there is nothing to do here. The problem is the IS is not reproducible and the second problem has been fixed. I am closing this a can't reproduce based on the IS. If you are experiencing this problem just set the status to 'Active' and provide steps to reproduce.
Comment #20
quietone CreditAttribution: quietone as a volunteer commented