-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Allow properties of jsonable attributes of a model to be translatable #21
Comments
@bennothommo any thoughts? |
If I remember correctly, the current architecture does not really make this possible... but I'd LOVE if this was implemented, it would solve so many problems for my use case. |
I'd say it wouldn't be possible simply because of the lack of IDs in the JSON-able data - you'd essentially have to copy the entire JSON data over for each translation and link it to the main record. In this scenario, it would be structurally better to use a related model with translatable fields. |
@bennothommo Another option I thought of would be to store the translations right in the JSON. Like having |
@multiwebinc that could work. We'd have to establish (in the docs, perhaps?) that the developer will need to account for this extra data if they go down this route, and use a larger data format column (like say a BIGTEXT column in their database), but it's certainly within the realm of possibility. |
yeah, but the beauty of the Translate plugin is that if you disable it, the
data is unchanged (all translations are stored in external tables)
…--
Marc
On Sun., Jan. 30, 2022, 20:56 Ben Thomson, ***@***.***> wrote:
@multiwebinc <https://github.com/multiwebinc> that could work. We'd have
to establish (in the docs, perhaps?) that the developer will need to
account for this extra data if they go down this route, and use a larger
data format column (like say a BIGTEXT column in their database), but it's
certainly within the realm of possibility.
—
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPLTPURPM33XB6UIWIDYJ3UYXT47ANCNFSM5MZVWE7Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@bennothommo Presumably for columns that contain JSON, people should be using the JSON type (i.e. @mjauvin Good point. I can't really think of a truly elegant way to get around that because of the lack of IDs, but perhaps when the translate plugin has been disabled and someone tries to write to a translatable JSON field, present a confirmation dialog saying something like "The field you are editing is translatable, but the Translate plugin has been disabled or removed. Making changes will remove any translated strings." Maybe also recommending creating a backup, re-enabling the plugin, removing the |
@multiwebinc if the plugin is disabled, you wouldn't be able to inform the user about this, unless you have some exception handling code in wintercms core |
@mjauvin Yeah, I was thinking of putting it in the core. |
@mjauvin Another idea that just occurred to me is to add something like a |
I'd love to see this feature implemented, that would make using jsonable fields on multilingual websites possible. |
@multiwebinc @kubamarkiewicz I would appreciate it if you guys could test PR #76 |
That's great news, I'll test it! |
@kubamarkiewicz I added a comment in the PR's description to clone the branch directly in order to test this. |
@mjauvin I made some tests with repeater and nestedform fields and works almost perfectly! I have found only one problem. When I have repeater field configured as in the example that you have included in Readme.md then when I save translations and reload the form, then when I switch the language in 'Job Title' field, the value does not change.
|
It would be also great if translations for 'blocks' field type could be implemented in a similar way. There is a difference however, because in that case there is no possibility to configure 'translatable' property in the controller and I have suggested adding 'translatable' property in fields definition in yaml: wintercms/wn-blocks-plugin#25 Do you think that would be possible? |
@kubamarkiewicz I was missing This is needed in order to fetch the right version of the data for the selected locale. |
Once this gets released, we'll look into adding support to the blocks plugin. |
@mjauvin ok, now the example in Readme.md works correctly. |
@mjauvin I made some more in depth testing of repeater field and I have found a problem with reordering items: when there are two items saved in a repeater field, when I reorder them and refresh the page, the fields that are translatable (in this case 'Job title') appear in wrong items: |
Interesting find. If you can continue those within the PR itself, that would be appreciated. |
Would it be possible to allow alternative syntax to specify translatable fields inside .yaml file? fields:
data[contacts]:
type: repeater (or nestedform)
translationMode: fields
form:
fields:
name:
label: Name
translatable: true
title:
label: Job Title
translatable: true
phone:
label: Phone number The goal is to be able to define jsonable fields entirely in fields.yaml file without necessity to modify the model file. The syntax could be similar to the proposed syntax for translations in blocks plugin: wintercms/wn-blocks-plugin#25 What do you think about it? |
I wanted to do that as well... thanks for confirming this not only makes sense to me. |
@mjauvin definitely it makes sense! |
I think this would be a good idea to allow properties of jsonable attributes to be translatable. This would allow you to translate specific sub-fields of a repeater to be translated. For example:
Model:
Then in the yaml:
If someone could give me some direction on how to even get started, I might be able to get a PR for this.
The text was updated successfully, but these errors were encountered: