In the current implementation actions parameters are being saved as a serialized array in the parameters field of the actions table.

It would be nice if there could be different settings for each language installed in the installation. For example, if I wanted a "Send email" action to be localized, I currently would have to create N separate actions with content translated to each of the N installed languages.

The attached patch saves and loads data using an array keyed by language.
This of course would break current configuration and could easily be fixed: an upgrade script could resave current settings into the new format, moving current $params to $params[$language->$language].

Comments

flevour’s picture

Version: 6.x-dev » 7.x-dev
StatusFileSize
new1.94 KB

Updated patch to 7.x.

flevour’s picture

Category: feature » task
Status: Needs review » Needs work

With latest patch, if you want to edit a specific language for an action, you just switch language. A problem comes up when you switch to a language for which no translated settings have been previously entered. Currently the form would be empty, while I think it should be filled with settings from another language to help translation.

The issue is how to pick up the "right" language to load default settings from. In fact, you can't always assume settings for the default site language have been entered first (or yes?).
I suggest trying this pseudo-code:
* when trying to load settings in language $lang for an action
* load settings $settings
* if $settings[$lang] is empty, try to load $settings[site_default_lang]. If this is empty too, load the first not empty language you find.

flevour’s picture

StatusFileSize
new2.5 KB

Updated patch based on the reasoning of previous comment. It implements a clever settings loading to avoid empty settings forms for existing actions.

Still missing an upgrade path for existing actions, but I'd leave that for when I get confirmation this patch is good to go in.
Anyway it'd be something like this:

$result = db_query("SELECT * FROM actions WHERE aid >= 1");
$default_language = language_default('language');
while($row = db_fetch_object($result)) {
  $params[$default_language] = unserialize($row->parameters);
  db_query("UPDATE actions SET parameters = '%s' WHERE aid = %d", serialize($params), $row->aid);
}
flevour’s picture

Status: Needs work » Postponed

As I work more through the code, I realize the real logic that needs to be changed is in includes/actions.inc. The whole patch here can be thrown away. I will currently postpone this issue until the #342983: Improve handling of $action object throughout Drupal core gets worked out.

Anonymous’s picture

Status: Postponed » Closed (won't fix)

Since there hasn't been much support for this in 3+ years, going to close.