Reputation: 1914
The SilverStripe Fluent mod seems to automatically translate all fields within a DataExtension
. To disable this I had to use: private static $translate = 'none';
.
Which is odd because when it comes to DataObjects
it works the opposite way: nothing is translated automatically, only the fields you explicitly tell to be translated.
Is it possible to disable this automatic translation behaviour of the SS-Fluent mod? It would also be interesting to know what other stuff Fluent automatically translates.
Upvotes: 2
Views: 840
Reputation: 46
Just building on Barry's answer; Fluent doesn't translate extensions, it translates DataObjects, and will by default automatically translate fields on the dataobject that match the Fluent.data_include
rules. Think of it as extensions pushing fields into the dataobject itself, which fluent sees as being owned by that extended object, rather than the extension itself.
The issue you're running into is the automatic translate behaviour, where translate
isn't defined. You can follow Barry's answer to solve this for individual objects.
If you want to globally disable all automatic field translations, you can copy the values from Fluent.data_include
to Fluent.data_exclude
. A field type in this list will not be include for localisation (even if in Fluent.data_include
).
---
Name: myfluentconfig
After: '#fluentconfig'
---
Fluent:
data_exclude:
- 'Text'
- 'Varchar'
- 'HTMLText'
- 'HTMLVarchar'
This means that if you have a dataobject (or extension) like below, it won't get automatically translated.
class MyObject extends DataObject {
private static $db = [
'Name' => 'Text'
];
}
Upvotes: 2
Reputation: 3318
In the code...
In silverstripe any static array can be set in the code, so yes adding this to _confip.php
Config::inst()->update('MyDataObject', 'translate',<SET ME HERE>);
...will work making sure to set the required value!
If you want to add the same thing into config.yml then...
MyDataObject:
translate:
- 'FieldOne'
- 'SomeOtherField'
...this is covered in more detail in https://github.com/tractorcow/silverstripe-fluent/blob/master/docs/en/configuration.md
Upvotes: 3