Jump to content

Creating permission based access to field languages


Recommended Posts

Hi all,

A client needs 12x languages on Processwire - I've set this up and it works beautifully out of the box. Again Processwire is wonderful thing.

One thing they've asked for a way that languages are shown on fields on a per-user basis. This is so translators won't be able to accidentally edit the wrong language.

So for example:

A German translator will only be able to edit the German version of the fields.

Is this be possible? I know that you can set a default language for each user, but could there be a way to set this and therefore restrict their access to one language only.

Any help here would be massively appreciated as always.

Thanks!

  • Like 4
Link to comment
Share on other sites

LanguageSupport::hookInputfieldAfterRender is probably the place you're looking for, but it's currently not hookable, so that you can't change anything to it from the outside. The not so updates friendly alternative would be, that you copy the module to the site/modules/ directory to use your own altered version of it, which is possible with the the dev branch.

Link to comment
Share on other sites

I also have a client requirement to be able to limit content managers per language. They want to be able to give access to translators for each language and give them permission to view the default language but edit only their assigned language of the content.

Would this need a lot of hooking if currently possible at all?

many thanks

Link to comment
Share on other sites

I've come across this module Dynamic Roles from Ryan that after some playing round with I notice let's you make roles specifically to do with a language.

So for example, on the field 'article_body' I am actually presented with multiple IDs on the dropdown for viewing/editing options.

These IDs are listed named in the format 'data1017', 'data1018' and so on and seem to refer to the language tabs on the field.

So I wonder is there some way to combine roles and dynamic roles to let specific users only view/edit specific languages on fields? It feels like there are some clues here?!

  • Like 1
Link to comment
Share on other sites

I've come across this module Dynamic Roles from Ryan that after some playing round with I notice let's you make roles specifically to do with a language.

So for example, on the field 'article_body' I am actually presented with multiple IDs on the dropdown for viewing/editing options.

These IDs are listed named in the format 'data1017', 'data1018' and so on and seem to refer to the language tabs on the field.

So I wonder is there some way to combine roles and dynamic roles to let specific users only view/edit specific languages on fields? It feels like there are some clues here?!

Nice find, I am going to play around with it now and see what can be found...

  • Like 1
Link to comment
Share on other sites

Hello,

How is your site's structure?

For one "article", do you have all your languages in the same page or do you have 12 separate pages?

Can you give more details?

All on one page - I'm using the TextareaLanguage and TextLanguage fields and have the tabs for 12x languages on each field.

Link to comment
Share on other sites

I am looking throught the Dynamic Roles plugin and it doesn't seem to support multi languages in this scenario (using TextareaLanguage / TextLanguage and others). Unless I am missing something.

So at the moment to achieve language translator access without ability to edit/add/delete the main language version (or other languages one isn't allowed) you would have to create duplicate pagetree for each language?

Link to comment
Share on other sites

I am looking throught the Dynamic Roles plugin and it doesn't seem to support multi languages in this scenario (using TextareaLanguage / TextLanguage and others). Unless I am missing something.

So at the moment to achieve language translator access without ability to edit/add/delete the main language version (or other languages one isn't allowed) you would have to create duplicate pagetree for each language?

Maybe it's not really supported - I just saw if you select a Tecxtarealanguage field you are then presented with IDs in the second dropdown in the 'What can they view?' 'What can they edit?' options (and only when you add them as 'subfields') see image below:

8TN3SPW.png?1

  • Like 1
Link to comment
Share on other sites

Maybe it's not really supported - I just saw if you select a Tecxtarealanguage field you are then presented with IDs in the second dropdown in the 'What can they view?' 'What can they edit?' options (and only when you add them as 'subfields') see image below:

8TN3SPW.png?1

Exactly - all the language fields (non default that is) come up with data1234 (where the digit is the language ID). Unless there is a way to inject regex in the selector this would be non-practical to do in a site with more than a few fields. Although technically - it seems like it would work. Would be cool to get some extra help from Ryan to add proper language support though. It's a supercool module! even for small sites.

I am just not sure wether this is something that should be worked into language support itself or in this module.

Link to comment
Share on other sites

Exactly - all the language fields (non default that is) come up with data1234 (where the digit is the language ID). Unless there is a way to inject regex in the selector this would be non-practical to do in a site with more than a few fields. Although technically - it seems like it would work. Would be cool to get some extra help from Ryan to add proper language support though. It's a supercool module! even for small sites.

I am just not sure wether this is something that should be worked into language support itself or in this module.

Agreed, it's sort of a tantilising glimpse that something may be possible with the correct knowhow.

It would be a really cool module - the flexibility of Processwire continues to amaze me.

Link to comment
Share on other sites

I don't know if it's off topic, or not.

With the Image type field you can "Disable multi-language descriptions" in the Input tab, as you perhaps already know.

And when you log in with a user with a specific language you only have the (image) description "field" for that language.

Once all the tabs are completed (or not) with content, perhaps, with a little tweak/hack, it could be possible to do this for each field or for all the fields from a certain "group"/template at once, or something like that, from the backend.

Link to comment
Share on other sites

And when you log in with a user with a specific language you only have the (image) description "field" for that language.

That's not like it's supposed to work. It's most likely a bug. If one sets up the field with disabled multilaguage descriptions from the beginning, then it really doesn't use languages. https://github.com/ryancramerdesign/ProcessWire/issues/1161

Link to comment
Share on other sites

Ok so I got what I think is a workable solution...

  1. Installed Ryan's Page Edit Field Permission module
  2. Created 'language alternate field values' for each of my languages for each field, rather than using the multi-language fields.
  3. Added these fields as permissions using Ryan's module.
  4. Created roles for each language, so for example 'german_translator' role can only access the German alternate fields.

It all seems to work well, and hopefully is pretty much exactly what the client was looking for in my first post.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks 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...