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

Fix: translation not running when set to sync #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hphoeksma
Copy link
Contributor

Fixes #28

@mficzel
Copy link
Member

mficzel commented Jul 10, 2023

fine by reading

@gradinarufelix
Copy link
Collaborator

I need to take a closer look at this case. If a language is configured to sync from another language, then nodes would automatically be adopted, without having to switch the language in the dimension switcher and hit “create and copy”.

@hphoeksma
Copy link
Contributor Author

I need to take a closer look at this case. If a language is configured to sync from another language, then nodes would automatically be adopted, without having to switch the language in the dimension switcher and hit “create and copy”.

Not sure what you mean. Do you mean when creating a new dimension preset the whole tree should be created? Because that isn't the case.

I created a command (in a separate package) that clones the whole node tree based on given dimensions and target dimensions and in that case the whole tree gets created, but without this fix nothing gets translated.

@gradinarufelix
Copy link
Collaborator

Sorry for the late reply.

If the configuration is set to sync, then the nodes are adopted/synced automatically as soon as the node in the source language is changed and published. But I don't know right now how it behaves if you change the configuration later when there is already content. E.g., you add another language dimension.

For that case, I wrote a sync command which can sync the whole content tree for a language. However, I did not publish it yet. I think this would be the better approach, wouldn't it? Say like you add another language dimension, and then you run the command to have a fully synchronized new language dimension.

Your PR is not wrong, though, but it would require doing the creation process through the language switcher for every document.

What do you mean?

@hphoeksma
Copy link
Contributor Author

Sorry for the late reply.

No problem.

If the configuration is set to sync, then the nodes are adopted/synced automatically as soon as the node in the source language is changed and published.

Somehow we had issues with this, which might be due to our setup (multiple dimensions - country & language).
I think what I ran into was documents being created and translated fine, but not the contents (which is done using adopting). That is why when syncing this should be run as well I think...?

Adding a new dimension set definitely did not work and I created a command to sync from one set to another set - I guess similar as you.

Mine looks like this:

    public function syncTree(string $siteNodeName, array $from, array $to): void
    {
        $from = json_decode(reset($from), true);
        $targetDimensions = json_decode(reset($to), true);

        /** @var Context $context */
        $context = $this->getContext('live', $from);
        $siteNode = $context->getNode('/sites/' . $siteNodeName);

        if (!$siteNode) {
            $this->output->outputLine('The sitenode could not be found, please check if you have the correct siteNodeName and if the from dimensions are available in your configuration.');
            $this->quit();
        }

        $documentNodeQuery = new FlowQuery([$siteNode]);
        $documentNodeQuery->pushOperation('find', ['[instanceof Neos.Neos:Document]']);
        $documentNodes = $documentNodeQuery->get();
        array_unshift($documentNodes, $siteNode);

        $this->output->outputLine('Found %s document nodes', [sizeof($documentNodes)]);
        $this->output->progressStart(sizeof($documentNodes));

        $newContext = $this->getContext('live', $targetDimensions);
        /** @var NodeInterface $documentNode */
        foreach ($documentNodes as $documentNode) {
            $newContext->adoptNode($documentNode, true);
            $this->nodeDataRepository->persistEntities();
            $this->output->progressAdvance();
        }
        $this->output->progressFinish();
        $this->quit();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use the 'sync' mode where translating first time
3 participants