Problem/Motivation

Custom Error messages are not translatable. The same message is used for all languages on a multilingual site. It should be possible, on a multilingual site, to provide translations of the custom error message.

The message are stored as configuration variables. The i18n module provides a mean to translate configuration variables. To support variable translations in Drupal 7, the i18n module uses the Variable module and require translatable variables to be defined using implementation of its hooks.

Proposed resolution

  • Implements hook_variable_info() and hook_variable_group_info() in a new customerror.variable.inc file in order to declare the configuration variables used to store custom error messages.
  • Use Variable function to retrieve variable values and build edit forms.

Remaining tasks

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#1 i18n_variables_support-1430600-1.patch9.33 KBpbuyle

Comments

pbuyle’s picture

Status: Active » Needs review
StatusFileSize
new9.33 KB
samw’s picture

Status: Needs review » Reviewed & tested by the community

Thanks - this patch was just what I was looking for and applied fine.

Out of coincidence, after applying this did you get any errors from the Variable module? I was getting an "Undefined index: module in variable_type_include() (line 428 of variable.module)" warning, which I suppressed with an if statement around that line? Not sure why I was getting that but it seemed to sort it out.

Would love to see this patch committed as it fits the bill perfectly!

gisle’s picture

Assigned: Unassigned » gisle

This is a duplicate of: http://drupal.org/node/1852620

Need to compare these to determine which patch provides the best solution.

gisle’s picture

Status: Reviewed & tested by the community » Needs work

Applied patch to commit 9ad93b4 on 7.x-1.x branch:

Just installing the patch produces a fatal error:

Fatal error: Call to undefined function variable_get_value() in .../customerror.module on line 316

Adding variables to the configuration produces the following warning:

Warning: Illegal string offset 'value' in customerror_page() (line 190 of .../customerror.module).
Warning: Illegal string offset 'format' in customerror_page() (line 190 of .../customerror.module).

This means that the patch needs work.

It is not clear to me why this module needs support for variable translations. The suggested patch adds dependency on another module, and this must be avoided for users not interested in having support for variable translations.

I'll leave this open as a placeholder, but this is not high priority for me.

gisle’s picture

Assigned: gisle » Unassigned

I am not going to work on this patch. Feel free to sign on if you're interested in working on it.

Working on this patch entails removing the Variables module dependency for users that does not want this dunctionality, making sure it applies cleanly to the latest dev snapshot, and providing documentation about how to make use of it.

pbuyle’s picture

Issue summary: View changes

Update description according to #4 and #5.

gisle’s picture

Issue tags: +Needs backport to D6

Also requested for the Drupal 6 version: http://drupal.org/node/1379098

gisle’s picture

Issue summary: View changes

Fix bad copy/paste

gisle’s picture

Issue summary: View changes

Inserted missing word.

_tarik_’s picture

Does it make sense to provide changes for a version compatible with Drupal 7 if it has an end life in November 2023?

gisle’s picture

While the announced EOL of Drupal 7 is November 2013, it may be extended further. A lot of the current owners of websites built with Drupal is not capable of upgrading to Symfony-based Drupal. I doubt the DA wants to alienate such a huge user base.

So a good patch or MR for this will be committed.