Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Most of this looks fine - except:
elseif ($op == t('Delete content type')) {
// Delete strings.
tt("nodetype:type:$type:name", NULL, NULL, TRUE);
tt("nodetype:type:$type:help", NULL, NULL, TRUE);
}
It looks like these do actually call i18nstrings_remove_string() via i18nstrings_update_string() via tt() - but it'd be a lot more self documenting to just use i18nstrings_remove_string() directly.
Comment | File | Size | Author |
---|---|---|---|
#6 | i18n_356535.patch | 6.73 KB | catch |
#5 | i18n_356535.patch | 6.67 KB | catch |
#2 | i18n_356535.patch | 6.31 KB | catch |
#1 | i18n_356535.patch | 3.35 KB | catch |
Comments
Comment #1
catchA few issues cropped up when patching this:
i18nstrings_remove_string() can't currently be used by itself to remove a string unless you call i18ncontext() first - I added a call inside the function to match i18nstrings_update_string() in order to allow this.
The body, title, description and name labels were all saved/updated inconsistently - these are now added and updated in all cases where the content type form will be saved.
The existing code to delete strings didn't cover the case where the 'delete' link is clicked from admin/content/types rather than the content type form itself - I've moved all that into hook_node_type(), and added the extra strings to the delete case as well.
Did a fair bit of manual testing of this and it seems to be working fine.
Comment #2
catchBetter patch which uses hook_node_type for insert, update and save - removes most of the form_alter() and a lot simpler.
Also implemented the missing hook_menu_alter() so that node types are translated on node/add and found some other cleanup as well.
Still TODO - get the help properly hidden at node/add/TYPE for english - at the moment both English and the translation are shown.
Also the existing hook_menu_alter() needs cleanup to not foreach through all the router items. I think most of this could be handled in follow-up patches though.
Comment #3
Jose Reyero CreditAttribution: Jose Reyero commentedThe patch looks good.
There's this help text issue though. The previous approach allowed to set the help text to blank, then produce our own help text for node/add, See i18nstrings_ts() comments (recently added) about it.
I see no other way to remove that help text, so I think we should keep that one, unless someone has a better idea to skip that text showing up (AFAIK the help system doesn't allow anything to hook into it...)
Comment #4
catchHi Jose, yes the help needs reintegrating back into this, I'd started working on re-incorporating this into hook_node_types() but not got very far, so this didn't make it into the published patch (and hence CNW is the right status).
Comment #5
catchI moved the help handling to hook_node_type() as well. While the db_query() isn't very nice, it keeps as much as possible in one place, and means we only need the form_alter() to replace the #default_value text (which would otherwise be empty). This is working the same as in -dev now from my testing. We could add this back into a #submit handler, but it saves a few lines of code doing it this way I think.
Comment #6
catchNeeded re-rolling for the change from ts() to i18nstrings_ts().
Comment #7
Jose Reyero CreditAttribution: Jose Reyero commentedLooks great, thanks.
Committed with a few minor changes (checking value of help text, removing string if empty)