Untranslated strings in devconnect_user apigee module Drupal 7

1 0 163

Hello,


I'm working with apigee devportal and one of the bugs I've received from our QA team is the there are some English text stuck in the Arabic language!

So at first I figured it might be an extra module that would override the string but none of that was found!

After more digging(Debugging) I found that you module(devconnect_user) is using hook_menu_local_tasks_alter() to replace three tabs of the user profile which in my case is this string

'Edit User Profile' and there are more for the view and the openid:

$data['tabs'][$i]['output'][$j]['#link']['title'] = 'Edit User Profile';


Anyway solving this is easy .. just passing these title via t() is the answer but doing directly in module would work but I'd rather not do that since it is like a contrib module of Apigee .. so if they didn't edit that from their source then the answer is to write your own custom hook_menu_local_tasks_alter it is what I did in my project only adding what's missing t() in the title .. it will be something like this:

/**
 * Implements hook_menu_local_tasks_alter().
 */
function yourmodule_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if (arg(0) == 'user' && array_key_exists('tabs', $data) && is_array($data['tabs'])) {
    if (isset($data['tabs'])) {
      foreach ($data['tabs'] as $i => $menu_item) {
        if (array_key_exists('output', $menu_item) && is_array($menu_item['output'])) {
          foreach ($menu_item['output'] as $j => $sub_item) {
            switch ($sub_item['#link']['path']) {
              case 'user/%/edit':
                $data['tabs'][$i]['output'][$j]['#link']['title'] = t('Edit User Profile');
                break;
            }
          }
        }
      }
    }
  }
}

There will be a question of the hooks weight here but from what I can tell the custom will be the first to run and replace what the devconnect is putting what's why I'd prefer you guys fix that from the module itself .. or is there a place where I can patch this for you in a git? like what's happening in drupal.org

Hopefully this gets fixed and this article can help someone.

Essam

Version history
Last update:
‎10-10-2019 01:14 AM
Updated by: