Follow-up to #2854188: Translation issue
Problem/Motivation
Changing the site wide language causes a translated webform's elements to be lost.
There is no easy way to get a webform's element's render array to be translatable because it is almost impossible to define a config scheme for dozens of render elements within nested render array.
https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...
The Webform module provides a WebformTranslationManager that extracts the translatable properties from a webform's element's render array.
Proposed resolution
OPTION 1: Detect when the site language changes and fix translated webform config.
OPTION 2: Track source language when a webform is created.
Remaining tasks
OPTION 1: Detect when the site language changes and fix translated webform config.
- Detect site language on install store as settings.
- Track website site language to current language
- Add conversion batch process to MskTranslationManager.
- Add warning to status report
- Add warning to translate tabs
- Add warning to change language form
- Write drush command
- Write tests
OPTION 2: Track source language when a webform is created.
- Add source_langcode to webform config
- Document the Source langcode
- Update WebformTranslationManager to use source_langcode for element definitions.
- Write update hook that sets the correctly source langcode for all existing configuration.
- Write tests
User interface changes
- Warning on Status Report
- Warning on Translate tab
API changes
- Webform module is tracking site language
Data model changes
None
Steps to Reproduce
- Install the Webform and Config Translation module
- Enable 'Spanish' ()
- Translate Contact form to Spanish
- Switch Default Language to 'Spanish'
- View Contact form and elements are missing.
Notes
Installing Webform on non-English (en) website
- Webform retains en langcode.
- English is still considered the (original)
New Webform created on a non-English website
- Webform's langcode is set to current language
- Current language is marked as original
Comment | File | Size | Author |
---|---|---|---|
#8 | changing_the_site_wide-2854510-7.patch | 39.22 KB | jrockowitz |
| |||
#6 | changing_the_site_wide-2854510-5.patch | 7.04 KB | jrockowitz |
| |||
#3 | changing_the_site_wide-2854510-3.patch | 963 bytes | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe attached is patch for OPTION 2.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #11
balintcsaba CreditAttribution: balintcsaba commentedIs any chance that the patch contains code from a previously added patch? First of all thank you, the patch is working and fixed the translation and the wizard problem to. But since the patch is not applying for all files with the message of: "Reversed (or previously applied) patch detected!" I can't mark as RTBC. Maybe is not worth it to fix, since is a critical bug for multilingual site with other default language then English, maybe the beta8 is more important. So for me is a RTBC but if you want that other to test before beta8 then you should wait.
Edit:
I applied the changing_the_site_wide-2854510-7.patch
Update:
If apply the changing_the_site_wide-2854510-5.patch this has no error, and this is fixing my issue to.
I'am missing something maybe :)
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch (@see #9). Please download or checkout the latest dev release.
I only noted it in the original ticket and should have said it here to.