Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Proposal for translatable PHPCR documents (pages, blocks etc.) #4808

Closed
koemeet opened this issue Apr 16, 2016 · 6 comments · Fixed by #6717
Closed

[RFC] Proposal for translatable PHPCR documents (pages, blocks etc.) #4808

koemeet opened this issue Apr 16, 2016 · 6 comments · Fixed by #6717
Labels
Feature New feature proposals. RFC Discussions about potential changes or new features.

Comments

@koemeet
Copy link
Contributor

koemeet commented Apr 16, 2016

So we have a lot of translatable models right now, but some very important ones are missing, such as pages and menu nodes. I am currently trying to find a good strategy to handle this. Since we have the TranslatableInterface in the resource component, I was thinking about setting up translations in PHPCR this way. You also have multi-lang build in into the PHPCR ODM of Doctrine, but it has some serious drawbacks, such as not being able to load multiple translations of the same document in the same runtime (I think you can work around it by cloning etc, but still, it feels very different from how Sylius handles translations now).

What do you guys think about not using the translations mechanism Doctrine provides for us and simply have a separate document to store translatable fields, just as we do with products etc. We could for example store the translation documents in /pages/about-us/en, /pages/about-us/nl.

Being able to do the following would be awesome:

$page = new Page();
$page->setName('about-us');

$translation = new PageTranslation();
$translation->setLocale('en');
$translation->setTitle('About us');
$translation->setBody('Content in English');
$page->addTranslation($translation);

$translation = new PageTranslation();
$translation->setLocale('nl');
$translation->setTitle('Over ons');
$translation->setBody('Content in het Nederlands');
$page->addTranslation($translation);

$dm->persist($page);
$dm->flush();

$page->getTranslations(); // would return "PageTranslation" documents

Would love to hear any ideas or feedback on this!

I will probably have this finished for myself on Monday, if this approach is preferred, I will be glad to open source it and provide a PR with the implementation for this.

@koemeet
Copy link
Contributor Author

koemeet commented Apr 18, 2016

This works btw nicely with the CreatePHP library and the routing endpoints CMF provides for us. So you can also inline edit the content for the locale your currently looking at in the online store 👍

@koemeet koemeet changed the title [RFC] Translatable pages/content strategies [RFC] Proposal for translatable PHPCR documents (pages, blocks etc.) Apr 18, 2016
@michalmarcinkowski michalmarcinkowski added RFC Discussions about potential changes or new features. Feature New feature proposals. labels Apr 18, 2016
@gabiudrescu
Copy link
Contributor

@steffenbrem we are also interested in this. currently, we handle PHPCR content translations by manually creating two entities for the locales we support.

having them translatable, just like products, would be great.

please let us know what's the progress of this and if there is something we can help with.

@koemeet
Copy link
Contributor Author

koemeet commented May 9, 2016

@gabiudrescu I've made some good progress on this and currently had to rush an implementation for a client of mine that had to be done quite quickly. I am planning on making a PoC PR in the coming days. I also had some discussion in doctrine/phpcr-odm#704 about Sylius PHPCR translations.

@ibasaw
Copy link
Contributor

ibasaw commented Jul 28, 2016

news ?

@koemeet
Copy link
Contributor Author

koemeet commented Jul 28, 2016

@ibasaw The discussion about this moved to doctrine/phpcr-odm#704, right now I have a working solution running in production. When things are cleared up I could work on a PR to integrate it into the main Sylius repo. There are some important things that need to be considered, such as migrating existing data etc. it has to be a minimum effort without weird stuff going on to do those migrations if we would include this in Sylius.

@koemeet
Copy link
Contributor Author

koemeet commented Sep 9, 2016

Right now I stopped using PHPCR all together, so I don't think I will be able to make my old changes ready for Sylius. Jackrabbit was too slow for me in the end and using a MySQL database worked way better, even though hierarchies are not managed very well in it. Using the doctrine-dbal driver is not really worth the extra overhead (since you won't have much of the phpcr features) and Jackrabbit on 5-10ms per query (because of the Davex layer) was simply not acceptable.

I don't know which way Sylius wants to go with it's CMS features, if it really wants to stick with phpcr-odm I could integrate my work when I have some free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature proposals. RFC Discussions about potential changes or new features.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants