Multilingual Content - alternative to 'translatable'

if you want the forms, such as shown on the checkout page, multilingual, then, as a first step, you need to enable i18n.

That alone is not enough though. In the trunk ecommerce module many (but not all) displayed strings are i18n enabled, however even if the translation exists, SS does not find it, and thus not display it (SS 2.3.1).

Fortunately that is not difficult to fix. Let's take for example the checkout form, personal details. That part of the form is defined in ecommerce/code/model/EcommerceRole.php, and is not i18n enabled yet. The textfields are defined with

new TextField('FirstName', 'First Name'),

which needs to get changed to

new TextField('FirstName', _t('Member.FIRSTNAME','First Name')),

here is the complete modified function:

/**
* Return the member fields to be shown on order forms.
* For orders made by existing members, this will be called on that member.
* For new orders, this will be called on the singleton object.
*
* Modified by Kalileo 2009-04-15
* to include " _t('Member.FIRSTNAME','First Name'),"
* instead of "new TextField('FirstName', 'First Name'),".
* at the relevant fields in order to enable i18n automatic translations
*
* This will use the existing translation in "Member." and "OrderInformation.ss."
*/
function getEcommerceFields() {
$fields = new FieldSet(
new HeaderField(_t('OrderInformation.ss.CUSTOMERDETAILS','Personal Information'), 3),
new TextField('FirstName', _t('Member.FIRSTNAME','First Name')),
new TextField('Surname', _t('Member.SURNAME','Surname')),
new TextField('HomePhone', _t('OrderInformation.ss.PHONE','Phone')),
new TextField('MobilePhone', _t('OrderInformation.ss.MOBILE','Mobile')),
new EmailField('Email', _t('OrderInformation.ss.EMAIL','Email')),
new TextField('Address', _t('OrderInformation.ss.ADDRESS','Address')),
new TextField('AddressLine2', ''),
new TextField('City', _t('OrderInformation.ss.CITY','City')),
new DropdownField('Country', _t('OrderInformation.ss.COUNTRY','Country'), Geoip::getCountryDropDown(), self::findCountry())
);
$this->owner->extend('augmentEcommerceFields', $fields);
return new CompositeField($fields);
}

with that code a call to e.g. domain.tld/de/checkout/?flush=1 should now show the labels of these fields in German (assuming your cart is not empty).

I hope this helps you to find the required modifications in your code.

Hi,
I am trying to use the recipe and
I've already changed the protected function to public function getField($field) { ... as suggested but
still getting a Fatal Error: Class 'MultiLingual' not found.

To add to my post to posts above, this ticket http://open.silverstripe.com/ticket/3400 explains why often it is (still) necessary to use the long form of the i18n function _t() as in _t('Member.FIRSTNAME','First Name') and not only the short form _t('FIRSTNAME','First Name')

The short form will apparently work also in nested templates not before 2.3.3. However you can always apply the fix Henk Poley describes in that ticket . Thanks Henk Poley!

Hi Apophenian:
I did create the Multilingual class and everything as the wiki and eventually gave up trying to implement this workaround.
My problem however is solved with the latest beta release 2.3.2 and translatable seems to be working again.
Thanks for your response anyways!
Cheers
Cem

Is there a way to display custom includes evaluating the current language?
I find this very difficult to do, and since i'm not a programmer, all that i've tried was messing up the layout or giving me errors...

All i need is to have a conditional that evaluates current language, to display a custom sidebar, wich now is an include from Page.ss.

If anyone can post here a way to evaluate the language inside the .ss files to include another, that would be great !