Posted by asak on June 29, 2009 at 8:49am
2 followers
| Project: | Advanced Help Injection and Export |
| Version: | 6.x-1.0-alpha6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
Great great module - was lacking i18n support, quick patch to fix:
(Please review - not sure this is optimal...)
Enjoy!
(This will search the current language, find out if the help text (i.e. node) is in the current language, and if not it will replace it with the translated node and path so the link always shows helps in the CURRENT browser language, of course it depends on the multilingual settings of your site...)
| Attachment | Size |
|---|---|
| patch.i18n.patch | 1.21 KB |
Comments
#1
Thanks. First comment - you're changing two things here, and that's generally not a good practice for submitting patches. You're doing the i18n thing (an obvious bug), and you're deciding that there shouldn't be a popup window. The second part needs to be taken out of the patch so that we just focus on fixing the bug.
#2
Sorry 'bout that - added support for Popups API (added "popups" class) on my site and missed that in the patch...
Attached a cleaner one
#3
So my next complaint is that we can probably cut down on the extra path* variables.
<?php
function theme_helpinject_topic($nid) {
if (user_access('view advanced help popup')) {
+ global $language;
$node = node_load($nid);
// get rid of this... see below
+ $path = 'node/' . $node->nid;
+ // Check if current language is the help language, if not switch the node
+ if ($node->language != $language->language) {
// don't need this line
+ $path2 = array();
// here's how we get rid of $path
+ $path2 = translation_path_get_translations( 'node/' . $node->nid);
+ $path3 = 'helpinject/' . $path2[$language->language];
+ }
+ else {
+ $path3 = 'helpinject/node/' . $node->nid;
+ }
drupal_add_css(drupal_get_path('module', 'advanced_help') . '/help-icon.css');
- return l('<span>' . t('Help') . '</span>', "helpinject/node/$nid", array(
+ return l('<span>' . t('Help') . '</span>', $path3, array(
// maybe try something like
if ($translations = translation_path_get_translations( 'node/' . $nid)) {
$path = 'helpinject/' . $translations[$language->language];
}
else {
$path = 'helpinject/node/' . $nid;
}
?>
#4
@asak - do you want to pursure this further? Your help is appreciated.