The Commerce project, specifically commerce_product_ui.module, adds menu callbacks like admin/commerce/products/add/product for each product type. It works like this:

  foreach (commerce_product_types() as $type => $product_type) {
    $items['admin/commerce/products/add/' . strtr($type, array('_' => '-'))] = array(
      'title' => 'Create !name',
      'title arguments' => array('!name' => $product_type['name']),
      'description' => $product_type['description'],
      'page callback' => 'commerce_product_ui_product_form_wrapper',
      'page arguments' => array(commerce_product_new($type)),
      'access callback' => 'commerce_product_access',
      'access arguments' => array('create', commerce_product_new($type)),
      'file' => 'includes/commerce_product_ui.products.inc',
    );
  }

Note how the 'title arguments' element takes care of inserting the product type name into the translatable string "Create !name". When I enable Administration Language this breaks, and all product creation pages get the literal title "Create !name".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

das-peter’s picture

Status: Active » Needs review
FileSize
542 bytes

Just stumbled over this and following adjustment (see patch) seems to fix the behaviour.

marcvangend’s picture

Thanks for looking into this. Maybe you can add a couple of lines of documentation? Even though it's only a 2-line patch, I don't understand what's going on...

das-peter’s picture

@marcvangend Added some documentation. Not sure if it really helps. The idea is to pass following condition on _menu_item_localize(): if (!$link_translate || ($item['title'] == $item['link_title'])) {
We need to ensure title and link_title are equal to re-run the translation process. While this seems to work I'm not entirely sure this is the right approach.

marcvangend’s picture

Thanks. It's a bit of a hack indeed, but at least the inline docs and your explanation here helps understand why it works.