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

Add translationMode option to MLRepeater & MLNestedForm formwidgets #76

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

mjauvin
Copy link
Member

@mjauvin mjauvin commented Feb 20, 2024

This allows translating internal fields of Repeater/NestedForm FormWidgets.

See `Repeater/NestedForm formwidget internal fields translation section in README.md for more details.

Fix #21

In order to test this, you can clone this branch with the following git command:

git clone -b wip-ml-repeater-fields git@github.com:wintercms/wn-translate-plugin.git plugins/winter/translate

@mjauvin mjauvin added this to the v2.1.5 milestone Feb 20, 2024
@mjauvin mjauvin self-assigned this Feb 20, 2024
@mjauvin mjauvin marked this pull request as draft February 20, 2024 01:55
@LukeTowers LukeTowers self-requested a review February 20, 2024 15:53
@mjauvin mjauvin changed the title Add translateFields option to MLRepeater formwidget. Add translationMode option to MLRepeater formwidget. Feb 21, 2024
@mjauvin mjauvin modified the milestones: v2.1.6, v2.1.7 Mar 19, 2024
README.md Outdated Show resolved Hide resolved
@mjauvin
Copy link
Member Author

mjauvin commented Mar 27, 2024

@kubamarkiewicz have you been testing this PR ?
Feedback welcome.

@kubamarkiewicz
Copy link

@mjauvin thanks for adding translatable property, I will test it tomorrow

@mjauvin mjauvin marked this pull request as draft March 27, 2024 17:22
@kubamarkiewicz
Copy link

@mjauvin I have tested nestedform with the translatable property in yaml file and it is working correctly! Thanks for adding it.
I have only found a minor css bug related to "fancy-layout" styles: only inside tabs language code has white color over white background so it is not visible, but it is working. I am not sure if this should be fixed in translation plugin or in winter cms styles. I will look for a css fix later.

Screenshot 2024-03-28 at 13 46 29

@kubamarkiewicz
Copy link

kubamarkiewicz commented Apr 2, 2024

@mjauvin I have done some more tests and have found a bug. When nested form/repeater definition is not placed in fields.yaml file but instead is located in a separate file and linked to the fields.yaml file like this:

fields:
    data[contacts]:
        type: repeater
        translatable: true
        translationMode: fields
        form: $/kubamarkiewicz/my_plugin/models/record/nested_fields.yaml

then the following error appears:

image

@mjauvin
Copy link
Member Author

mjauvin commented Apr 2, 2024

@kubamarkiewicz can you try the fix I just commited ?

Thanks for your help, much appreciated!

@kubamarkiewicz
Copy link

@mjauvin now it works! Thanks for the fix.

@kubamarkiewicz
Copy link

@mjauvin here it a css fix for the bug with "fancy-layout", that I have commented earlier:

kubamarkiewicz@9fb5c5c

@mjauvin
Copy link
Member Author

mjauvin commented Apr 4, 2024

@mjauvin here it a css fix for the bug with "fancy-layout", that I have commented earlier:

kubamarkiewicz@9fb5c5c

I added your css fix to this PR.

Thanks.

@nmiyazaki-chapleau
Copy link

nmiyazaki-chapleau commented May 22, 2024

I tried this PR with the stable version of wn-pages-plugin and saving a static page doesn't work at all because it cannot properly identify the static page title. The title field's translate input name ends up being RLTranslate[en][][viewBag][title], which feels wrong? Not sure, but it refuses to save.

@nmiyazaki-chapleau
Copy link

nmiyazaki-chapleau commented May 22, 2024

Static pages plugin sets its fields without arrayNames. The title formField's name is viewBag[title] without an arrayName value. This causes the method getLocaleFieldName in traits/MLControl (when isLongFormNeeded() is true) to implode an empty arrayName, thus causing the issue mentionned above.

I'm also realising this is probably normal since this is a BC and other plugins will need to update for this.

@mjauvin
Copy link
Member Author

mjauvin commented May 22, 2024

Static pages plugin sets its fields without arrayNames. The title formField's name is viewBag[title] without an arrayName value. This causes the method getLocaleFieldName in traits/MLControl (when isLongFormNeeded() is true) to implode an empty arrayName, thus causing the issue mentionned above.

I'm also realising this is probably normal since this is a BC and other plugins will need to update for this.

Thanks for reporting this.

I'll need to investigate further, but it might be required for me to cope for the case where the arrayName is not set. Otherwise, we're going to have to make a change to the pages plugin, but it should be doable in this PR.

If you want to experiement with a fix in this PR, please do so as I don't have much time to look into this at the moment.

@nmiyazaki-chapleau
Copy link

Just did PR #83 to fix the issue I mentionned, feel free to review.

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

Successfully merging this pull request may close these issues.

Allow properties of jsonable attributes of a model to be translatable
5 participants