Follow-up to #2805113: Form has translation and its elements and properties can not be changed.

Problem/Motivation

A YAML forms are render arrays that contain rendering and processing information as well as each element's title, description, placeholder, etc... An element's labels need to be easily translatable.

Proposed resolution

Rework YAML form translations so that just a simple YAML file containing just an element's label can be translated.

Remaining tasks

  • Create dedicated yamform translate test form. Include custom elements and place holders
  • Define properties that are translatable. getTranslatableProperties($element)
  • Update translation form to display only element labels.
  • Update yamlform initialization logic to apply labels
  • Update element CRUD operations to delete translated elements
  • Write update hook that convert existing translated forms to use new labeling format.
  • Remove locking code and validation handlers.
  • Write tests

User interface changes

TBD

API changes

TBD

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jrockowitz created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
FileSize
110.32 KB

  • jrockowitz committed 4c4a3d8 on 2825410-forms-translations
    Issue #2825410 by jrockowitz: Allow forms labels to be translatable
    
jrockowitz’s picture

  • jrockowitz committed 0d09601 on 8.x-1.x
    Issue #2825410 by jrockowitz: Allow forms labels to be translatable
    
jrockowitz’s picture

Status: Needs review » Fixed
stewest’s picture

Hi. I'm using latest 8.x-1.x-dev. I created the form in english, translate to DE, updating the yaml form labels. When I go to the form's DE page, there are no input fields.

Any suggestions?

jrockowitz’s picture

What is the default language for your site?

What page/path is blank? Can you include a screenshot?

Can you replicate the issue via https://simplytest.me/project/yamlform?

stewest’s picture

Hi there

German DE is the default language for the website, however Drupal was installed in English.

We're on Drupal 8.2.3, but Simply test is 8.1.11. I'll see if I can get a test going.

This is the yaml of the form

first_name:
  '#type': textfield
  '#title': 'First Name'
last_name:
  '#type': textfield
  '#title': 'Last Name'
company_name:
  '#type': textfield
  '#title': 'Company Name'
company_id_number:
  '#type': textfield
  '#title': 'Company ID Number'
form_address:
  '#type': textfield
  '#title': Address
zip_code:
  '#type': textfield
  '#title': 'Zip Code'
city_town:
  '#type': textfield
  '#title': City/Town
comments:
  '#type': textarea
  '#title': Comments

jrockowitz’s picture

Status: Fixed » Needs review
FileSize
187.75 KB

I couldn't reproduce the issue.

Here are my steps attempting to replicate this issue...

  • Create https://simplytest.me/project/yamlform using French as the default language.
  • Enable the YAML Form modules and Config translation module (/admin/modules)
  • Add Spanish as a second language (/admin/config/regional/language)
  • Create Spanish translation of the Contact form (/admin/structure/yamlform/manage/contact/translate/es/add)
  • View the Spanish translated Contact form. (/es/form/contact)

It is also worth noting that Drupal automatically converted the forms language from 'en' to 'fr' when I enabled the YAML Form module.

stewest’s picture

Hi there

Thanks for this feedback. I followed the steps.

We're using 8.2.3 and the Yaml forms Dev version.

I install just 3 of the form modules: YAML Forms, UI and Node.
modules enabled

We can see the newly created form - when I click translate, it says English is the default.
english form shows

I then add a German DE translation. The form disappears on the de/form/formname and only shows on the en/form/formname
DE form disappears

jrockowitz’s picture

I can't duplicate this issue using Simplytest.me.

Below is a very simple form translated from German into English and French.

https://d1yjh.ply.st/form/test-form
https://d1yjh.ply.st/en/form/test-form
https://d1yjh.ply.st/fr/form/test-form

Here are the languages:

https://d1yjh.ply.st/admin/config/regional/language

Please note that this sandbox (https://d1yjh.ply.st/) is only available for 24 hours.

jrockowitz’s picture

My best guess is this issue is related to the sequence that the languages are being enabled/configured but we need to be able to replicate this using Simplytest.me.

stewest’s picture

I've attempted Simpletest, but we're on 8.2.3 and this requires the dev release of the Yamlform module.

jrockowitz’s picture

Below is the 'magical' URL, the only limitation is you can't specific which version of the YAML Form module

https://simplytest.me/project/drupal/8.2.3?add[]=yamlform

stewest’s picture

Thank you for that. I've done as you suggested and cannot reproduce the error. There must be something wrong in my config. Thanks for your time and effort so far.

jrockowitz’s picture

No one gets left behind

Just to be clear, you had existing translations and then you updated to beta23 and now you are seeing this issue.

I am going to bet this issue is simply related the langcode (ie langcode: en) for your existing YAML form configuration files. You should export and examine your existing configuration and see how it differs from the configuration generated via a clean installation.

One trick to completely reinstall the YAML Form module would be to...

- Export your custom configuration
- Backup the 'yamlform_submission' and 'yamlform_submission_data' tables
- Completely uninstall and reinstall the YAML Form module
- Import your custom configuration
- Restore the backed up 'yamlform_submission' and 'yamlform_submission_data'

Obviously, I am assuming you know how to export configuration and backup and restore MySQL tables.

stewest’s picture

Hi there. I totally uninstalled the module, removed (exported) the config, so it was "clean". Then re-installed the latest stable release. I am now able to do translations. Thanks.

jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.