Jump to content

Translation permission for editors


bfncs
 Share

Recommended Posts

Hello everyone,

is it currently possible to allow editors (so all kinds of non-superusers) to edit the translation files in the backend?

It doesn't look like it to me, because there are no permissions in the LanguageSupport modules. Or did I overlook something here? And if not: is it possible to work around this somehow?

Any help is appreciated.

Edit: Should I maybe ask this question more general (not coined to multilanguage) in another subforum?

Link to comment
Share on other sites

Hi, i think its possible but i did not test it yet.

Go to templates - show system templates - language (there is access tab).

And offcource Languages are normal pages in admin tree: Administration - Setup - Languages

Link to comment
Share on other sites

Thanks a lot for answering!

I tried it with the template rights (i.e. making language pages and/or admin pages editable by the specified group), but that didn't really work out. I suppose it should work by making a module that hooks into PagePermissions::viewable(), but I somehow thought there must be an easier way to do it.

Edit:

Here is some work in progress:

https://gist.github.com/boundaryfunctions/1d32ba61052a0ae32e02

This works great to allow to view the page with the permission. The only thing that is shown in the backend though is a warning: "TemplateFile: You don't have permission".

I debugged the code and there is a ProcessControllerPermissionException thrown when ProcessController::hasPermission() is called with an empty $permissionName - so it can only return true for the superuser. I single-stepped through all of it and there is no hookable method on the way to change that, not even a hacky one.

This also explains, why it dosn't help to give a non superuser permissions to view/edit pages with the "admin" template.

Any idea how I could still work around it and get this done? It would be really nice to allow some editors to translate without making them superusers. How do you approach relatively big multilanguage sites where you don't translate yourself then?

Link to comment
Share on other sites

The language translation tools are intended to be admin-only, so assigning permissions for that isn't supported by default. There are potential security implications with making it a default/supported capability. But it is something you could add relatively easily by editing the ProcessLanguage.module and ProcessLanguageTranslator.module files located in /wire/modules/LanguageSupport/. In the getModuleInfo() function of each, you'd want to add a 'permission' line, like this:

static public function getModuleInfo() {
  return array(
    'title' => __('Languages', __FILE__),
    'version' => 100,
    'summary' => __('Manage system languages', __FILE__),
    'author' => 'Ryan Cramer',
    'requires' => 'LanguageSupport',
    'permission' => 'language-edit' // ADD THIS LINE
    );
} 
Then in your admin, go to Access > Permissions and add a new permission called "language-edit". Give that permission to any roles you want to be able to use these tools. 
  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Hey Ryan,

thanks a lot, that worked perfectly!

I wouldn't even dare thinking about hacking the core normally, but in this case I think it is ok, because this is just a temporary change either way in my case. Really nice to see, how flexible the permission system can be.

I can understand that this being admin only is hard coded because of security considerations. Still it would be great to have this potentially available for users in some point in the future, especially for big websites that change a lot (in code).

With kind regards,

Marc

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...
My editor role can only edit/see non-default languages. Any idea how to enable editing the default language, too?

I did not edit the modules in the wire directory, but copied them to my site/modules directory, as I want to update the core in the future. 
Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...