Problem / motivation
D7 i18n_taxonomy module provides two different taxonomy translation concepts: 'localized terms' and 'translated terms'. In addition to this, there is also a possibility to say that all terms of give vocabulary get a 'fixed language'. See screenshot below on the vocabulary settings that i18n_taxonomy provides.
Note that the multilingual capabilities provided by i18n_taxonomy module are different than the D7 Entity Translation module.
In 'localized terms' concept, there is one term entity but the fields (title, description, possible custom fields) of this term can be translated to different languages. In other words, there is just one term ID but several translations of the fields.
In 'translated terms' concept, each language version of the term is a separate term entity with an own term ID and each term has a language code.
Proposed resolution
Put the new migration, d7_taxonomy_term_translation.yml because it requires the language module to be enabled. Add a new source plugin that will get the term language when the i18nmode is set. And add a dedicated test.
The scope of this issue is to migrate the language code of the terms from D7 to D8. The language code is stored in taxonomy_term_data.language database column.
Similar migration has already been implemented for migrating the D6 i18n_taxonomy term language codes in #2784371: Migrate D6 i18n taxonomy term translation (but not yet localized translations)
Remaining tasks
1. Patch
2. Review and test
3. Commit
User interface changes
N/A.
API changes
N/A.
Data model changes
N/A.
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | interdiff-51-57.txt | 2.15 KB | quietone |
| #57 | 2979966-57.patch | 6.43 KB | quietone |
| #51 | 2979966-51.patch | 6.3 KB | quietone |
| #51 | interdiff-49.51.txt | 775 bytes | quietone |
| #49 | 2979966-49.patch | 5.84 KB | quietone |
Comments
Comment #2
masipila commentedComment #3
masipila commentedComment #6
quietone commentedThis is using the test fixture from #3022137: Update migrate fixtures for remaining active issues which still needs some work but I am doing all the rest of the fixtures changes in one issue.
While this works it isn't clear what to do when both entity translations and i18n translation are available. So, this could be wrong.
Comment #8
quietone commentedThat is better than it looks, most of the error are because of changes that need to be removed from the fixture. There is one error related to this issue, the one in Taxonomy.Drupal\Tests\taxonomy\Kernel\Migrate\d7\MigrateTaxonomyTermTest
Comment #9
quietone commentedThis fixes the relevant test failure. The others will be fixed in the fixture issue.
I
Comment #11
quietone commentedGood, that fixed the relevant test. What this needs next is review and testing, yes, even with the failing tests. The tests will be fixed later, when the fixture has a few more additions. So setting to NR.
If you find yourself here the patch is #9 is ready for testing. If you want to review the code, look at 2979966-6-review-only.txt in comment #8.
Comment #12
papagrandeHi @quietone, I tried applying the patches in #6 and #9 to 8.6.12 and both broke taxonomy term migration. Do I need to be on 8.7.x?
Comment #13
heddnCan we get a review only patch?
Comment #14
quietone commented@PapGrande, thanks for trying to apply the patch. You will need to be on 8.8.x for the patch to apply.
Sure, the review only patch is in #8. The change in #9 was a correction to the test, that is the vid number changed, and I'd rather not make a new patch just for that one line.
Comment #15
heddnThis looks fine. Based on the IS, we've got test cases for all the scenarios. We've got data fixture changes that covers all of it.
I'm not sure though about the fixture changes that come from #3022137: Update migrate fixtures for remaining active issues. Do we need to wait until that issue lands or just commit what we have here and it will shrink in scope?
Comment #16
quietone commentedGood point. I will double check what to do in relation to #3022137: Update migrate fixtures for remaining active issues. Back to NW for that point.
Comment #17
quietone commentedReally set to NW
Comment #18
quietone commented@heddn, thanks for pointing this out.
The fixture in this patch is the same as the one over in #3022137: Update migrate fixtures for remaining active issues and it appears that the remaining data is in. An exception is #3008028: Migrate D7 i18n menu links which already has fixture changes and that one can be done later.
What should happen next is work on the fixture itself to reduce it size, it add about 250k to the fixture. Then commit that and then work on the remaining multilingual issue and hopefully not have to modify the fixture again. Therefore postponing this.
Comment #19
quietone commentedthis patch removes the fixture and replaces it with the one from #3022137: Update migrate fixtures for remaining active issues. Lets see if anything breaks.
Comment #20
quietone commentedThat's good that all tests pass. This was just an extra check that everything is OK with the new fixture. This is back to postponed.
When that is fixed the patch in #9 is to be used, or rerolled if needed. Do not use the patch in #19.
Comment #21
quietone commentedThis rerolls the patch in #9. And now we have a patch without the fixture and much easier to focus on the work being done here.
No interdiff because the reroll is removing the fixture and it would all be noise. The patch is now down to a reasonable 8k.
Comment #22
quietone commentedThis is ready for review. This was RTBCed in #15 and since then there hasn't been any code changes. What has changed is the fixture. It was committed on its own with changes from this patch, other patches and what is hoped the data for the remaining i18 patches.
Comment #23
gábor hojtsyThanks, this looks great. Some notes for naming and scoping:
Since this is about individual language codes stored on taxonomy terms, why are we scoping this to the content translation module? The Drupal 8 language module already provides this functionality (if enabled on the vocabulary).
Also, do we need the
translations:trueclause on the source for this case?This shows well that the resulting taxonomy terms are not translations in the D8 sense. Should we name this migration "taxonomy language" instead (as the issue is scoped).
And apply that then to the ID and the label.
Comment #24
quietone commentedThink you are right about that. This fixes the above #1 and #2.
Comment #25
heddnIs this still needed? I think the parent now comes through on the entity in 8.6+. Leaving at NR if my question is wrong.
Comment #26
pieterdc$row->get() is not supported yet in Drupal 8.6.x
Adapted that call to $row->getSourceProperty() to be able to use the patch on Drupal 8.6.x
Based on the patch from comment #24.
See attached.
Comment #27
pieterdcAccidentally uploaded the patch with .txt extension. Corrected it to the .patch extension.
Comment #28
gábor hojtsyThis will not be backported to 8.6.x, so that change is not helpful unfortunately.
Comment #29
quietone commented25.1 - I don't know about the parent coming through in 8.6 but removing that code causes the tests to fail, as shown in the attached fail patch.
Comment #31
quietone commentedRe uploading the successful patch from #24 for convenience.
Comment #32
heddnObviously we don't get the right structure from parents. All feedback is now addressed.
Comment #33
alexpottCommitted and pushed 81543e1755 to 8.8.x and 379763d5e5 to 8.7.x. Thanks!
Comment #36
quietone commentedThis is causing failures in the UI tests of the complete upgrade in commerce migrate. It is because this is tagged Multilingual and in the taxonomy directory. Maybe the following changes are needed as well as rerolling #2936365: Migrate UI - allow modules to declare the state of their migrations.
Remove?
Remove?
Comment #37
gábor hojtsyHm, why would this not be a multilingual migration?!
Comment #38
quietone commentedWell, you pointed out that the resulting taxonomy terms are not translations in the D8 sense. So they are some other category. What are they?
The practical problem is that now if one has taxonomy installed then this new migration is found. And then if you want to migrate a source site that is not multilingual you will still have to install migrate_drupal_multilingual. That does not make sense and I should have caught that earlier.
When the Multilingual tag is found and migrate_drupal_ui is not installed an error is thrown and user gets a message the migrate_drupal_multilingual must be installed to continue. This is why it is convenient to have all the migrations tagged Multilingual in content_translation or config_translation. Though, as you point out, having this migration in content_translation isn't quite right either but it is a possible solution.
This could also go into language, which maybe should be the destination_module. But it is very late and I could be writing nonsense.
Comment #39
quietone commentedThought about this a bit this morning from the perspective of using the UI. Say I am migrating a non-multilingual site and have taxonomy enabled. I will get an error stating that I need to install migrate_drupal_multilingual in order to run d7_taxonomy_term_language.yml. Since my site doesn't need that I just want to run all the other migrations. But in the UI there is no way to proceed without enabling migrate_drupal_multilingual. And changing that requires a new form to ask the question as well as changes to the logic that gets the migrations that are to run. Is that what needs to be done? What other ways to address this?
I think this needs to be reverted because folks need to install migrate_drupal_multilingual to migrate a site that is not multilingual.
Comment #42
quietone commentedTalked briefly with mikelutz in Slack about this.
For me, the key point is that the "core UI doesn’t really offer meaningful support for partial migrations atm," There is an issue to add support for doing Content or Configuration migrations only and that has problems as well. However, it is the closest we have to what I think is needed here and there is a patch over there as well. I think it is worth looking at #2826742: Expose migration types in Migrate UI.
Comment #43
gábor hojtsy@quietone so this is a thing that got refined in Drupal 8. In Drupal 7 you need to enable locale module and i18n to assign language to taxonomy terms, so it is quite deep in being multilingual. In Drupal 8, you only need to enable the language module if the languages being assigned are other than English. That could be a monolingual site in Spanish let's say but it requires infrastructure for multilingual (language module in D8 and locale+i18n modules in D7). So to me it looks a bit closer to the borderline but still multilingual :) It is not a translation thing, but multilingual is not just translations :)
Comment #44
quietone commentedOK. I think the thing to do here is to move the move the migration to language, since language needs to be enabled, and remove the Multilingual tag.
No interdiff since this is a smallish patch.
Comment #46
quietone commentedSince d7_taxonomy_term.yml has the audit key I've added it to d7_taxonomy_term_translation.yml as well. And it seems the test has a list of migrations with audit set, so the new migration has to be added to that MigrateDrupal7AuditIdsTest.
Comment #47
quietone commentedHi folks, this is ready for review.
Comment #48
gábor hojtsyHm, this patch does a WHOLE LOT MORE than just transporting the language value. It seems to be doing entity translation support, title module support, field translatability support, etc. That is like 3 different ways to translate stuff on terms. The tests don't seem to reflect that complexity.
At the same time the title of the issue and this summary snippet says very different about the scope:
IMHO it is great that we can support those migrations as well, but then we need to cover with tests and update the issue summary for clarity.
Comment #49
quietone commentedThanks for the review. It got me to start over and what I saw is duplication. With many of the migration of translation it starts with building on the existing migration for the entity involved so that is what I did. The existing d7_taxonomy_term migration already includes the language property and the source plugin has logic to determine the language to use based on the default language and if entity translation is enabled. All this needs to do is add logic to use the i18n language, if it is available, to the source plugin. And MigrateTaxonomyTerm test has been modified to test the language field.
The patch is much smaller and the interdiff is full of deletions.
Because this is now reduced in scope I removed the Needs issue summary update tag.
Comment #51
quietone commentedOops, accidentally removed the change to the Term source plugin.
Comment #52
gábor hojtsyThis patch looks good! Thanks for focusing on scope!
Is entity translation support, title module support and field translatability support then a separate issue? I think its fine to focus this on term language, we can get it in nice and neat, but then we should have those translations represented somehow, because unless they somehow already got in in other issues, they will still be missing features. And the implementations looked fine, there was just missing tests :)
Comment #53
quietone commentedThe entity translation seems to be done already. There is a d7_taxonomy_term_entity_translation.yml file. This migration is run in the existing d7/MigrateTaxonomyTermTest.php and there is a test method testTaxonomyTermEntityTranslations. It was done in #2980996: Migrate Drupal 7 taxonomy term entity translations data to Drupal 8. That would have been maxocub who did the entity translation work.
The title module support is already in the prepareRow method of the Term.php source plugin.
Not sure about 'field translatability', so I'd like to move that to a follow up issue. Setting to NW to make this issue.
Comment #54
quietone commentedFollow up made, [#3073050,] and there is nothing else to do here so back to NR.
Comment #55
gábor hojtsyThanks for adjusting the scope here, much simpler and indeed now fulfills the mission set out in the issue summary. Looks very straightforward. Thanks!
Comment #57
quietone commentedSo, when the i18n_mode is localized we want to use the default language, not the language in the row.
Comment #58
Gnanasampandan Velmurgan commentedThis patch focusing on migrate the language code of the terms from D7 to D8. Thanks for above patch.
Comment #59
gábor hojtsy@quietone: can you upload an interdiff please?
Comment #60
quietone commentedSorry, forgot to upload it.
Comment #61
quietone commentedAnd now that the migration is returning the correct language for the localized term, the test needs to change to use that language. Which makes sense that it would be the default language and not 'und'.
Comment #62
gábor hojtsyMakes total sense. The postgres test had 2 fails above, but one was from #3008029: Migrate D7 i18n field option translations where it got fixed since then. So that should not reappear randomly anymore. Thanks!
Comment #63
larowlanCommitted 32f4d3e and pushed to 8.8.x. Thanks!
Comment #66
xjmI think we should highlight a list of all the significant improvements to multilingual migrations in 8.8 (whether or not the module stabilizes in this release). Tagging accordingly.