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

Translations are going too deep #44

Closed
AIC-BV opened this issue Sep 29, 2022 · 8 comments · Fixed by #51
Closed

Translations are going too deep #44

AIC-BV opened this issue Sep 29, 2022 · 8 comments · Fixed by #51

Comments

@AIC-BV
Copy link
Contributor

AIC-BV commented Sep 29, 2022

When adding a key to the $translatable array:

$translatable = [
    'title', 'image', ...
];

I noticed that the translation is picking up all title/image/... fields
What I mean with this is that when you have the following structure (simplified it):

title:
    label: Title field
repeater:
    form:
        fields:
            data:
                type: nestedForm
                    form:
                        fields:
                            title:
                                label: Title field in repeater

The translation will pick up [title] but also repeater[x][data][title].
Meaning [title] will always have the value of repeater[lastIndex][data][title].
This also occurs with my image (which I posted about in Discord), which is why when removing [image] is not working because the translation is saving repeater[lastIndex][data][image] in my [image] field

I would expect it would only pick the title/image field located in Plugin[image] and that fields inside a jsonable field are ignored.

The workaround is to create unique keys. Instead of title in repeater, use repeater_title, ...
Note that repeater[x][data][title] is also getting the locale switcher thingy

image
Note how RLTranslate sets image on the Blog[image] but also on Blog[blocks][0][data][image]
image

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Sep 29, 2022

Found this old post, must've had the same issue months ago: wintercms/winter#448 (comment)

@mjauvin
Copy link
Member

mjauvin commented Sep 29, 2022

Are you using the latest version of the plugin?

@mjauvin
Copy link
Member

mjauvin commented Sep 29, 2022

This line was added to prevent exactly that:
https://github.com/wintercms/wn-translate-plugin/blob/main/classes/EventRegistry.php#L133

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Sep 29, 2022

Yes i'm on the latest version. I have that line in the Class EventRegistry.php

Composer.json has "winter/wn-translate-plugin": "~2.1.1",
CMS -> Plugins -> Translate says its only 2.1.0
I ran composer update and winter:up but nothing changed

@mjauvin
Copy link
Member

mjauvin commented Sep 29, 2022

When you're in the create form, do you see only the top most title field with the localePicker (language selection) or do you also see this when creating the nested form title entry?

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Sep 30, 2022

It is also within the nested form title entry
image

LukeTowers added a commit to wintercms/wn-test-plugin that referenced this issue Dec 18, 2022
…dgets at once

Attempted to add a test for wintercms/wn-translate-plugin#44 but was unable to replicate the issue.
@AIC-BV
Copy link
Contributor Author

AIC-BV commented Dec 19, 2022

title:
    label: Title field
repeater:
    form:
        fields:
            data:
                type: nestedForm
                    form:
                        fields:
                            title:
                                label: Title field in repeater

Probably cleaned code a little bit too much in my code example, fields need to be in a nestedform -> form -> tabs -> fields -> x, where 'tabs' seem to be the cause @LukeTowers

So 'tabs' need to be added in the code above for the bug to happen

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Jan 24, 2023

Can someone please look in to this? I'm willing to pay for the fix.
@mjauvin @LukeTowers @bennothommo @jaxwilko
wintercms/wn-test-plugin#14

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