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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Assigned: Unassigned » catch
Status: Active » Needs review
FileSize
3.35 KB

A 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.

catch’s picture

FileSize
6.31 KB

Better 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.

Jose Reyero’s picture

Status: Needs review » Needs work

The 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...)

catch’s picture

Hi 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).

catch’s picture

Status: Needs work » Needs review
FileSize
6.67 KB

I 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.

catch’s picture

FileSize
6.73 KB

Needed re-rolling for the change from ts() to i18nstrings_ts().

Jose Reyero’s picture

Status: Needs review » Fixed

Looks great, thanks.

Committed with a few minor changes (checking value of help text, removing string if empty)

Status: Fixed » Closed (fixed)
Issue tags: -i18n sprint

Automatically closed -- issue fixed for 2 weeks with no activity.