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

Add translation capability #81

Merged
merged 55 commits into from Dec 16, 2011

Conversation

Projects
None yet
3 participants
@dbu
Member

dbu commented Dec 13, 2011

this adds translation annotations and functionality to the phpcr-odm. doc is included in the README.

as discussed on the mailing list:
https://groups.google.com/group/symfony-cmf-devs/browse_thread/thread/87349a31eb9f7eb2

this wil replace the MultilangContentBundle of symfony-cmf (https://github.com/symfony-cmf/symfony-cmf/wiki/MultilangContentBundle) => Note to self: clean up that wiki page once this is merged.

Daniel Barsotti and others added some commits Nov 18, 2011

Daniel Barsotti
Revert "allow locale-specific changesets"
This reverts commit 8eb12dc.

We don't need locale sensitive changesets in the UnitOfWork for now.
*/
public function getPreferredLocalesOrder($document, ClassMetadata $metadata, $forLocale = null)
{
if (is_null($forLocale)) {

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

you know me ... i always think its best to separate the error handling checks from the rest of the method logic.

This comment has been minimized.

@dbu

dbu Dec 15, 2011

Member

while i generally agree, in this case i do not really see how to do it here.
this is not more readable:

    if (! is_null($forLocale) && ! array_key_exists($forLocale, $this->localePreference)) {
        throw new \InvalidArgumentException("There is no language fallback for language '$forLocale'");
    }

    if (is_null($forLocale)) {
        $preferred = $this->localePreference[$this->defaultLocale];
    } else {
        $preferred = $this->localePreference[$forLocale];
    }

i commited a reversed order: exception at the end.

*/
public function setDefaultLocale($locale)
{
if (array_key_exists($locale, $this->localePreference)) {

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

here again ..

*
* @return array $preferredLocales
*/
public function getPreferredLocalesOrder($document, ClassMetadata $metadata, $forLocale = null);

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

interfaces should omit public

*/
abstract class AbstractTranslationStrategy implements TranslationStrategyInterface
{
/*** @var string */

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

two * are enough :)

public function saveTranslation($document, NodeInterface $node, ClassMetadata $metadata, $locale)
{
foreach ($metadata->translatableFields as $field) {

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

extra new line

*/
public function removeTranslation($document, NodeInterface $node, ClassMetadata $metadata, $locale)
{
foreach ($metadata->translatableFields as $field)

This comment has been minimized.

@lsmith77

lsmith77 Dec 13, 2011

Member

curly bracket should be on this line

@lsmith77

This comment has been minimized.

Member

lsmith77 commented Dec 14, 2011

@dbu: i added a bunch of comments .. also it looks like you may have to sync your branch with master.

@dbu

This comment has been minimized.

Member

dbu commented Dec 14, 2011

thanks @lsmith77 - one day we will have the code style coded right into our brains ;-)
i will clean those up tomorrow.

does anybody have worries about functionality or the interfaces? if code style cleanups are the only problem, this will be merged tomorrow :-)

dbu added a commit that referenced this pull request Dec 16, 2011

@dbu dbu merged commit 1c24c2f into doctrine:master Dec 16, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment