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

Custom field translation #950

Merged
merged 30 commits into from
May 6, 2020

Conversation

micahmills
Copy link
Collaborator

Added Translation fields to Custom Fields so you can add a custom translation to an existing key, or add a translation to your custom fields.

I also updated all (or I got them all) of the usages of the label key on the front-end.

@micahmills
Copy link
Collaborator Author

I am not sure why the build failed, If anyone can figure out what the error in TravisCI is that would be a huge help.

@corsacca
Copy link
Member

Thanks @micahmills
I briefly looked through the changes. Looks like a lot of front end checks.
I wonder about replacing the translations when the fields object is being build instead of on the front end.

@corsacca
Copy link
Member

I'm also not sure why the travis version of the script.min.js is different than the one we are generating. I'll look at it more later

@micahmills
Copy link
Collaborator Author

replacing the translation when the object is created is probably a better option. I am not actually sure where/when that object is created though.

@corsacca
Copy link
Member

Have a look at the dt_custom_fields_settings_after_combine filter.
example: dt-contacts/contacts-post-type.php:753

@micahmills
Copy link
Collaborator Author

I am not sure why the minified script files are failing in Travis. I have merged master in and run gulp. Everything seems to be up to date, but Travis doesn't like it for some reason.

@micahmills
Copy link
Collaborator Author

micahmills commented Apr 28, 2020

@mikeallbutt found a bug with this PR as it stands. If the DT instance is in Language A, but the user has his language set to Language B. If he goes into the Admin and adds a translation for Language B it will appear in the default field as well. This is because we are using the "dt_custom_fields_settings_after_combine" hook in dt-contacts/contacts-post-type.php:753 to update the object label with the translated version when we create the Object, that then populates the default text input instead of the the actual default language. If the user then saves the input in this state it will make the translation the default label instead of the original.

@corsacca
Copy link
Member

I think a pull from master will resolve the phpcs issue.
We had removed the package-lock.json, but travis needs it so it uses the same packages.

@micahmills
Copy link
Collaborator Author

so far this makes the Custom Fields, and Custom Tiles translatable in the Admin UI. I just need to add the Custom Lists.

@micahmills
Copy link
Collaborator Author

@mikeallbutt found a bug with this PR as it stands. If the DT instance is in Language A, but the user has his language set to Language B. If he goes into the Admin and adds a translation for Language B it will appear in the default field as well. This is because we are using the "dt_custom_fields_settings_after_combine" hook in dt-contacts/contacts-post-type.php:753 to update the object label with the translated version when we create the Object, that then populates the default text input instead of the the actual default language. If the user then saves the input in this state it will make the translation the default label instead of the original.

This bug should be fixed as well. You can now change the default label if your user isn't using the default language.

@corsacca
Copy link
Member

corsacca commented May 5, 2020

Brilliant @micahmills !
I'd love to see the changes also applied in the groups-post-type.php and dt-posts>custom-post-type.php. I think it would just be adding the filters.

@corsacca
Copy link
Member

corsacca commented May 5, 2020

Just for debugging and aesthetics (and maybe clarity when reading the code):
What do you think about nesting the translations under a "translations" key?
Screenshot from 2020-05-05 09-52-14

@corsacca
Copy link
Member

corsacca commented May 6, 2020

For some reason i can't set the translation for group field names like group type.
It refreshes and stays blank:
image

@corsacca corsacca merged commit 941cd47 into DiscipleTools:master May 6, 2020
@corsacca
Copy link
Member

corsacca commented May 6, 2020

@micahmills i look forward to using this feature! thank you!

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.

None yet

2 participants