symfony-cmf/create-bundle

Handle translations

dbu opened this issue · 4 comments

dbu commented

Right now, in a multilanguage setup, create just edits the page in whatever locale it currently is. This is fine as long as a translation already exists. But if i requested the page in german and the content only exists in english, i will always edit the english version, i can not create the french translation.

It would be cool to have a widget to configure if i am updating the english text or creating the french translation at this point. We could then map that onto the locale field of the document. imo it makes no sense to offer all available locales, just the choice between the requested local and the locale we actually got.
another feature could be to delete the current translation, i.e. if created accidentally.

this might profit from bergie/create#59, but maybe it would help if create.js would have explicit built-in understanding of locales.

This would be really cool..

We also have a more serious bug here.

  1. Goto http://cmf.liip.ch/en
  2. Edit something, save
  3. Goto http://cmf.liip.ch/de
  4. Edit something, save,

and woahh ... it saved the changes over the english version, not german.
Something has to do with caching first-accessed locale in js

I'm stuck with this problem right now and willing to help. But I'm new to this bundle. Any ideas how this can be fixed?

dbu commented

i think the "simplest" approach is:

  • map the field that holds the locale in the document in the rdf mapping (the user would have to do this)
  • render that field as hidden field (also the job of the user)
  • have a create.js plugin that adds a widget to the top toolbar to select the locale. configured with the available locales. this widget would read the current locale from that hidden field, and update the hidden field. this widget would be provided by this bundle.

i think once we have all that, it should be enough for phpcr-odm, as it respects the locale set on the document and saves it in a different language.

the point where it becomes hairy is with existing translations. if we change the locale to a different, existing locale and save, we overwrite the translation. maybe we should use the cmf_document_locales twig function to know which languages exist and distinguish that. we could provide the urls of those translations and define that the widget redirects to the other page if the translation already exists, but stays on the current page for new translations. (i hope you can follow - otherwise i can contribute the language url thingy once you have a pull request that works for choosing the locale)