I have a multilingual site with 3 languages where only 1 field (Description) is really multilingual, everything else is a translated interface and strings.
For the Description field, it has been my aim to replicate the functionality of Wordpress's "qTranslate" plugin so that the UI looks something like this:
I have almost managed to achieve this using Fieldgroup module, 3 description fields, and Language Sections module (because I found no better way to assign each field to its language).
So far so good. But at the top of each field I have to put in default texts (=fr =en= =el=) so that Language Sections module knows which field is which language and displays the correct text depending on which is the current language. If the end-users delete those =en= and =fr= tags, then the whole thing falls apart.
So I need a module that will inject those =fr= and =en= tags at the beginning of each textfield's entered text, in a way that's completely transparent to the user. Is there such a module? Can Rules achieve a functionality like this?
Alternatively, if there is no such module, how would one go about creating one? Which function or which hook to use?
UPDATE I made this module called language_markers based on the answer given by Beebee ,but it didn't work. Can you pleasetellmewhat I'mdoing wrong? :
<?php
function language_markers_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'property_for_sale_node_form' || $form_id == 'property_to_rent_node_form') {
$form['#submit'][] = 'language_markers_submit_handler_function';
}
}
function language_markers_submit_handler_function($form, &$form_state) {
foreach($form_state['values'] as $field_name => $value) {
switch($field_name) {
case 'field_description_fr':
$value = '=fr= '.$value;
break;
case 'field_description_nl':
$value = '=nl= '.$value;
break;
case 'field_description_en':
$value = '=en= '.$value;
break;
}
}
}
UPDATE 2: I have managed to get this to work with Rules module:
Event: After updating existing content of type Property for Sale
Condition: none
Action: Set a data value Parameter: Data: [node:field-description-en..., Value: =en= [node:field-description-en:value]
It works,but when the end-user comes back to edit the node, he sees "=en=" in front of his text. That's a BAD User-Experience. This is a work-around, not a solution. I still need a solution.
<input>
is what it is and it does not support locking and hiding parts of it.style="display: none"
or something analogous when talking HTML. Automated is a whole different story.