I've found some translation issues in content_permission module.

In the following cases i need placeholder, but I'm not sure if this is supported here. As an example - in German it must be translated to "@field_name bearbeiten" and "@field_name ansehen". As you can see we must move translated string of the hardcoded "edit " and "view " string to the end in German.

function content_permissions_perm() {
  foreach (content_fields() as $field) {
    $perms[] = 'edit '. $field['field_name'];
    $perms[] = 'view '. $field['field_name'];
  }
  return $perms;
}

...

function content_permissions_content_views_access($field_name) {
  return user_access('view '. $field_name);
}

Aside POTX generator struggles on this syntax, too.

Comments

karens’s picture

Status: Active » Postponed (maintainer needs more info)

The way it is done now is consistent with the way core handles node type permissions in the node.module, which I assume is the right example to follow.

I'm not quite sure what else to do with this.

hass’s picture

Project: Content Construction Kit (CCK) » Translation template extractor
Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: General » Code
Status: Postponed (maintainer needs more info) » Active

Could be an issue of POTX. So moving for now... i generated the POT files for node module myself and it does not contain this broken strings. Maybe Gabor could bring some light on this much quicklier.

modules-content_permissions.pot

#: modules/content_permissions/content_permissions.module:15
msgid "field_name"
msgstr ""

#: modules/content_permissions/content_permissions.module:16
msgid "edit "
msgstr ""

#: modules/content_permissions/content_permissions.module:17
msgid "view "
msgstr ""

modules-node.pot does not contain the node module permission strings... and i wasn't able to find them in general.pot or somewhere else.

gábor hojtsy’s picture

There is no way to have placeholders in permissions in Drupal 5 or 6. Feel free to code patches for Drupal 7! Therefore Drupal 5 and 6 potx can only extract literal permission names, not composite permission names. Since composite permission names do not have these placeholders, they are site dependent and cannot be generally translated. That's how it is. Feel free to provide a patch for a better way in Drupal 7!

hass’s picture

Well i thought this... but where are the composite permission names from node module gone?

In CCK the composite permission names are included in the POT files but the core node modules strings are not in any file!? Do you have any filter build in POTX that filters out composite permission names of core modules? In node.module i see $perms[] = 'create '. $name .' content';, but if i search all POT files for "create " or " content" i cannot find anything, but i should...

hass’s picture

I found it... node.module permissions are blacklisted in POTX. Should we write POTX patches for every contrib module? What is the plan about this for non-core modules?

function _potx_find_perm_hook($file, $filebase, $save_callback) {
  global $_potx_tokens, $_potx_lookup;

  if (isset($_potx_lookup[$filebase .'_perm'])) {
    // Special case for node module, because it uses dynamic permissions.
    // Include the static permissions by hand. That's about all we can do here.
    if ($filebase == 'node') {
      $line = $_potx_tokens[$_potx_lookup['node_perm'][0]][2];
      // List from node.module 1.763 (checked in on 2006/12/29 at 21:25:36 by drumm)

...
hass’s picture

Title: Translation issues with permissions » Blacklist composite permission names
gábor hojtsy’s picture

The plan is that some bright folk will submit patches for the next Drupal version to support composite permissions. Until then, we don't support that. The potx code which discovers permission names could be a bit more intelligent not to pick up 'create ' when it is part of a composite operation.

hass’s picture

Yep, hopefully we are able to find a workaround to filter/remove the composite permissions for 6.x POT files in a POTX 6.x-2.1 or a -dev soon...

I'm not deep enough in potx code to solve this quickly... For now I haven't touched the composite permissions strings in the German translation files of CCK... hopefully others won't try to translate them... but i'm sure this will happen soon in other translations...

gábor hojtsy’s picture

Status: Active » Closed (works as designed)

Submitted this issue against Drupal 7, so that we can get real translatable composite permissions in Drupal 7: http://drupal.org/node/313213 Please provide your feedback, support and review there. I've tried to make it as painless and simple as possible for non-composite permissions.

http://drupal.org/node/306402 exists to implement the new hook_perm() parsing in potx for Drupal 7, but until it looks like finalized, I am not beginning on doing that.

Marking this by design, since the issue is outside potx. Let's solve it in Drupal core!