Below is a workaround for the translation of form labels.
Hi Eduardo,
i understand what you are talking bout, this is, no, this was one of the open issues on my list too. The following is assuming that you made your form in the CMS and it is there where you added your Spanish language labels 9such as "Empresa", "Rubro", "Contacto (nombre)", etc.).
The main problem is that our nice SS developers have not yet made this part of the code i18n aware.
The bad news is that you have to patch the Sapphire code to fix this (at least I'm not yet aware of another easy way). So beware if you run an SS update, it will overwrite the fix we make here.
The good news is that it is simple and easy :)
You do not have to be a PHP developer to implement the fix below, but you should at least dare to modify the code following the instructions which I'll give you below.
And you have to be familiar with i18n and how to use it in SS, you need i18n enabled in SS to use it. (See my other posts about i18n in this thread).
This fix is tested in SS 4.3.1, it does not need the multilingual alternative to be implemented to work, but it needs i18n enabled (which you have if you use the multilingual alternative in 4.3.1).
EDIT: The code which we patch is unchanged in SS 4.3.2, thus it should also work in 4.3.2, if you have i18n enabled there, but you do not need it if you use the new translatable module of SS 4.3.2.
We need to patch the code in /sapphire/forms/FormField.php, the function FieldHolder(), which should be at line 334. Replace the code there with this code, or just add the changes manually:
function FieldHolder() {
$Title = $this->XML_val('Title');
$Message = $this->XML_val('Message');
$MessageType = $this->XML_val('MessageType');
$RightTitle = $this->XML_val('RightTitle');
$Type = $this->XML_val('Type');
$extraClass = $this->XML_val('extraClass');
$Name = $this->XML_val('Name');
$Field = $this->XML_val('Field');
/** 3 lines below added by Kalileo 2009-07-19 to enable translations of labels in standard SS forms */
if (!empty($Title)) {
$Title = _t('FieldHolder.' . $Title, $Title );
}
$titleBlock = (!empty($Title)) ? "<label class=\"left\" for=\"{$this->id()}\">$Title</label>" : "";
$messageBlock = (!empty($Message)) ? "<span class=\"message $MessageType\">$Message</span>" : "";
$rightTitleBlock = (!empty($RightTitle)) ? "<label class=\"right\" for=\"{$this->id()}\">$RightTitle</label>" : "";
/** return below changed by Kalileo 2009-04-19 to avoid nasty IE7 margin inheritance bug:
wrapped $Field in <span> tag "<span>$Field</span>"
IE sucks!!!!!!!!!!
*/
return <<<HTML
<div id="$Name" class="field $Type $extraClass">$titleBlock<div class="middleColumn"><span>$Field</span></div>$rightTitleBlock$messageBlock</div>
HTML;
}
As you can see there is also a bugfix for IE7 included, which is not related to our translation problem.
The only part needed for the translation is the addition of these lines there, inserted at line 344:
/** 3 lines below added by Kalileo 2009-07-19 to enable translations of labels in standard SS forms */
if (!empty($Title)) {
$Title = _t('FieldHolder.' . $Title, $Title );
}
Now the labels in the CMS standard forms are i18n aware. But we still have to add the translations. These are in the files under /mysite/lang
For English, my default, I use the file /mysite/lang/en_US.php. If you do not have it, then create it, or just add the relevant lines below.
<?php
global $lang;
$lang['en_US']['FieldHolder']['Your name'] = 'Your name';
$lang['en_US']['FieldHolder']['Your Email'] = 'Your Email';
$lang['en_US']['FieldHolder']['Your phone'] = 'Your phone';
$lang['en_US']['FieldHolder']['Your Message'] = 'Your Message';
?>
For German I use /mysite/lang/de_DE.php.
<?php
/**
* German (Germany) language pack
* @package mysite
* @subpackage i18n
*/
i18n::include_locale_file('mysite', 'en_US');
global $lang;
if(array_key_exists('de_DE', $lang) && is_array($lang['de_DE'])) {
$lang['de_DE'] = array_merge($lang['en_US'], $lang['de_DE']);
} else {
$lang['de_DE'] = $lang['en_US'];
}
$lang['de_DE']['FieldHolder']['Your name'] = 'Ihr Name';
$lang['de_DE']['FieldHolder']['Your Email'] = 'Ihre E-mail';
$lang['de_DE']['FieldHolder']['Your phone'] = 'Ihr Telefon';
$lang['de_DE']['FieldHolder']['Your Message'] = 'Ihre Nachricht';
?>
For Thai I use /mysite/lang/th_TH.php.
<?php
/**
* Thai (Thailand) language pack
* @package mysite
* @subpackage i18n
*/
i18n::include_locale_file('mysite', 'en_US');
global $lang;
if(array_key_exists('th_TH', $lang) && is_array($lang['th_TH'])) {
$lang['th_TH'] = array_merge($lang['en_US'], $lang['th_TH']);
} else {
$lang['th_TH'] = $lang['en_US'];
}
$lang['th_TH']['FieldHolder']['Your name'] = 'ชื่à¸';
$lang['th_TH']['FieldHolder']['Your Email'] = 'ที่à¸à¸¢à¸¹à¹ˆà¸à¸µà¹€à¸¡à¸¥';
$lang['th_TH']['FieldHolder']['Your phone'] = 'หมายเลขโทรศัพท์';
$lang['th_TH']['FieldHolder']['Your Message'] = 'รายละเà¸à¸µà¸¢à¸”';
?>
You get the concept? Isn't it easy :)
Now you only need to replace the Your name, Your Email, etc with exactly the label text as you have entered it in the CMS for the form fields. In your (Eduardo's) case it will be "Empresa", "Rubro", "Contacto (nombre)"
$lang['en_US']['FieldHolder']['Empresa'] = 'Business';
$lang['en_US']['FieldHolder']['Rubro'] = 'Item';
$lang['en_US']['FieldHolder']['Contacto (nombre)'] = 'Contact (name)';
The code is implemented in a SS 4.3.1 site about wastewater treatment systems in Thailand in English, German, and Thai.
EDIT: As said, you do not need this if you use translatable in SS 4.3.2