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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObject + TranslatableDataObject + ModelAdmin


Go to End


4 Posts   2176 Views

Avatar
moniuch

Community Member, 11 Posts

16 August 2015 at 9:27pm

It's SS 3.1.13, Translatable 2.0.8 and TDO dev-master.
I have two DO classes: "Facility" ($has_one) and "FacilityType" ($has_many) with which I chose to be managed in ModelAdmin (as they are global properties of the site owner). I cannot however get TranslatableDataObject extension to enable translation for them, despite reading carefully the setup instructions: https://github.com/bummzack/translatable-dataobject

Here's my config:
// Set the site locale
i18n::set_locale('en_US');

SiteConfig::add_extension('Translatable');

// Set allowed locales
Translatable::set_allowed_locales(array('en_US', 'pl_PL'));
TranslatableDataObject::set_locales(array('en_US', 'pl_PL'));
Facility::add_extension("Translatable");
Facility::add_extension("TranslatableDataObject"); // tried "TranslatableDataObject('Title')" as well
FacilityCategory::add_extension("Translatable");
FacilityCategory::add_extension("TranslatableDataObject");

Could anyone please confirm that this setup should or won't work for me?

Avatar
Pyromanik

Community Member, 419 Posts

17 August 2015 at 10:54pm

Edited: 17/08/2015 10:58pm

Ensure to have Translable module installed too, and to set_default_locale, not just set_locale.

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

I'm not too experienced with these modules, but it looks like it should work. The best way is to try it and see :)

Avatar
moniuch

Community Member, 11 Posts

18 August 2015 at 11:13am

I'm so sorry - no go. It did not help.

Avatar
Pyromanik

Community Member, 419 Posts

19 August 2015 at 2:51am

Hmm, it should work but just in case: try setting the extensions via the YML config

Also, have you added translation content for the locale that isn't the default? You need to add this via the CMS first before it will load - otherwise it will probably just default to the default locale.