Problem/Motivation
Variables can be set as multilingual using i18n module.
Proposed resolution
Create a source and destination plugin to migrate the data in the D6 {i18n_variable} table (name, language, value).
Remaining tasks
Write the source plugin and tests
Write the config destination plugin and tests
See roadmap section in #2208401: [META] Remaining multilingual migration paths
Original report by Ryan Weal
i18n variables (D6/D7 i18n contrib -> D8 translatable config). In D6 & D7 the i18n module provided an "override" table of any settings the user specified in their settings.php file (or in the DB in d7). Virtually any D6 or D7 variable could have a mirror of itself in the i18n table. Best case scenario, we detect which settings have the override set, and then pull all the language versions for those config and apply them to the translatable config entities in D8.
Comment | File | Size | Author |
---|---|---|---|
#36 | interdiff-2225477-22-36.txt | 1.57 KB | quietone |
#36 | 2225477-36.patch | 12.67 KB | quietone |
#22 | interdiff-2225477-20-22.txt | 15.02 KB | quietone |
#22 | 2225477-22.patch | 12.67 KB | quietone |
#20 | interdiff-2225477-19-20.txt | 1.5 KB | quietone |
Comments
Comment #1
penyaskitoAFAIK, we can only override labels in D8.
Comment #2
Gábor HojtsySo long as we have a mapping of a Drupal 6 variable to its Drupal 8 equivalent, we should be easily able to migrate it to config translation, basically we migrate it into a config file with the same structure but only the translation. Work for any translatable variable that is still marked translatable in Drupal 8 config.
Comment #3
phenaproximaComment #4
phenaproximaBlocked by #2594263: Add translation data to Migrate Drupal's test fixtures.
Comment #5
Gábor Hojtsy#2594263: Add translation data to Migrate Drupal's test fixtures landed.
Comment #6
quietone CreditAttribution: quietone commentedI've enabled the internationalization, content type translation and profile translation and 3 languages. Made some test content played with configuration but have not been able to populate the i18n_variable table. How does one generate that data? Please be specific, I've never done any multilingual work before.
Comment #7
quietone CreditAttribution: quietone commentedWhat exactly is "D8 translatable config" mentioned in the IS?
Comment #8
Gábor Hojtsy@quietone: almost all configuration in Drupal 8 is translatable, enable the configuration translation module and see the list of translatable configuration in admin > configuration > regional and language > configuration translation.
The i18n_variable table seems to be originated from i18n_variable module which does not even use it anymore. It uses a generic storage system of the variable module instead. See http://cgit.drupalcode.org/i18n/tree/i18n_variable/i18n_variable.install... update functions :) That combination allows you to translate things like content type names, the site name, etc. Those are now in translatable config in Drupal 8.
Hope this helps.
Comment #9
quietone CreditAttribution: quietone commented@Gábor Hojtsy, thanks I do see the D8 translations in config. But, so far, I can only make content translations for D6.
How do I create a translation for things like site name and site maintenance msg in D6?
Comment #10
Gábor HojtsyRight, I quoted Drupal 7 code. Sorry. So in Drupal 6:
To translate site name, etc you'll need to set the global i18n_variables array. See https://www.drupal.org/node/313272. Note that you'll be editing translations on the config page itself by switching language.. For some higher level config objects like content types, that is much easier:
- Enable he content type translation module (from i18n). It will enable all its dependencies. No external dependencies.
- Add a language other than English.
- Go to /admin/build/translate/search and limit search to content type. Voila!
Comment #11
quietone CreditAttribution: quietone commentedThx, I've got some data in the i18n_variable table! The bit I missed was changing settings.php.
Comment #12
quietone CreditAttribution: quietone commentedThinking this through a bit with a simple example.
Drupal 6
Drupal 8
So, for all site_slogans in D6 the following applies.
language ==> collection field as language.XX
value ==> system.site/slogan
A source plugin that produces rows identical to the source should be sufficient. And allow for processing of the value, if needed, in more complex inputs.
Before doing that I want to know more about writing language data to config. Specifically, can the existing config destination plugins be sufficient? Will they handle the collection field?
Comment #13
Gábor HojtsyThat I don't know any better than you unfortunately. Wanna try? :)
Comment #14
quietone CreditAttribution: quietone commentedFirst go at this. It is modeled off the existing Variable.php. This could be the wrong approach but have to start somewhere. And will know more when using it in a real migration.
The plugin will return an array of the following form.
For now, let's see what the bot finds,
Comment #15
quietone CreditAttribution: quietone commenteds/variable/i18n_variable/
Oops, will fix soon.
Comment #16
penyaskitoGreat progress :)
Thanks for working on this :)
Comment #17
quietone CreditAttribution: quietone commentedStarted working on a config destination plugin. Can't use the existing one because, I think, the language must be set to the language of the data being migrated first. Correct me if I am wrong on that.
It looks like there are several setLanguage methods. Which one to use and how?
Comment #18
quietone CreditAttribution: quietone commentedNeeds the destination plugin.
Comment #19
quietone CreditAttribution: quietone commentedpenyaskito, thanks for the help on IRC.
Added a destination plugin. It is in migrate, just like the current Variable destination plugin. Not sure if that is the right module for it. And the changes to config schema need to be checked. I'm not very familiar with that system.
Comment #20
quietone CreditAttribution: quietone commentedChanged the destination plugin to sort the destination by language so the saving can be done by language.
Even though I had questions about how to handle multiple languages I wanted to create this so I had a better understanding of the issue. Now thats done, time to return to the questions.
1) Is using i18n to precede the filenames ok?
2) Should the destination plugin be in migrate or somewhere else?
3) Is calculateDependencies correct?
4) Should the source plugin be smarter and allow for selecting one or more languages?
Comment #21
quietone CreditAttribution: quietone commentedI'm going to start making child issues for other i18n variables that need a migration. I'll start by looking at the existing D6 migrations that use the variable source plugin. These are:
d6_book_settings.yml
d6_system_image_gd.yml
d6_date_formats.yml
d6_system_maintenance.yml
d6_system_cron.yml
d6_system_rss.yml
d6_system_date.yml
d6_system_performance.yml
d6_system_file.yml
d6_system_image.yml
d6_system_logging.yml
d6_system_site.yml
d6_action_settings.yml
d6_dblog_settings.yml
d6_syslog_settings.yml
d6_node_settings.yml
d6_aggregator_settings.yml
d6_file_settings.yml
d6_search_settings.yml
d6_simpletest_settings.yml
d6_statistics_settings.yml
d6_forum_settings.yml
d6_comment_entity_form_display_subject.yml
d6_comment_field_instance.yml
d6_comment_field.yml
d6_comment_entity_display.yml
d6_comment_entity_form_display.yml
d6_comment_type.yml
d6_user_mail.yml
d6_user_settings.yml
Therefore, changing the title to include [META].
Comment #22
quietone CreditAttribution: quietone commentedTalked to chx on IRC and he suggested that it would be better to not have two destination plugins for Config. Makes sense and it was a simple once I stopped over thinking it.
Comment #23
chx CreditAttribution: chx at Smartsheet commentedNifty!
Comment #24
quietone CreditAttribution: quietone commentedThis is a blocker for any issue that migrates i18n variables to configuration. Note that the variable to configuration migrations are usually suitable for tagging Novice.
Comment #25
Gábor HojtsySo this is basically the meat of the patch right? :)
Comment #26
chx CreditAttribution: chx at Smartsheet commentedThat and i18nVariable::values and ::query
Comment #27
Gábor HojtsyWhile I have limited understanding of the migration system at best, the reuse of the config migration looks good. What would ensure that this is only attempted to be run if there was i18n_variable table/data?
Comment #28
Gábor HojtsyAll right, let's get this baseline in then, I see nothing wrong here. And then build on top of it :)
Comment #29
catchNot properly reviewed yet, but got confused by the title so updating.
Comment #30
catchComment #31
quietone CreditAttribution: quietone as a volunteer commentedComment #32
catchShouldn't this use @link?
Comment #33
quietone CreditAttribution: quietone as a volunteer commented@catch, thx. But can you be more explicit? Where do you think @link is needed?
Comment #34
catchSorry I posted that comment to the wrong tab :(
Back to RTBC, I need to actually review this one again, which is why I had the tab open, but have not done that yet.
Comment #35
Kristen PolThanks for the patch! I scanned the code for syntax and found some nitpicks that don't affect functionality. Leaving RTBC since it's unclear if any of these should be addressed.
Nitpick: More than 80 characters.
Nitpick: Use single space between sentences.
Nitpick: Use $i18n_variable or $i18nVariable.
Nitpick2: Extra space after
$i18nvariable->language
and before) {
.Comment #36
quietone CreditAttribution: quietone as a volunteer commentedThx, Kristen Pol. Yea, nitpicks should be addressed.
1. Sorry, don't know how to 'properly' fix that.
2. Fixed
3. Name changed, extra space removed.
Comment #37
Kristen PolChanges look good! Yeah... not sure what the policy is for the first nitpick so keeping it as is seems fine. Thanks!
Comment #40
catchCommitted/pushed to all three 8.x branches. Thanks!
Added commit credit post-commit.
Generally it's really nice to see support being implemented for migrating modules like i18n_variables that have been replaced by core functionality, this is one of the things it was near-impossible to do properly with hook_update_N().
Comment #42
Gábor HojtsyAmazing, thanks all, especially @quietone! This now allows so much to make progress! Woot!
Comment #43
Gábor Hojtsy