Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

how to correctly install translatable


Go to End


7 Posts   3809 Views

Avatar
kochab2

Community Member, 5 Posts

18 November 2012 at 8:22pm

hi,
I am following the instructions for installing the translatable module from github, using the latest master from the repository:

https://github.com/silverstripe/silverstripe-translatable/blob/master/docs/en/index.md

I do not understand this section:

Through $extensions

:::php
class Page extends SiteTree {
static $extensions = array(
"Translatable"
);
}

where is this supposed to go?

If I do not add it, I can install translatable but clicking on the "Create" translation page does nothing.

any hint appreciated,
thanks,

kochab

Avatar
martimiz

Forum Moderator, 1391 Posts

19 November 2012 at 12:58am

Hi Kochnab2,
First of all: ignore the :::php bit: this is a directive for the sintaxhighliter in the docsviewer application, that doesn't work on GitHub.

The translatable module is basically an extension (decorator) that you have to enable for it to work. As the helpfile says: there are more ways to do this, but it's 'either or', not 'and'. So adding this to your mysite/_config.php file should do the trick:

Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');

Mind to do a /dev/build?flush=1 afterwards. The fact that you can create a translation Seems to indicate that the module is installed, so something else is going wrong. You say create translation does nothing. Do you get any errormessage? What version of SilverStripe are you using?

Avatar
kochab2

Community Member, 5 Posts

13 December 2012 at 3:35am

Thank you very much,
I am using silverstripe 3.0.2, I tried upgrading to 3.0.3 but I get some issues in the backend, so prefer to stick with 3.0.2.
I made the changes to the _config file,

First I got this error:

PHP Fatal error:  Call to undefined method MySQLDatabase::isSchemaUpdating() in /data/www/cosmo3/silverstripe-translatable/code/model/Translatable.php on line 1201

so I commented that line out and the extension seem to be installed.

But in the backend, in the "Translations" tab,
when I click on the "Create" button to create a translation, nothing happens and I get no errors, I activated also the error log, but that shows nothing as well.

Any help appreciated. Thanks.

Avatar
kochab2

Community Member, 5 Posts

13 December 2012 at 3:46am

Ok,
I think I found the problem,
it looks like the "Create" button has the "name" attribute: action_createtranslation

which is defined in:

CMSMain.Translatable.js

but this javascript file is not included in the backend page,
do you know how to fix this?

Avatar
borriej

Community Member, 267 Posts

14 December 2012 at 2:16am

Edited: 14/12/2012 2:18am

im having the same problem on 3.02 with the latest translatable module... uploaded it under the name: translatable...
ran a dev/build?flush=1..

got error during dev/build..

Fatal error: Call to undefined method MySQLDatabase::isSchemaUpdating() in /url/translatable/code/model/Translatable.php on line 1201

now upgrading to 3.03 and see what happens..

Avatar
kochab2

Community Member, 5 Posts

14 December 2012 at 8:54am

yeah, if you comment that line out it looks like the install works, but then the javascript scripts are not included correctly in the backend.
Is anybody maintaining this module?

Avatar
Molodoi

Community Member, 6 Posts

9 January 2013 at 9:31am

Edited: 30/01/2013 2:17am

Hello,

Decompress your module and rename silverstripe-translatable-master to translatable.

Follow install process inspired of http://www.balbuss.com/

In your mysite/code/Page.php

<?php
class Page extends SiteTree {
static $extensions = array(
"Translatable"
);
some code ...

And add this line in your _config.php

LeftAndMain::require_javascript('silverstripe-translatable/javascript/CMSMain.Translatable.js');
//My exemple is for website translate in 3 languages
Translatable::set_default_locale('fr_FR');
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable'); // 2.4 or newer only
Translatable::set_allowed_locales(array(
'en_GB', //UK English
'nl_NL', //Ducth
'fr_FR' //French
)
);

Have a lot of fun ;)

The translation module is definitely not working or just simply page!

My error in the jquery notice in backend is :
Error Line 580 ../framework/model/MySQLDatabase.php

An Sql Error?... Just for

I can do some dev / build... nothing works...

I created a new PageType ContactPage with the code follow :

<?php
class ContactPage extends Page {

static $db = array(
'Mailto'=>'Varchar(100)',
'SubmitText'=>'Text',
'Nom'=>'Varchar(50)',
'Adresse'=>'Varchar(50)',
'Ville'=>'Varchar(50)',
'CP'=>'Varchar(50)',
'Region'=>'Varchar(50)',
'Pays'=>'Varchar(50)',
'Phone'=>'Varchar(50)',
'GPS'=>'Varchar(50)'
);

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.SoumissionForm", $myMailTo =new TextField('Mailto', 'Email du destinataire '));
$fields->addFieldToTab("Root.SoumissionForm", $mySubmitText = new TextareaField('SubmitText', 'Texte du mail'));

$fields->addFieldToTab("Root.Coordonnees", $myNom = new TextField('Nom', 'Raison Sociale'));
$fields->addFieldToTab("Root.Coordonnees", $myAdresse = new TextField('Adresse', 'Adresse'));
$fields->addFieldToTab("Root.Coordonnees", $myVille = new TextField('Ville', 'Ville'));
$fields->addFieldToTab("Root.Coordonnees", $myCP = new TextField('CP', 'Code Postale'));
$fields->addFieldToTab("Root.Coordonnees", $myRegion = new TextField('Region', 'Région'));
$fields->addFieldToTab("Root.Coordonnees", $myPays = new TextField('Pays', 'Pays'));
$fields->addFieldToTab("Root.Coordonnees", $myPhone = new TextField('Phone', 'Téléphone'));
$fields->addFieldToTab("Root.Coordonnees", $myGPS = new TextField('GPS', 'Coordonnées GPS : Latitude,Longitude'));

$translation = $this->getTranslation(Translatable::default_locale());

if($translation && $this->Locale != Translatable::default_locale()) {

$transformation = new Translatable_Transformation($translation);

$fields->replaceField('Mailto',$transformation->transformFormField($myMailTo));
$fields->replaceField('SubmitText',$transformation->transformFormField($mySubmitText));
$fields->replaceField('Nom',$transformation->transformFormField($myMailTo));
$fields->replaceField('Adresse',$transformation->transformFormField($myMailTo));
$fields->replaceField('Ville',$transformation->transformFormField($myMailTo));
$fields->replaceField('CP',$transformation->transformFormField($myMailTo));
$fields->replaceField('Region',$transformation->transformFormField($myMailTo));
$fields->replaceField('Pays',$transformation->transformFormField($myMailTo));
$fields->replaceField('Phone',$transformation->transformFormField($myMailTo));
$fields->replaceField('GPS',$transformation->transformFormField($myMailTo));
}

return $fields;
}

}
class ContactPage_Controller extends Page_Controller {

public function init() {
parent::init();

}

}

If someone have an idea to create and traduce a new type of page.

I'm really desperate... one month to work for nothing, my client project is on standby... what has become my favorite SS version 2.4.5...