I’m using webform (3.17) and form_localazation, to build a form with some textfields, a select item and a grid. In the webform ‘forms settings’, all checkboxes of ‘Localization by string translation’ are checked. The checkboxes of ‘Localization by sync’ aren’t.
Via “Configuration > Regional and language > Translate interface > Translate” I’ve added every label, every select value and every grid question an option.
Back to the webform display, only the labels of the textfields are translated. The labels of the select item and the grid aren’t translated. Even the select values and grid options and questions are in the default language, although they were available in the Translation part.

Comments

DEJU’s picture

Perhaps a work around, but I'm not sure if this the right way in Drupal.

In the 'Translate' form, the Webform grid title is shown as followed:

TEXT GROUP: Webform Localization
STRING: Test Grid (=> the displaylabel of my field), webform:1:4:#title
CONTEXT: 1:4:#title

After adding the right translation, de language isn't striked through anymore. The result of this translation isn't displayed in the webform.

When I use the hook hook_webform_component_render_alter with following code:

function TestWebformTranslation_webform_component_render_alter(&$element, $component)
{
  $element['#title'] = t($element['#title']);

switch ($element['#type']) 
	{
		case 'checkboxes':
			$element['#options'][1] = t($element['#options'][1]);
			$element['#options'][2] = t($element['#options'][2]);
			break;
		
		case 'webform_grid':
			$element['#grid_questions'][1] = t($element['#grid_questions'][1]);
			$element['#grid_questions'][2] = t($element['#grid_questions'][2]);
		
			$element['#grid_options'][2] = t($element['#grid_options'][2]);
			$element['#grid_options'][2] = t($element['#grid_options'][2]);
			
	}
}  

The 'Translate' form shows an extra translatable item as followed:
TEXT GROUP: Built-in interface
STRING: Test Grid (=> the displaylabel of my field), /mysite/?q=fr/node/1
CONTEXT: (empty)

Translating this item, the webform is correctly displayed.

DEJU’s picture

Looking deeper into the arguments that are passed to the hook ($element and $component), a textfield contains
the item ['#webform_component']['extra']['translated_strings'][0], which refer to context of the translate form (e.g.: webform:1:2:#title).
A select or grid field do not have this 'translated_string' item in the $element and $component array.

GDrupal’s picture

Assigned: Unassigned » GDrupal

This need a further review indeed, let me check it and I will let you know, select and grid work different and should be displaying ok. as are in our testing, I will try to reproduce your problem.

Thanks!

GDrupal’s picture

Status: Active » Postponed (maintainer needs more info)

@DEJU i can not reproduce your problem i have tried several times using webform (3.17) and the lst copy of webform_localization. Do you have the last version? are you using this to get it:
git clone --branch 7.x-1.x GDrupal@git.drupal.org:sandbox/GDrupal/1407100.git webform_localization

Thanks!

DEJU’s picture

Yes I do (Webform 7.x-3.17 and the latest webform_localization)

Some screenshots

GDrupal’s picture

Version: » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

This can´t be reproduced right now. Please feel free to open it if you have more information.