Hi!

Can you adjust following snippet so the user entered option values are also translatable in next versions?

select.inc - Line 514

source:
isset($group) ? $options[$group][$key] = $value : $options[$key] = $value;

new:
isset($group) ? $options[$group][$key] = t($value) : $options[$key] = t($value);

Greetings from Berlin Germany

CKIDOW

Comments

stevenpatz’s picture

Version: 6.x-2.7 »
Status: Active » Needs review
StatusFileSize
new950 bytes

and a patch

ckidow’s picture

can anyone test this patch and report if it is possible to submit the form in different languages? 'cause there is a problme submitting the form in different languages than the basic language in which the form was created.

After pressing "submit" in other languages it directly redirects to the webform incl. filled in values... so nothing happens

konrad_m’s picture

Version: » 6.x-3.0-beta2

It works fine for me - event with version 3.0 - beta2 of Webform.

giorgosk’s picture

StatusFileSize
new999 bytes

6.x-3.0-beta2 needs a patch for options to be translatable

quicksketch’s picture

Status: Needs review » Needs work

This patch won't be committed as it's written, since it's misuse of the t() function. However we started using the tt() function in #638168: Add tt wrapper to allow user roles to be translated, which seems like it would be appropriate to do here also.

giorgosk’s picture

I need help in creating the $name for webform_tt

quicksketch’s picture

Quite honestly I don't know how that string is formatted either. Webform just used the same as other modules in #638168: Add tt wrapper to allow user roles to be translated. I imagine it should be something like: "webform:cid:$cid:option:$key", where $cid is the component ID and $key is the key specified by the user. Unfortunately we don't really have a $key that's dependable, since if the user is not using the "key|value" syntax, then the entire string ends up being the $key. This problem is the subject of #712324: Convert Select and Grid Options to New Data Storage, which would make it so we could always get a consistent $key.

The purpose of using tt() as I understand it is so that we can clean up unused strings when they're no longer needed. So when a component is deleted we should go through and delete all the translated options.

tomsm’s picture

subscribing

quicksketch’s picture

#712324: Convert Select and Grid Options to New Data Storage has been committed, meaning we can now get a reliable $key value to add to our tt() $name value. While this means that we can now have a reliable $name value, we also need to manage the deletion and updating of these strings as the components are modified or deleted.

xalexas’s picture

subscribing

tomsm’s picture

Version: 6.x-3.0-beta2 » 6.x-3.1

This issue still exists in 6.x-3.1. Patch #4 fixes this.

plach’s picture

plach’s picture

Version: 6.x-3.1 » 6.x-3.x-dev
giorgosk’s picture

#4 will never make it in webform
its not the proper way
read #9

rantebi’s picture

Does anybody know how to do this with drupal 7's cck.
There's no option for php code there ... :S

olafski’s picture

Version: 6.x-3.x-dev » 6.x-3.14

Hello everybody,
I was going to test one of the patches, but then I noticed an interesting thing which might help somebody:

On my site, the character string "- Select -" was translatable. I found it using the search function of the translation admin pages. But watching the path, which is mentioned beneath the string, I guess the translatable string wasn't stored there by Webform (as module) but by an individual form which I set up earlier.

Or was the issue fixed in the meanwhile? (I use webform 6.3.14.)

quicksketch’s picture

Status: Needs work » Closed (duplicate)

This issue can now be solved through #245424: Make Webform multilingual (i18n) aware through contributed modules (which has been committed) and the sandbox project http://drupal.org/sandbox/GDrupal/1407100. Hopefully that project will be promoted to a full project as "webform_localization" sometime soon.

Drupal 6 users are currently still out of luck for an existing solution, though custom modules may now use hook_webform_component_render_alter(), which will allow translation of any properties (including select list options).

giorgosk’s picture

In a custom module I was able to do this

function CUSTOM_MODULE_webform_component_render_alter(&$components){
  $components["#title"] = t($components["#title"]);
}

and then you can translate the usual way

unfortunatelly hook_webform_component_render_alter() is not documented in webform.api.php