When working on multilingual sites with permissions and roles. There is an issue where core translates the two build in role names, making it hard using "user_roles()" to match in code role names as the role names are translated depend on the language of the last person to export the roles.

This is especially an issue in modules like http://drupal.org/project/secure_permissions.

CommentFileSizeAuthor
#1 translate_role_names-2205581-1.patch747 bytescableman0408

Comments

cableman0408’s picture

Status: Active » Needs review
StatusFileSize
new747 bytes

The attached patch removes the translation.

cableman0408’s picture

Title: Don't translation build in role names » Don't translate build in role names
David_Rothstein’s picture

Project: » Drupal core
Version: » 7.x-dev
Component: Code » user.module

If they aren't translated there, where would they be translated though?

making it hard using "user_roles()" to match in code role names as the role names are translated depend on the language of the last person to export the roles.

Why is it necessary to match on role names, rather than matching role ID to DRUPAL_ANONYMOUS_RID and DRUPAL_AUTHENTICATED_RID?

cableman0408’s picture

It's strange that only core roles are translatable and as mentioned it gives issues in different contribute modules (e.g. secure permission, features etc.)

David_Rothstein’s picture

Title: Don't translate build in role names » Allow retrieving the untranslated versions of built-in role names
Category: Bug report » Task
Status: Needs review » Needs work

Right, I can see why modules that export role names have a different need here. For Features that issue is a more general one though (not just limited to user roles) and from what I can see is handled by http://cgit.drupalcode.org/features/tree/features.module?h=7.x-2.7#n1225

For secure_permissions it may be limited to user roles; I am not as familiar with that module but it looks to me like they already deal with it also.

If there's a need to get the untranslated role names for export purposes, one thing we could do is change the core user_roles() function to call a new function as a helper method - the new function could return untranslated role names and then user_roles() could continue to return the translated ones.

Regarding "only core roles are translatable", that's a different issue - see #598862: Custom user roles are not translatable in core alone (requires a contributed module)

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.