Comments (12)
I have zero experience with translatable, sorry! Let us know how you go
from silverstripe-blocks.
Here's a quick working GIST to support basic translatable fucntionality. It will create translated versions of blocks when translatlating a page
https://gist.github.com/thezenmonkey/6e6730023af553f12e3ab762ace3b08a
from silverstripe-blocks.
Thanks for that, I've added a note and link to your gist in the readme :)
from silverstripe-blocks.
How do you apply the posted TranslatableBlockPage
?
from silverstripe-blocks.
You need to add the Translatable extension to the Block. Once thats done either add the onTranslatableCreate() from the gist to your Page class or apply the DataExtension to your SiteTree. The reason it's seperate is because you may need modify the onTranslatableCreate() depending on your specfic requirements.
from silverstripe-blocks.
For me that crashes at
$block = $originalBlock->createTranslation($translatedPage->Locale);
Telling me that ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'createtranslation' does not exist on 'ImageOnlyBlock'
. (ImageOnlyBlock
is one of my custom blocks.)
Any ideas what I'm doing wrong? I'm using Silverstripe 3.3 and the most recent version of the silverstripe-blocks and silverstripe-translate plugin.
EDIT:
That's what I'm doing in my _config.php
(the relevant part of it):
// Enable Translateable module
Translatable::set_default_locale('de_CH');
SiteTree::add_extension('Translatable');
SiteConfig::add_extension('Translatable');
// Add support for translatable Blocks
SiteTree::add_extension('Page', 'TranslatableBlockPage');
So createTranslation
should be available when TranslatableBlockPage::onTranslatableCreate()
is triggered?
from silverstripe-blocks.
You also need to add the translatable extension to both the page and the block
from silverstripe-blocks.
Thank you, that's all I need. I just added Block::add_extension('Translatable');
and now it works.
from silverstripe-blocks.
While with that configuration every seems to work, it's still not possible to create new blocks and add it to another language then the default language.
For my case: At first all pages where created in the primary language de_CH
and then I used the Create Translation
button to translate all of them to en_US
. Everything seem to work back then. Now I tried to create a new block on an en_US
page and when I saved the block I didn't get any error message, but the block didn't appear in the front nor in the backend. So I looked up the block in the backend and found that it has the locale field set to de_CH
even if it was attach to an en_US
page. Once I manually changed the locale to the correct one, the block got displayed.
Can anybody give me an hint about how to write a DataExtension which fixes that newly created blocks get assigned the correct locale?
from silverstripe-blocks.
No ideas? I would just need to know where to hack in to correctly set the locale
field on the newly created block. Isn't there a way to catch "new block created" event using a DataExtension
?
from silverstripe-blocks.
Current Locale should be assigned via the Translatable extension by default whenever you create a new translatable dataobject.
from silverstripe-blocks.
Thank you, I'll try if updating the translatable plugin helps (maybe just some bug in their plugin?) and then ask if they could help me with my issue.
However, all I found yet, was that the form for creating a new block already contains the wrong locale. (So the POST request for creating the block sends always the primary language.)
from silverstripe-blocks.
Related Issues (20)
- No blocks tab in page view on SS 3.5.3 HOT 4
- Misleading draft button state
- SilverStripe 4 alpha7 versioning - incorrect namespace
- CMSFields error adding blocks to DataObjects HOT 1
- Blocks don't show in edit page view HOT 6
- Update composer requirements for Symbiote vendor
- Symbiote - namespacing vendor updates in use statements
- Class 'SilverStripe\Core\Object' not found in BlockManager
- BlocksSiteTreeExtension - references BlockSet `PageTypesValue`
- SS4 - used Versioned buttons in CMS
- release tag, please HOT 1
- BUG incorrect symbiote package names in 1.1 branch HOT 1
- Default block area HOT 1
- After duplicating block, content is linked in original & duplicated block.
- Dependent issue Symbiotic 4.x-dev HOT 3
- Using silverstripe-blocks with blog module
- compatible issue with silverstripe-gridfieldextensions 3.1.1
- Silverstripe 4.1 and the future? HOT 3
- SS 3.7.2 / PHP 7.2 Compatibility HOT 1
- multivaluefield 3 is SS4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silverstripe-blocks.