Problem/Motivation
On #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms, we found that vocabulary vocabulary settings from the i18n Taxonomy translation module are not being migrated.
On a D6 site with this module enabled, the Vocabulary page has a "Multilingual options" section of the settings that looks like this:
D6 data source
The multilanguage mode is saved in variable i18ntaxonomy_vocabulary
. The structure is an associative array of $vid => $mode
and here are the mode options and constant values:
// this is i18ntaxonomy_vocabulary_options():
return array(
I18N_TAXONOMY_NONE => t('None. No multilingual options for this vocabulary.'),
I18N_TAXONOMY_LOCALIZE => t('Localize terms. Terms are common for all languages, but their name and description may be localized.'),
I18N_TAXONOMY_TRANSLATE => t('Per language terms. Different terms will be allowed for each language and they can be translated.'),
I18N_TAXONOMY_LANGUAGE => t('Set language to vocabulary. The vocabulary will have a global language and it will only show up for pages in that language.'),
);
// and the constants are defined as:
// No multilingual options
define('I18N_TAXONOMY_NONE', 0);
// Run through the localization system
define('I18N_TAXONOMY_LOCALIZE', 1);
// Predefined language for all terms
define('I18N_TAXONOMY_LANGUAGE', 2);
// Multilingual terms, translatable
define('I18N_TAXONOMY_TRANSLATE', 3);
The D6 can also have a language if (and only if) the multilanguage mode is set as 'Set language to vocabulary'. D6 UI forces an empty value to this drop down list if any other multilanguage mode is selected. The language is saved in D6 database in vocabulary.language column.
'Localized terms' concept
The data model in D6 is illustrated in the picture below.
- The node translations are separate nodes but they are both pointing to the same term.
- There is only one term entity, but the title and description of the term can be translated in D6.
The D8 equivalent to this concept is shown in the picture below.
D6 'per language' concept
The data model in D6 is illustrated in the picture below.
- The node translations are separate nodes.
- There are two separate term entities which may be linked together as translations of each other but the translation link does not necessarily exist.
The closest D8 equivalent to this concept is shown in the picture below.
- There is a conceptual difference between D6 and D8.
- In D6, the different taxonomy term entities can be linked as translations of each other but in D8 they can not be linked like in D6.
- The data model described in the picture above is the closest equivalent in D8.
D8 vocabulary settings
The D8 vocabulary settings are shown in the picture below.
The 'Term language / Default language' corresponds to the D6 vocabulary language.
Note that the vocabulary itself has a language in D8. This is not related to the D6 language settings, the 'Language' field of D8 can be used to indicate the language of the vocabulary so that the vocabulary name and description can be translated.
Proposed resolution
Common mapping to all multilingual modes
- D8 vocabulary term default language: Migrate from D6 vocabulary language if it is set. Otherwise migrate to site default language.
- Note: this does not impact the language of the terms to be migrated, only new terms that will be created in D8.
D6 'No multilingual options for this vocabulary' setting
Test vocabulary: tags, forums and type
- D8 vocabulary 'Show language selector on create and edit pages': FALSE
- D8 vocabulary 'Enable translation': FALSE.
- D8 content type field settings for the term reference 'Users may translate this field': FALSE
D6 'localize terms'
Test vocabulary: vocabulary 3 (i=2)
- D8 vocabulary 'Show language selector on create and edit pages': TRUE
- D8 vocabulary 'Enable translation': TRUE
- D8 content type field settings for the term reference 'Users may translate this field': FALSE
D6 'per language terms'
Test vocabulary: vocabulary 1 (i=0)
- D8 vocabulary 'Show language selector on create and edit pages': TRUE
- D8 vocabulary 'Enable translation': FALSE.
- D8 content type field settings for the term reference 'Users may translate this field': TRUE
D6 'Set language to vocabulary'
Test vocabulary: vocabulary 2 (i=1)
- D8 vocabulary 'Show language selector on create and edit pages': FALSE
- D8 vocabulary 'Enable translation': FALSE.
- D8 content type field settings for the term reference 'Users may translate this field': FALSE
Remaining tasks
1. Patch
2. Add tests.
3. Review.
4. Commit
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#64 | interdiff-61-64.txt | 706 bytes | quietone |
#64 | 2975509-64.patch | 16.81 KB | quietone |
#61 | interdiff-59-61.patch | 776 bytes | quietone |
#61 | 2975509-61.patch | 16.8 KB | quietone |
#59 | interdiff_50-59.txt | 750 bytes | gaydabura |
Comments
Comment #2
jhodgdonHTML typo
Comment #3
jhodgdonComment #4
quietone CreditAttribution: quietone as a volunteer commentedAssigning to myself, I'm about halfway through making a patch.
Comment #5
quietone CreditAttribution: quietone as a volunteer commented@jhodgdon, thanks for the research, most helpful. I didn't see it until after I had done another look at the d6 code and I came to the same conclusion as you.
I manually tested this patch and it worked just fine but I haven't reviewed the code yet, I just got something to work.
Comment #7
quietone CreditAttribution: quietone as a volunteer commentedLet's try that again. That was a bad patch.
Comment #9
quietone CreditAttribution: quietone as a volunteer commentedThis adds a source plugin test
Comment #11
masipila CreditAttribution: masipila commentedD6 has four options in vocabulary language settings. Let's cover all of them in this issue but limit the scope of this issue strictly to D8 Vocabulary settings as it was originally.
I updated the issue summary and proposed the mappings to all four scenarios.
Remaining tasks:
1. Review and agree the configuration settings of the proposed resolution
2. Update the patch accordingly with tests.
3. Test manually.
Cheers,
Markus
Comment #12
masipila CreditAttribution: masipila commentedFormatting and fix to broken img URL.
Comment #13
Gábor HojtsyLooks all fine, except these ones which are the same in all cases:
D8 vocabulary language: Migrate from D6 vocabulary language. If empty on D6, migrate to 'und' (Not specified).
This may be fine, but I was wondering it we should migrate it to the site default language or just English when empty. I think D6 makes assumptions about this, and while I am not sure it will probably assume the site default language(?)
Comment #14
masipila CreditAttribution: masipila commentedRe: #13.
I was thinking the same myself. I don't think we should use English as a fallback. I can easily imagine a D6 site where the primary language is something else but the vocabulary language is empty in D6. Let's fallback to the site default language.
I'll update the issue summary later today (I'm just about to hop off from the bus).
Markus
Comment #15
masipila CreditAttribution: masipila commentedRe #13-14: IS updated.
Comment #16
masipila CreditAttribution: masipila commentedD7 i18n_taxonomy module has the same 4 vocabulary options that we have in D6. The data is stored in taxonomy_vocabulary database table, we have columns 'language' and 'i18n_mode'. In D6 the data is stored in variables as described in the issue summary.
Do we want to increase the scope of this issue and cover both D6 and D7 in this same issue? Conceptually they are the same which would justify handling them in this same issue even though the scope of the issue creeps. I'm ok to handle these also as separate issues if that's what others are preferring.
Cheers,
Markus
Comment #17
masipila CreditAttribution: masipila commentedRe #16: Answering myself, let's handle that as a separate issue as the vocabulary itself can be translated as well. For D6-D8 that part has been already covered in #2225781: Migrate D6 i18n taxonomy vocabularies and for D7 we need to cover a) the vocabulary settings as described in this issue + b) handle the translation of the vocabulary itself. I'll create a separate issue for that.
Comment #18
masipila CreditAttribution: masipila commentedRe: #17: Created #2979970: Migrate D7 vocabulary language settings
Comment #19
masipila CreditAttribution: masipila commentedComment #20
masipila CreditAttribution: masipila commentedI was evaluating more about this. D8 vocabluary does not have 'site default' language so the proposed resolution I wrote earlier is quite tricky. I'll continue evaluating and will provide a new patch this evening my time and will update the issue summary with an updated proposed resolution.
Hope you don't mind @quietone that I jump in with patching!
Cheers,
Markus
Comment #21
quietone CreditAttribution: quietone as a volunteer commented@masipila, not at all.
Comment #22
masipila CreditAttribution: masipila commentedOk, I figured out the rest of this.
The D6 vocabulary 'language' can be defined if (and only if) the multilanguage mode is set as 'Set language to vocabulary'. D6 UI forces an empty value to this drop down list if any other multilanguage mode is selected. The language is saved in D6 database in vocabulary.language column. This field controls the language of the new terms to be created i.e. it is an equivalent to D8 'Term language / Default language'.
The D8 vocabulary 'language' field is a different thing and is an attribute of the 'Taxonomy vocabulary' configuration entity. The D6 configuration attributes that that we are migrating here are attributes of the D8 'Content language settings' configuration entity.
Issue summary updated accordingly. Patch will come in the next comment.
Cheers,
Markus
Comment #23
masipila CreditAttribution: masipila commentedTypo / formatting in IS.
Comment #24
masipila CreditAttribution: masipila commentedHere's the patch that should be migrating all three fields according to the issue summary.
I did not make any changes to the tests yet, tagging for tests.
Markus
Comment #25
masipila CreditAttribution: masipila commentedThis works, but I noticed that @maxocub used a language code 'xx-et-current' in another migration, see #2073467: Migrate Drupal 7 Entity Translation settings to Drupal 8.
What is this 'xx-et-default' and should we use that one instead of 'site_default'?
Markus
Comment #26
maxocub CreditAttribution: maxocub as a volunteer commentedThe xx-et-* langcodes are specific to the entity_translation module ('et' = 'entity_translation'), so I think 'site_default' is good here.
Comment #27
quietone CreditAttribution: quietone as a volunteer commentedI'll look at the tests this week.
Comment #28
quietone CreditAttribution: quietone as a volunteer commentedThanks masipila! Updated the test to check the default langcode and the third party settings according to the new migration values.
Comment #30
quietone CreditAttribution: quietone as a volunteer commentedComment #31
masipila CreditAttribution: masipila as a volunteer commentedI'm checking the tests at the moment.
Comment #32
masipila CreditAttribution: masipila as a volunteer commentedA couple of copy-paste error nits.
1.
Should be something like 'Tests migration of i18ntaxonomy vocabulary settings.'
2.
s/an/the.
3.
Should be something like 'Tests i18ntaxonomy vocabulary setting source plugin.'
Comment #33
quietone CreditAttribution: quietone as a volunteer commented@masipila, thanks for the review!
Yes, I still leave copy/paste errors behind.
All items in #32 fixed.
Removed the needs tests tags because the tests are here.
Comment #34
masipila CreditAttribution: masipila as a volunteer commentedI realized that the vocabulary language settings is not the only thing we need to cover.
Issue summary updated with expected result for each of the scenarios.
Comment #35
masipila CreditAttribution: masipila as a volunteer commentedComment #36
quietone CreditAttribution: quietone as a volunteer commentedThis is not finished but I think it is working properly. At minimum, tests are needed for the changes in d6_vocabulary_field_instance and the changes to the dump needs checking.
I've added the names of the test fixture vocabularies to the proposed resolution to help with reviews.
Comment #37
quietone CreditAttribution: quietone as a volunteer commentedThe patch is #36 was a work in progress and it was made from HEAD. Oops. This patch is and the interdiff is against the patch in #33.
The four modes of translation are now enabled in the test fixture. Only one vocabulary required a change, that was to set vocabulary vocabulary_3_i_0_ to translate 'localized term'. And they are tested according to the excellent descriptions by masipila in the proposed resolution. I've added the taxonomy names there to help reviewers.
Edit: I really must remember to name interdiff correctly.
Comment #40
quietone CreditAttribution: quietone as a volunteer commentedNot sure how the hierarchy for the vocabulary was changed from 2 to 0. It is back to 2 now. And fixed the entity count as well/
Comment #41
quietone CreditAttribution: quietone as a volunteer commentedThis is ready for review. It should now implement all of the proposed resolution, that is the vocabulary settings and the language content settings for the 4 modes of taxonomy translation available in Drupal6.
Change the IS to show that the patch is made and it has tests.
Comment #42
quietone CreditAttribution: quietone as a volunteer commentedComment #44
masipila CreditAttribution: masipila as a volunteer commentedI tested this manually and the patch #40 works exactly as the issue summary describes. I also reviewed the patch and it looks good. There is also sufficient test coverage.
I'd RTBC this otherwise but I contributed to the patch in #24 so I'm not sure I can do that. But as said, the patch #40 is doing exactly what the issue summary defines for the different scenarios.
Thanks @quietone!
Cheers,
Markus
Comment #45
maxocub CreditAttribution: maxocub as a volunteer commentedJust found a few things, otherwise this looks good, great work everyone!
I think this could be written as
Instead of manually creating the languages, we can just run the 'language' migration.
I don't see the relevance of those changes. I think they can be remove without affecting the tests in this patch.
Missing spaces after the periods.
Comment #46
quietone CreditAttribution: quietone as a volunteer commentedThanks maxocub.
This should fix #45.1-4.
Comment #47
maxocub CreditAttribution: maxocub as a volunteer commentedGreat, after reading a few times through the IS, the comments and the patch, I think this is ready.
Only one thing though, there's still one unused use statement:
But that can be fixed on commit, right?
Comment #49
masipila CreditAttribution: masipila as a volunteer commentedQueued the last patch to PostgreSQL and SQLite tests just to be sure.
Comment #50
quietone CreditAttribution: quietone as a volunteer commentedRemoved the unused use statement spotted in #47.
Comment #51
masipila CreditAttribution: masipila as a volunteer commentedThanks @quietone for the last fix!
I haven't touched the patch since it was last RTBC so I should be allowed to do it now.
Markus
Comment #52
alexpottOne thing I can't see (and it might be just because I don't know) is how we are sure that content_translation is enabled on the target site?
Comment #53
masipila CreditAttribution: masipila as a volunteer commentedChanging the status back to NR to address @alexpott's question in #52. Ping @quietone / @maxocub.
Comment #54
quietone CreditAttribution: quietone as a volunteer commentedThat pattern in the migration yml already exists in core in language/d6_language_content_setttings,yml and language/d7_language_content_settings.yml. That doesn't make it the 'correct' solution but it is out there.
This is further proof we need to discuss how to handle migrations that require multiple destination modules. Perhaps a new issue?
Edit: Made a new issue #3004472: Handle migrations that require multiple destination modules
Comment #55
masipila CreditAttribution: masipila as a volunteer commentedThanks @quietone for your insight!
I propose that we will not block this issue because of this. Instead, I will emphasize in the docs that when performing multilingual upgrades, the sitebuilder is expected to enable Config translation, Content translation, UI translation and Migrate Drupal multilingual. It is IMO quite safe assumption that more or less any multilingual site will anyway need these modules.
I'll add this to these two pages:
https://www.drupal.org/docs/8/upgrade/upgrading-multilingual-drupal-6-to...
https://www.drupal.org/docs/8/upgrade/upgrading-multilingual-drupal-7-to...
I'll change this to NW for the additional documentation and then back to RTBC once the docs have been updated.
Markus
Comment #56
masipila CreditAttribution: masipila as a volunteer commentedComment #57
masipila CreditAttribution: masipila as a volunteer commentedThe handbook documentation has now been updated so that we are emphasizing that Language, Interface Translation, Content Translation, Configuration Translation and Migrate Drupal Multilingual need to be enabled before running a multilingual upgrade.
This and @quietone's comment in #54 addresses @alexpott's question in #52.
Back to RTBC.
Cheers,
Markus
Comment #58
masipila CreditAttribution: masipila as a volunteer commentedPatch #50 does not apply anymore, needs reroll
Comment #59
gaydabura CreditAttribution: gaydabura as a volunteer and at Skilld commentedre-rolled
Comment #61
quietone CreditAttribution: quietone as a volunteer commentedUsing git bisect (first time) this error starts when #2994398: Not properly clearing EntityFieldManager's fieldMap leads to fatals, often after migration or bundle creation was committed. Skimming that patch I noticed that the installing the entity schema for node was added to the existing Migrate Language Content Settings tests. So, I added that to this test and it passed locally. Let's see if testbot agrees.
Arg!: My fingers have learned to use the wrong extension for interdiff.
Comment #63
quietone CreditAttribution: quietone as a volunteer commentedI guess I ended up testing in the wrong branch.
Comment #64
quietone CreditAttribution: quietone as a volunteer commentedStart over and try again.
The problem is it is trying to add a field to the taxonomy_term_field_data table, so let's just make sure it exists for the test!
Comment #66
quietone CreditAttribution: quietone as a volunteer commentedThere was a testbot hiccough so I reran the test and it is green now
Comment #67
masipila CreditAttribution: masipila as a volunteer commentedThanks @gaydabura for the reroll in #59!
I reviewed the patches from #59 onwards. As @quietone explained in #64, we need to have taxonomy_term schema in the test that failed in #59.
I queued the latest patch for PostgreSQL and SQLite. Once those are green, this can go back to RTBC as it was before.
Markus
Comment #68
quietone CreditAttribution: quietone as a volunteer commentedTests are passing on PostgreSQL and SQLite so setting to RTBC as recommended by masipila in #67.
Comment #69
masipila CreditAttribution: masipila as a volunteer commentedUn-assigning myself
Comment #70
catchCommitted and pushed d654e1038b to 8.7.x and 9e80041316 to 8.6.x. Thanks!